Custom checkers with java 17

667 views
Skip to first unread message

Sergei Shevlyagin

unread,
May 19, 2022, 10:59:28 PM5/19/22
to error-prone-discuss
I'm having trouble getting my custom checks to build with java 17. The core error prone library works just fine following the directions in https://errorprone.info/docs/installation, however I can't get the custom checks we've had working under java 11 to work. I have both the tree and utils libraries that the error is complaining about in the jvmArgs of the daemon. Any suggestions?

Thanks,
Sergei

Error:
Started Gradle worker daemon (0.149 secs) with fork options DaemonForkOptions{executable=/Users/sshevlyagin/Library/Java/JavaVirtualMachines/corretto-17.0.3/Contents/Home/bin/java, minHeapSize=null, maxHeapSize=null, jvmArgs=[--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED, --add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED, --add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED, --add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED, --add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED, --add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED, --add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED, --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED, --add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED, --add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED], keepAliveMode=SESSION}.
Compiling with JDK Java compiler API.
/Users/sshevlyagin/xxx/errorprone/bugpatterns/UseCompletableFutureWithExecutorServiceChecker.java:78: error: cannot access JCDiagnostic
            return describeMatch(tree, fix);
                   ^
  class file for com.sun.tools.javac.util.JCDiagnostic not found
/Users/sshevlyagin/xxx/errorprone/bugpatterns/UseCompletableFutureWithExecutorServiceChecker.java:86: error: cannot access JCTree
            return describeMatch(tree, fix);
                   ^
  class file for com.sun.tools.javac.tree.JCTree not found



Relevant build.gradle
tasks.withType(JavaCompile) {
options.fork = true
options.forkOptions.jvmArgs += ["--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED"]
options.forkOptions.jvmArgs += ["--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED"]
options.forkOptions.jvmArgs += ["--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED"]
options.forkOptions.jvmArgs += ["--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED"]
options.forkOptions.jvmArgs += ["--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED"]
options.forkOptions.jvmArgs += ["--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED"]
options.forkOptions.jvmArgs += ["--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED"]
options.forkOptions.jvmArgs += ["--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"]
options.forkOptions.jvmArgs += ["--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED"]
options.forkOptions.jvmArgs += ["--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED"]
}


Sergei Shevlyagin

unread,
May 19, 2022, 11:18:58 PM5/19/22
to error-prone-discuss
A different framing of the question, has anyone gotten custom error prone checks to work under gradle with java 17? How did you do it? 

Manu Sridharan

unread,
May 20, 2022, 12:36:03 AM5/20/22
to error-pro...@googlegroups.com
NullAway compiles and runs on Java 17.  This is the config we had to add, which is similar to yours:


The main difference I can see is that we don’t fork when compiling.

--Manu


--
Googlers: This an external list. Please be careful when posting.
---
You received this message because you are subscribed to the Google Groups "error-prone-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to error-prone-dis...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/error-prone-discuss/7e5afbfa-c48f-41e1-9a5b-71f162f24102n%40googlegroups.com.

Sergei Shevlyagin

unread,
May 20, 2022, 3:22:03 PM5/20/22
to error-prone-discuss
Manu you're a life saver. The problem was using `options.forks`.  THANK YOU THANK YOU THANK YOU

Sergei Shevlyagin

unread,
May 20, 2022, 3:41:57 PM5/20/22
to error-prone-discuss
Actually, the problem I setting options.forkOptions.jvmArgs where the NullAway code was setting options.compilerArgs. Forking was fine. Anyway, still solves it!

Manu Sridharan

unread,
May 20, 2022, 4:41:31 PM5/20/22
to error-pro...@googlegroups.com
Sure thing, glad I could help :-) 

--Manu


Reply all
Reply to author
Forward
0 new messages