Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,10 @@ docs/examples/BazelExample/bazel-testlogs
docs/examples/BazelExample/Out.txt
docs/examples/MavenExample/Out.txt
docs/examples/MavenExample-framework-all/Out.txt
docs/examples/errorprone/.gradle/
docs/examples/errorprone/Out.txt
docs/examples/nullaway/.gradle/
docs/examples/Wrong-Checker-Qual/Out.txt

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
docs/examples/Wrong-Checker-Qual/Out.txt
docs/examples/mismatched-checker-qual/Out.txt

docs/examples/nullaway/Out.txt
docs/examples/jspecify/.gradle/
docs/examples/jspecify/Out.txt
docs/examples/lombok/.gradle/
docs/examples/lombok/Out.txt
docs/examples/lombok/lombok.config
docs/manual/*.png
Expand All @@ -124,9 +121,7 @@ target/
*.ipr
*.iws
*.iml
/.gradle/
# TODO: why this second gradle directory?
/buildSrc/.gradle/
.gradle/
Comment thread
ShahriarAhnaf marked this conversation as resolved.

## Tests

Expand Down
3 changes: 3 additions & 0 deletions docs/examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ compile:
$(MAKE) -C MavenExample || (sleep 60 && echo "Trying again:" && $(MAKE) -C MavenExample)
$(MAKE) -C lombok
$(MAKE) -C errorprone
$(MAKE) -C Wrong-Checker-Qual
Comment thread
ShahriarAhnaf marked this conversation as resolved.
Outdated
$(MAKE) -C BazelExample
$(MAKE) -C nullaway
$(MAKE) -C jspecify


# TODO: type check the different files with the right checker;
# some tests expect errors, compare against expected errors.

Expand All @@ -28,6 +30,7 @@ clean:
$(MAKE) -C MavenExample clean
$(MAKE) -C lombok clean
$(MAKE) -C errorprone clean
$(MAKE) -C Wrong-Checker-Qual clean
$(MAKE) -C BazelExample clean
$(MAKE) -C nullaway clean
$(MAKE) -C jspecify clean
16 changes: 16 additions & 0 deletions docs/examples/Wrong-Checker-Qual/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
JAVA_VER := $(shell java -version 2>&1 | head -1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1 | sed 's/-ea//' | sed 's/-beta//')

.PHONY: all clean

ifeq ($(shell test $(JAVA_VER) -lt 17; echo $$?),0)
all:
@echo "Skipping test because errorprone does not work under Java ${JAVA_VER}"
else
all:
- ../../../gradlew build > Out.txt 2>&1
grep -qF "Exception: org.checkerframework.javacutil.BugInCF:" Out.txt
endif

clean:
- ../../../gradlew clean
rm -f Out.txt
60 changes: 60 additions & 0 deletions docs/examples/Wrong-Checker-Qual/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// ///////////////////////////////////////////////////////////////////////////
// Checker Framework pluggable type-checking and Error Prone example
Comment thread
ShahriarAhnaf marked this conversation as resolved.
Outdated
//

plugins {
id 'java'
id 'net.ltgt.errorprone' version '4.2.0'
// Checker Framework pluggable type-checking
id 'org.checkerframework' version '0.6.53' apply false
}

ext {
versions = [
eisopVersion: '3.49.3-eisop1',
]
}

apply plugin: 'org.checkerframework'
if (false) {
Comment thread
ShahriarAhnaf marked this conversation as resolved.
Outdated
def cfHome = "${projectDir}/../../.."
dependencies {
compileOnly files(cfHome + '/checker/dist/checker-qual.jar')
testCompileOnly files(cfHome + '/checker/dist/checker-qual.jar')
checkerFramework files(cfHome + '/checker/dist/checker.jar')
}
} else {
dependencies {
// Without the proper checker qualifiers, Nullness Checker should gracefully issue warnings
Comment thread
ShahriarAhnaf marked this conversation as resolved.
Outdated
// compileOnly "io.github.eisop:checker-qual:${versions.eisopVersion}"
// testCompileOnly "io.github.eisop:checker-qual:${versions.eisopVersion}"
checkerFramework "io.github.eisop:checker-qual:${versions.eisopVersion}"
checkerFramework "io.github.eisop:checker:${versions.eisopVersion}"
}
}

dependencies {
if (JavaVersion.current() >= JavaVersion.VERSION_17) {
errorprone 'com.google.errorprone:error_prone_core:2.38.0'
}
}

repositories {
// mavenLocal() // Use local Maven repository first for testing
mavenCentral()
}

checkerFramework {
checkers = [
'org.checkerframework.checker.nullness.NullnessChecker',
]
extraJavacArgs = ['-Aversion']
}

compileJava {
options.errorprone.enabled = (JavaVersion.current() >= JavaVersion.VERSION_17)
// A checker will only run if Error Prone does not issue any warnings. So
// convert the expected error to a warning to test that both Error Prone
// and the Nullness Checker run.
options.errorprone.warn('CollectionIncompatibleType')
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.example;

import java.util.Set;

public class Demo {
void demo(Set<Short> s, short i) {
s.remove(i - 1); // Error Prone error
s.add(null); // Nullness Checker error
}
}
Loading