Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patching not working since Errorprone 2.26.0 #1080

Open
protocol7 opened this issue Nov 28, 2024 · 4 comments
Open

Patching not working since Errorprone 2.26.0 #1080

protocol7 opened this issue Nov 28, 2024 · 4 comments

Comments

@protocol7
Copy link

protocol7 commented Nov 28, 2024

Since Errorprone 2.26.0, and perhaps this change google/error-prone#4028, patching does not seem to work with NullAway. Instead we get the following error:

An exception has occurred in the compiler (21.0.5). Please file a bug against the Java compiler via the Java bug reporting page (https://bugreport.java.com) after checking the Bug Database (https://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
com.google.errorprone.scanner.ErrorProneInjector$ProvisionException: Failed to initialize com.uber.nullaway.NullAway
	at com.google.errorprone.scanner.ErrorProneInjector.getInstance(ErrorProneInjector.java:92)
	at com.google.errorprone.scanner.ErrorProneInjector.getInstance(ErrorProneInjector.java:65)
	at com.google.errorprone.scanner.ScannerSupplierImpl.instantiateChecker(ScannerSupplierImpl.java:66)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1939)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
	at com.google.errorprone.scanner.ScannerSupplierImpl.get(ScannerSupplierImpl.java:74)
	at com.google.errorprone.scanner.ScannerSupplierImpl.get(ScannerSupplierImpl.java:37)
	at com.google.errorprone.ErrorProneAnalyzer.lambda$createAnalyzer$1(ErrorProneAnalyzer.java:91)
	at com.google.common.base.Suppliers$NonSerializableMemoizingSupplier.get(Suppliers.java:200)
	at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:227)
	at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:133)
	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1436)
	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1383)
	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:963)
	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:319)
	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:178)
	at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:64)
	at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:50)
Caused by: java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:74)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:502)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:486)
	at com.google.errorprone.scanner.ErrorProneInjector.getInstance(ErrorProneInjector.java:90)
	... 23 more
Caused by: java.lang.IllegalStateException: DO NOT report an issue to Error Prone for this crash!  NullAway configuration is incorrect.  Must specify annotated packages, using the -XepOpt:NullAway:AnnotatedPackages=[...] flag.  If you feel you have gotten this message in error report an issue at https://github.com/uber/NullAway/issues.
	at com.uber.nullaway.ErrorProneCLIFlagsConfig.<init>(ErrorProneCLIFlagsConfig.java:241)
	at com.uber.nullaway.NullAway.<init>(NullAway.java:293)
	at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:62)
	... 26 more

This is using NullAway 0.12.1 and javac with -Xep:NullAway:WARN -XepOpt:NullAway:AnnotatedPackages=com.helloworld -XepOpt:NullAway:SuggestSuppressions=true -XepPatchChecks:NullAway -XepPatchLocation:/tmp/tmp.patch. I've tried various combinations of these settings, e.g. including and excluding -Xep:NullAway:WARN with the same results.

This works as expected with Errorprone 2.25.0, and does not work with Errorprone from 2.26.0 up until at least 2.35.1.

Not sure if this is best reported here or with Errorprone, but following the advise in the error message :)

@Stephan202
Copy link

Hey @protocol7! Looking at the error, this may be one of the rare cases where the "DO NOT report an issue to Error Prone for this crash!" statement may be ignored 😅. Luckily I already filed a pull request that proposes a fix: google/error-prone#4699.

@protocol7
Copy link
Author

That's great timing :)

@msridhar
Copy link
Collaborator

msridhar commented Dec 3, 2024

Thank you for the report @protocol7! I've hacked up a NullAway test here, based heavily on the test @Stephan202 wrote on google/error-prone#4699:

master...msridhar:NullAway:test-auto-patching

I confirmed this test passes under EP 2.25.0 but fails under EP 2.26.0. Unfortunately I don't see an easy way to work around this issue on the NullAway side. For now, I've added a note to our auto suppression docs noting the Error Prone version incompatibility.

FYI @cushon

@cushon
Copy link

cushon commented Dec 4, 2024

passes under EP 2.25.0 but fails under EP 2.26.0

I initially mis-read that as 2.36.0 and was confused about what the regression was (:

2.26.0 contained google/error-prone@9da2d55, which is consistent with google/error-prone#4699 helping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants