Skip to content

Commit

Permalink
Update to Error Prone 2.18.0 (#707)
Browse files Browse the repository at this point in the history
Fixed some minor Javadoc warnings reported by the new version.  Also, adds an `@Inject` annotation on the main `NullAway` constructor, for compatibility with future versions of Error Prone that load checkers via Guice.
  • Loading branch information
msridhar authored Jan 22, 2023
1 parent d809795 commit 57a89e8
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 25 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ jobs:
epVersion: 2.4.0
- os: macos-latest
java: 11
epVersion: 2.16
epVersion: 2.18.0
- os: ubuntu-latest
java: 11
epVersion: 2.16
epVersion: 2.18.0
- os: windows-latest
java: 11
epVersion: 2.16
epVersion: 2.18.0
- os: ubuntu-latest
java: 17
epVersion: 2.16
epVersion: 2.18.0
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -70,7 +70,7 @@ jobs:
with:
arguments: coveralls
continue-on-error: true
if: runner.os == 'Linux' && matrix.java == '11' && matrix.epVersion == '2.16' && github.repository == 'uber/NullAway'
if: runner.os == 'Linux' && matrix.java == '11' && matrix.epVersion == '2.18.0' && github.repository == 'uber/NullAway'
- name: Check that Git tree is clean after build and test
run: ./.buildscript/check_git_clean.sh
publish_snapshot:
Expand Down
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ subprojects { project ->
check("PackageLocation", CheckSeverity.ERROR)
check("UnnecessaryAnonymousClass", CheckSeverity.ERROR)
check("UnusedException", CheckSeverity.ERROR)
// To enable auto-patching, uncomment the line below, replace [CheckerName] with
// the checker(s) you want to apply patches for (comma-separated), and above, disable
// "-Werror"
// errorproneArgs.addAll("-XepPatchChecks:[CheckerName]", "-XepPatchLocation:IN_PLACE")
}
} else {
// Disable Error Prone checks on JDK 8, as more recent Error Prone versions don't run on JDK 8
Expand Down
2 changes: 1 addition & 1 deletion gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import org.gradle.util.VersionNumber
// The oldest version of Error Prone that we support running on
def oldestErrorProneVersion = "2.4.0"
// Latest released Error Prone version that we've tested with
def latestErrorProneVersion = "2.16"
def latestErrorProneVersion = "2.18.0"
// Default to using latest tested Error Prone version, except on Java 8, where 2.10.0 is the last version
// that works
def defaultErrorProneVersion = JavaVersion.current() >= JavaVersion.VERSION_11 ? latestErrorProneVersion : "2.10.0"
Expand Down
1 change: 1 addition & 0 deletions nullaway/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies {
annotationProcessor deps.apt.autoService
compileOnly deps.build.jsr305Annotations
compileOnly deps.test.jetbrainsAnnotations
compileOnly deps.apt.javaxInject


compileOnly deps.build.errorProneCheckApi
Expand Down
36 changes: 17 additions & 19 deletions nullaway/src/main/java/com/uber/nullaway/NullAway.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.lang.model.element.AnnotationMirror;
import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
Expand Down Expand Up @@ -277,6 +278,7 @@ public NullAway() {
moduleElementClass = null;
}

@Inject // For future Error Prone versions in which checkers are loaded using Guice
public NullAway(ErrorProneFlags flags) {
config = new ErrorProneCLIFlagsConfig(flags);
handler = Handlers.buildDefault(config);
Expand Down Expand Up @@ -2453,50 +2455,46 @@ static FieldInitEntities create(
ImmutableSet.copyOf(staticInitializerMethods));
}

/**
* @return symbol for class
*/
/** Returns symbol for class. */
abstract Symbol.ClassSymbol classSymbol();

/**
* @return <code>@NonNull</code> instance fields that are not directly initialized at
* declaration
* Returns <code>@NonNull</code> instance fields that are not directly initialized at
* declaration.
*/
abstract ImmutableSet<Symbol> nonnullInstanceFields();

/**
* @return <code>@NonNull</code> static fields that are not directly initialized at declaration
* Returns <code>@NonNull</code> static fields that are not directly initialized at declaration.
*/
abstract ImmutableSet<Symbol> nonnullStaticFields();

/**
* @return the list of instance initializer blocks (e.g. blocks of the form `class X { { //Code
* } } ), in the order in which they appear in the class
* Returns the list of instance initializer blocks (e.g. blocks of the form `class X { { //Code
* } } ), in the order in which they appear in the class.
*/
abstract ImmutableList<BlockTree> instanceInitializerBlocks();

/**
* @return the list of static initializer blocks (e.g. blocks of the form `class X { static {
* //Code } } ), in the order in which they appear in the class
* Returns the list of static initializer blocks (e.g. blocks of the form `class X { static {
* //Code } } ), in the order in which they appear in the class.
*/
abstract ImmutableList<BlockTree> staticInitializerBlocks();

/**
* @return the list of constructor
*/
/** Returns constructors in the class. */
abstract ImmutableSet<MethodTree> constructors();

/**
* @return the list of non-static (instance) initializer methods. This includes methods
* annotated @Initializer, as well as those specified by -XepOpt:NullAway:KnownInitializers
* or annotated with annotations passed to -XepOpt:NullAway:CustomInitializerAnnotations
* Returns the list of non-static (instance) initializer methods. This includes methods
* annotated @Initializer, as well as those specified by -XepOpt:NullAway:KnownInitializers or
* annotated with annotations passed to -XepOpt:NullAway:CustomInitializerAnnotations.
*/
abstract ImmutableSet<MethodTree> instanceInitializerMethods();

/**
* @return the list of static initializer methods. This includes static methods
* annotated @Initializer, as well as those specified by -XepOpt:NullAway:KnownInitializers
* or annotated with annotations passed to -XepOpt:NullAway:CustomInitializerAnnotations
* Returns the list of static initializer methods. This includes static methods
* annotated @Initializer, as well as those specified by -XepOpt:NullAway:KnownInitializers or
* annotated with annotations passed to -XepOpt:NullAway:CustomInitializerAnnotations.
*/
abstract ImmutableSet<MethodTree> staticInitializerMethods();
}
Expand Down

0 comments on commit 57a89e8

Please sign in to comment.