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

Custom checks can't be loaded when used as JavaC Plugin #974

Closed
tbroyer opened this issue Mar 24, 2018 · 6 comments
Closed

Custom checks can't be loaded when used as JavaC Plugin #974

tbroyer opened this issue Mar 24, 2018 · 6 comments

Comments

@tbroyer
Copy link
Contributor

tbroyer commented Mar 24, 2018

What version of Error Prone are you using?

2.2.0 (latest)

What did you do?

I'm writing a new Gradle plugin that integrates Error Prone as a JavaC plugin rather than relying on internal Gradle APIs: https://github.com/tbroyer/gradle-errorprone-javacplugin-plugin/ and came across this issue while writing more tests; but this can be reproduced on the command-line.

If possible, provide a recipe for reproducing the error.
A complete small program is good.

/usr/lib/jvm/java-9-openjdk/bin/javac -processorpath error_prone_ant-2.2.0.jar:nullaway-0.4.0.jar -Xplugin:ErrorProne Foo.java

What did you expect to see?

Class Foo should be compiled without error (or with Error Prone violations if any)

What did you see instead?

Compilation fails with exception while trying to load the custom check; likely a classloader issue:

An exception has occurred in the compiler (9.0.4). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.util.ServiceConfigurationError: com.google.errorprone.bugpatterns.BugChecker: com.uber.nullaway.NullAway not a subtype
	at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:588)
	at java.base/java.util.ServiceLoader.access$200(ServiceLoader.java:390)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1231)
	at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1259)
	at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1294)
	at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1379)
	at com.google.common.collect.Iterables.isEmpty(Iterables.java:1059)
	at com.google.errorprone.ErrorPronePlugins.loadPlugins(ErrorPronePlugins.java:49)
	at com.google.errorprone.ErrorProneAnalyzer.lambda$scansPlugins$0(ErrorProneAnalyzer.java:76)
	at com.google.common.base.Suppliers$NonSerializableMemoizingSupplier.get(Suppliers.java:160)
	at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:152)
	at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:120)
	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1404)
	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1363)
	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:959)
	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:302)
	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:162)
	at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
	at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)

#928 could possibly provide a solution. Or maybe Error Prone could use JavaFileManager.getServiceLoader when used with Java 9+? Or should it be seen as a JavaC bug? (tested in OpenJDK 9.0.4 and Oracle JDK 10, both exhibit the issue)

@tbroyer
Copy link
Contributor Author

tbroyer commented Mar 27, 2018

I see that it was supposedly fixed in 2.2.0 by 3e44e10, but I double-checked and confirm that I reproduce the issue with 2.2.0 (with and without the -J--add-exports=)

@cushon
Copy link
Collaborator

cushon commented Mar 27, 2018

I see that it was supposedly fixed in 2.2.0 by 3e44e10

3e44e10 didn't make it into 2.2.0, though. It works for me at head:

$ javac -fullversion -processorpath error_prone_ant-2.2.0.jar:nullaway-0.4.1.jar '-Xplugin:ErrorProne -XepOpt:NullAway:AnnotatedPackages=test' -XDcompilePolicy=byfile Foo.java
javac full version "9.0.4+11"
An exception has occurred in the compiler (9.0.4). Please file a bug against the Java compiler via the Java bug reporting page (http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com) for duplicates. Include your program and the following diagnostic in your report. Thank you.
java.util.ServiceConfigurationError: com.google.errorprone.bugpatterns.BugChecker: com.uber.nullaway.NullAway not a subtype
        at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:588)
        at java.base/java.util.ServiceLoader.access$200(ServiceLoader.java:390)
        at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNextService(ServiceLoader.java:1231)
        at java.base/java.util.ServiceLoader$LazyClassPathLookupIterator.hasNext(ServiceLoader.java:1259)
        at java.base/java.util.ServiceLoader$2.hasNext(ServiceLoader.java:1294)
        at java.base/java.util.ServiceLoader$3.hasNext(ServiceLoader.java:1379)
        at com.google.common.collect.Iterables.isEmpty(Iterables.java:1059)
        at com.google.errorprone.ErrorPronePlugins.loadPlugins(ErrorPronePlugins.java:49)
        at com.google.errorprone.ErrorProneAnalyzer.lambda$scansPlugins$0(ErrorProneAnalyzer.java:76)
        at com.google.common.base.Suppliers$NonSerializableMemoizingSupplier.get(Suppliers.java:160)
        at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:152)
        at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:120)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1404)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1353)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:952)
        at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:302)
        at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:162)
        at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
        at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)
$ javac -fullversion -processorpath error_prone_ant-2.2.1-
20180327.021500-39.jar:nullaway-0.4.1.jar '-Xplugin:ErrorProne -XepOpt:NullAway:AnnotatedPackages=test' -XDcompilePolicy=byfile Foo.java
javac full version "9.0.4+11"
Foo.java:4: warning: [NullAway] returning @Nullable expression from method with @NonNull return type
    return null;
    ^
    (see http://t.uber.com/nullaway )
1 warning

@tbroyer
Copy link
Contributor Author

tbroyer commented Mar 27, 2018

3e44e10 didn't make it into 2.2.0, though.

Ha, must have misread my gitk, thanks (and indeed commit was 10 days after 2.2.0 release).

Any ETA for 2.2.1?

@eaftan
Copy link
Contributor

eaftan commented Mar 27, 2018

I'm on the hook for 2.2.1, but I'm swamped through 4/6. So let's say the week of 4/9-13.

@tbroyer
Copy link
Contributor Author

tbroyer commented Mar 27, 2018

Snoozed the mail notification until then, will ping you if you're "late" 😉

@tbroyer
Copy link
Contributor Author

tbroyer commented Jun 11, 2018

2.3.0 has been released with the fix on 19 Apr, and then 2.3.1 on 21 Apr.

@tbroyer tbroyer closed this as completed Jun 11, 2018
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

3 participants