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

JDK 14/15 compatibility #1106

Closed
don-vip opened this issue Sep 2, 2018 · 48 comments
Closed

JDK 14/15 compatibility #1106

don-vip opened this issue Sep 2, 2018 · 48 comments
Assignees

Comments

@don-vip
Copy link
Contributor

don-vip commented Sep 2, 2018

What version of Error Prone are you using?

2.3.4 (originally 2.3.1)

Does this issue reproduce with the latest release?

Yes

What did you do?

Error-prone does not work with JDK12 EA b09 and produces the following exception:

    [javac] 1 warning
    [javac] An exception has occurred in the compiler (12-ea). 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.
    [javac] java.lang.NoSuchMethodError: com.sun.tools.javac.util.Log.error(Lcom/sun/tools/javac/util/JCDiagnostic$DiagnosticPosition;Ljava/lang/String;[Ljava/lang/Object;)V
    [javac] 	at com.google.errorprone.ErrorProneError.logFatalError(ErrorProneError.java:55)
    [javac] 	at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:155)
    [javac] 	at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:132)
    [javac] 	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1418)
    [javac] 	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1365)
    [javac] 	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:960)
    [javac] 	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:311)
    [javac] 	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:170)
    [javac] 	at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
    [javac] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [javac] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    [javac] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [javac] 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    [javac] 	at org.apache.tools.ant.taskdefs.compilers.Javac13.execute(Javac13.java:57)
    [javac] 	at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1404)
    [javac] 	at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:1133)
    [javac] 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    [javac] 	at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    [javac] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [javac] 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    [javac] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
    [javac] 	at org.apache.tools.ant.Task.perform(Task.java:350)
    [javac] 	at org.apache.tools.ant.Target.execute(Target.java:449)
    [javac] 	at org.apache.tools.ant.Target.performTasks(Target.java:470)
    [javac] 	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1388)
    [javac] 	at org.apache.tools.ant.Project.executeTarget(Project.java:1361)
    [javac] 	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    [javac] 	at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
    [javac] 	at org.apache.tools.ant.Main.runBuild(Main.java:834)
    [javac] 	at org.apache.tools.ant.Main.startAnt(Main.java:223)
    [javac] 	at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
    [javac] 	at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)

It works fine with previous build (JDK 12 EA b08). I don't know what change causes this error.

@tbroyer
Copy link
Contributor

tbroyer commented Sep 2, 2018

See #860 (and #448); Error Prone 2.3.1 doesn't even officially support JDK 10 and 11.

@cushon
Copy link
Collaborator

cushon commented Sep 2, 2018

It works fine with previous build (JDK 12 EA b08).

I'm surprised that it regressed, I wouldn't expect 2.3.1 to work with JDK 12 in general.

The next release should work better with JDK 10 and up, can you try the latest snapshot?

@don-vip
Copy link
Contributor Author

don-vip commented Sep 2, 2018

2.3.1 works with JDK 10, 11 and first EA builds of JDK 12 when used as a javac plugin, as advised in #860 comments. Up to b08 there was nothing really new in JDK 12 EA. b09 introduced compiler support for Switch Expressions, I guess this is where the regression comes from. I'm going to try latest snapshot.

simon04 pushed a commit to JOSM/josm that referenced this issue Sep 2, 2018
@don-vip
Copy link
Contributor Author

don-vip commented Sep 2, 2018

I have a new error with 2.3.2-SNAPSHOT:

    [javac] /var/lib/jenkins/jobs/Java-EarlyAccess-Integration/workspace/jdk/JDK12/src/org/openstreetmap/gui/jmapviewer/DefaultMapController.java:131: error: An unhandled exception was thrown by the Error Prone static analysis plugin.
    [javac]                 break;
    [javac]                 ^
    [javac]      Please report this at https://github.com/google/error-prone/issues/new and include the following:
    [javac]   
    [javac]      error-prone version: 2.3.2-SNAPSHOT
    [javac]      BugPattern: Finally
    [javac]      Stack Trace:
    [javac]      java.lang.NoSuchFieldError: label
    [javac]   	at com.google.errorprone.bugpatterns.Finally$FinallyJumpMatcher.<init>(Finally.java:173)
    [javac]   	at com.google.errorprone.bugpatterns.Finally.matchBreak(Finally.java:81)
    [javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitBreak(ErrorProneScanner.java:537)
    [javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitBreak(ErrorProneScanner.java:146)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBreak.accept(JCTree.java:1575)
    [javac]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
    [javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:82)
    [javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:42)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:91)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:106)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:114)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitCase(TreeScanner.java:372)
    [javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitCase(ErrorProneScanner.java:558)
    [javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitCase(ErrorProneScanner.java:146)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCase.accept(JCTree.java:1293)
    [javac]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
    [javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:82)
    [javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:42)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:106)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:114)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitSwitch(TreeScanner.java:333)
    [javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitSwitch(ErrorProneScanner.java:1034)
    [javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitSwitch(ErrorProneScanner.java:146)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCSwitch.accept(JCTree.java:1235)
    [javac]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
    [javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:82)
    [javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:42)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:91)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:106)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:249)
    [javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitBlock(ErrorProneScanner.java:528)
    [javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitBlock(ErrorProneScanner.java:146)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1038)
    [javac]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
    [javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:82)
    [javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:42)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:91)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:207)
    [javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:896)
    [javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:146)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:904)
    [javac]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
    [javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:82)
    [javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:42)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:91)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:106)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:114)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:188)
    [javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:588)
    [javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:146)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:814)
    [javac]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
    [javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:82)
    [javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:42)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:106)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:114)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitCompilationUnit(TreeScanner.java:145)
    [javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:603)
    [javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:146)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:597)
    [javac]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:56)
    [javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:64)
    [javac]   	at com.google.errorprone.scanner.ErrorProneScannerTransformer.apply(ErrorProneScannerTransformer.java:43)
    [javac]   	at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:152)
    [javac]   	at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:132)
    [javac]   	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1418)
    [javac]   	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1365)
    [javac]   	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:960)
    [javac]   	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:311)
    [javac]   	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:170)
    [javac]   	at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
    [javac]   	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [javac]   	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    [javac]   	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [javac]   	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    [javac]   	at org.apache.tools.ant.taskdefs.compilers.Javac13.execute(Javac13.java:57)
    [javac]   	at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1404)
    [javac]   	at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:1133)
    [javac]   	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    [javac]   	at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    [javac]   	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [javac]   	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    [javac]   	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
    [javac]   	at org.apache.tools.ant.Task.perform(Task.java:350)
    [javac]   	at org.apache.tools.ant.Target.execute(Target.java:449)
    [javac]   	at org.apache.tools.ant.Target.performTasks(Target.java:470)
    [javac]   	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1388)
    [javac]   	at org.apache.tools.ant.Project.executeTarget(Project.java:1361)
    [javac]   	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    [javac]   	at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
    [javac]   	at org.apache.tools.ant.Main.runBuild(Main.java:834)
    [javac]   	at org.apache.tools.ant.Main.startAnt(Main.java:223)
    [javac]   	at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
    [javac]   	at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)
    [javac] 1 error
    [javac] 1 warning

floscher pushed a commit to floscher/josm that referenced this issue Sep 2, 2018
@don-vip
Copy link
Contributor Author

don-vip commented Sep 3, 2018

Change found: http://hg.openjdk.java.net/jdk/jdk/rev/de411d537aae#l26.131

     public static class JCBreak extends JCStatement implements BreakTree {
-        public Name label;
+        public JCExpression value;
         public JCTree target;
-        protected JCBreak(Name label, JCTree target) {
-            this.label = label;
+        protected JCBreak(JCExpression value, JCTree target) {
+            this.value = value;
             this.target = target;
         }
         @Override
         public void accept(Visitor v) { v.visitBreak(this); }
+        public boolean isValueBreak() {
+            return target != null && target.hasTag(SWITCH_EXPRESSION);
+        }
         @DefinedBy(Api.COMPILER_TREE)
         public Kind getKind() { return Kind.BREAK; }
         @DefinedBy(Api.COMPILER_TREE)
-        public Name getLabel() { return label; }
+        public Name getLabel() {
+            return value != null && value.getKind() == Kind.IDENTIFIER ? ((JCIdent) value).getName() : null;
+        }

I guess we can just replace .label by .getLabel() for now.

don-vip added a commit to don-vip/error-prone that referenced this issue Sep 3, 2018
@don-vip
Copy link
Contributor Author

don-vip commented Sep 4, 2018

With #1107 used on our project we get a new error:

[javac] /var/lib/jenkins/jobs/Java-EarlyAccess-Integration/workspace/jdk/JDK12/src/org/openstreetmap/josm/gui/NavigatableComponent.java:1297: error: An unhandled exception was thrown by the Error Prone static analysis plugin.
    [javac]     public final WaySegment getNearestWaySegment(Point p, Predicate<OsmPrimitive> predicate,
    [javac]                             ^
    [javac]      Please report this at https://github.com/google/error-prone/issues/new and include the following:
    [javac]   
    [javac]      error-prone version: 2.3.2-SNAPSHOT
    [javac]      BugPattern: GuardedBy
    [javac]      Stack Trace:
    [javac]      java.lang.NullPointerException
    [javac]   	at com.google.errorprone.bugpatterns.threadsafety.HeldLockAnalyzer$LockScanner.checkMatch(HeldLockAnalyzer.java:227)
    [javac]   	at com.google.errorprone.bugpatterns.threadsafety.HeldLockAnalyzer$LockScanner.visitIdentifier(HeldLockAnalyzer.java:196)
    [javac]   	at com.google.errorprone.bugpatterns.threadsafety.HeldLockAnalyzer$LockScanner.visitIdentifier(HeldLockAnalyzer.java:116)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:2324)
    [javac]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitBreak(TreeScanner.java:472)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBreak.accept(JCTree.java:1575)
    [javac]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:91)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:106)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:249)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1038)
    [javac]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:91)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitIf(TreeScanner.java:445)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCIf.accept(JCTree.java:1498)
    [javac]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:91)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:106)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:249)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1038)
    [javac]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:91)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitEnhancedForLoop(TreeScanner.java:307)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCEnhancedForLoop.accept(JCTree.java:1178)
    [javac]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:106)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:249)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1038)
    [javac]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:91)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitEnhancedForLoop(TreeScanner.java:307)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCEnhancedForLoop.accept(JCTree.java:1178)
    [javac]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitLabeledStatement(TreeScanner.java:320)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCLabeledStatement.accept(JCTree.java:1206)
    [javac]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:91)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:106)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:249)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1038)
    [javac]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:91)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:207)
    [javac]   	at com.google.errorprone.bugpatterns.threadsafety.HeldLockAnalyzer$LockScanner.visitMethod(HeldLockAnalyzer.java:153)
    [javac]   	at com.google.errorprone.bugpatterns.threadsafety.HeldLockAnalyzer$LockScanner.visitMethod(HeldLockAnalyzer.java:116)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:904)
    [javac]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:56)
    [javac]   	at com.google.errorprone.bugpatterns.threadsafety.HeldLockAnalyzer.analyze(HeldLockAnalyzer.java:88)
    [javac]   	at com.google.errorprone.bugpatterns.threadsafety.GuardedByChecker.analyze(GuardedByChecker.java:75)
    [javac]   	at com.google.errorprone.bugpatterns.threadsafety.GuardedByChecker.matchMethod(GuardedByChecker.java:64)
    [javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:890)
    [javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:146)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:904)
    [javac]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
    [javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:82)
    [javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:42)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:91)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:106)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:114)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:188)
    [javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:588)
    [javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:146)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:814)
    [javac]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
    [javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:82)
    [javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:42)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:106)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:114)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitCompilationUnit(TreeScanner.java:145)
    [javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:603)
    [javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:146)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:597)
    [javac]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:56)
    [javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:64)
    [javac]   	at com.google.errorprone.scanner.ErrorProneScannerTransformer.apply(ErrorProneScannerTransformer.java:43)
    [javac]   	at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:141)
    [javac]   	at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:132)
    [javac]   	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1418)
    [javac]   	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1365)
    [javac]   	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:960)
    [javac]   	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:311)
    [javac]   	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:170)
    [javac]   	at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
    [javac]   	at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)
    [javac] 1 error

simon04 pushed a commit to JOSM/josm that referenced this issue Sep 5, 2018
floscher pushed a commit to floscher/josm that referenced this issue Sep 5, 2018
@don-vip
Copy link
Contributor Author

don-vip commented Sep 5, 2018

Third problem:

    [javac] /var/lib/jenkins/jobs/Java-EarlyAccess-Integration/workspace/jdk/JDK12/src/org/openstreetmap/josm/actions/SessionSaveAsAction.java:185: error: An unhandled exception was thrown by the Error Prone static analysis plugin.
    [javac]     public class SessionSaveAsDialog extends ExtendedDialog {
    [javac]            ^
    [javac]      Please report this at https://github.com/google/error-prone/issues/new and include the following:
    [javac]   
    [javac]      error-prone version: 2.3.2-SNAPSHOT
    [javac]      BugPattern: ClassCanBeStatic
    [javac]      Stack Trace:
    [javac]      java.lang.NullPointerException
    [javac]   	at com.google.errorprone.bugpatterns.CanBeStaticAnalyzer.visitIdent(CanBeStaticAnalyzer.java:60)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:2316)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.visitBreak(TreeScanner.java:222)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBreak.accept(JCTree.java:1559)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.visitBlock(TreeScanner.java:143)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1026)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.visitIf(TreeScanner.java:213)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCIf.accept(JCTree.java:1486)

simon04 pushed a commit to JOSM/josm that referenced this issue Sep 5, 2018
@don-vip
Copy link
Contributor Author

don-vip commented Sep 5, 2018

And finally with #1107 + #1110 + #1111 we're able to run error_prone on JOSM source code with JDK 12!

@mmoayyed
Copy link

Might have found a new one:

openjdk version "12-ea" 2019-03-19
OpenJDK Runtime Environment (build 12-ea+23)

...where the error is:

public abstract class RootCasException extends RuntimeException {
                ^
     Please report this at https://github.com/google/error-prone/issues/new and include the following:
  
     error-prone version: 2.3.3-SNAPSHOT
     BugPattern: OverrideThrowableToString
     Stack Trace:
     java.lang.AssertionError
  	at com.google.errorprone.fixes.SuggestedFixes.renameMethod(SuggestedFixes.java:463)
  	at com.google.errorprone.bugpatterns.OverrideThrowableToString.lambda$matchClass$4(OverrideThrowableToString.java:67)
  	at java.base/java.util.Optional.map(Optional.java:265)
  	at com.google.errorprone.bugpatterns.OverrideThrowableToString.matchClass(OverrideThrowableToString.java:67)
  	at com.google.errorprone.scanner.ErrorProneScanner.processMatchers(ErrorProneScanner.java:424)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:521)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:148)

Full log: https://travis-ci.org/apereo/cas/jobs/465117781

Using 2.3.3-SNAPSHOT.

@don-vip
Copy link
Contributor Author

don-vip commented Feb 5, 2019

Since today, we fail to use error_prone with JDK13:

openjdk version "13-ea" 2019-09-17
OpenJDK Runtime Environment (build 13-ea+6)
OpenJDK 64-Bit Server VM (build 13-ea+6, mixed mode, sharing)

    [javac]     public static <T> T find(Iterable<? extends T> collection, Predicate<? super T> predicate) {
    [javac]                         ^
    [javac]      Please report this at https://github.com/google/error-prone/issues/new and include the following:
    [javac]   
    [javac]      error-prone version: 2.3.2-SNAPSHOT
    [javac]      BugPattern: TypeParameterUnusedInFormals
    [javac]      Stack Trace:
    [javac]      java.lang.NoSuchFieldError: bound
    [javac]   	at com.google.errorprone.bugpatterns.TypeParameterUnusedInFormals.matchMethod(TypeParameterUnusedInFormals.java:73)
    [javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:890)
    [javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:146)
    [javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:904)
    [javac]   	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
    [javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:82)
    [javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:42)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:91)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:106)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:114)
    [javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:188)
    [javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:588)
    [javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:146)

(using JOSM patched version containing fixes #1107 + #1110 + #1111)

@don-vip don-vip changed the title JDK 12 compatibility JDK 12/13 compatibility Feb 11, 2019
don-vip added a commit to don-vip/error-prone that referenced this issue Feb 11, 2019
don-vip added a commit to don-vip/error-prone that referenced this issue Feb 11, 2019
don-vip added a commit to don-vip/error-prone that referenced this issue Feb 11, 2019
@don-vip
Copy link
Contributor Author

don-vip commented Feb 11, 2019

Problem fixed in #1225. With #1107 + #1110 + #1111 + #1225 error_prone works with Java 8 to 13 for us.

cushon added a commit that referenced this issue May 19, 2020
@cushon cushon pinned this issue May 19, 2020
@cushon cushon changed the title JDK 12/13/14/15 compatibility JDK 14/15 compatibility May 20, 2020
@davido
Copy link
Contributor

davido commented May 24, 2020

I'm experimenting with adding Java 14 toolchain support to Bazel. And after upgrading error prone to 2.3.5-SNAPSHOT in Bazel, trying to build simple Java 14 syntax program in Bazel test is failing with NCDFE:

  $ bazel test src/test/shell/bazel:bazel_java14_test
[...]
Target //src/test/shell/bazel:bazel_java14_test up-to-date:
  bazel-bin/src/test/shell/bazel/bazel_java14_test
INFO: Elapsed time: 279.479s, Critical Path: 186.00s
INFO: 1026 processes: 448 linux-sandbox, 1 local, 577 worker.
INFO: Build completed, 1 test FAILED, 1032 total actions
//src/test/shell/bazel:bazel_java14_test                                 FAILED in 75.2s

  $ cat bazel-out/k8-fastbuild/testlogs/src/test/shell/bazel/bazel_java14_test/test.log
  external/openjdk14_linux_archive/bin/java -XX:+UseParallelOldGC -XX:-CompactStrings '--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.comp=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.tree=ALL-UNNAMED' '--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED' '--add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED' '--add-opens=java.base/java.nio=ALL-UNNAMED' '--add-opens=java.base/java.lang=ALL-UNNAMED' -jar external/local_java_tools/java_tools/JavaBuilder_deploy.jar @bazel-out/k8-fastbuild/bin/java/main/Javac14Example.jar-0.params @bazel-out/k8-fastbuild/bin/java/main/Javac14Example.jar-1.params)
Execution platform: @local_config_platform//:host
Note: java/main/Javac14Example.java uses preview language features.
Note: Recompile with -Xlint:preview for details.
error: An unhandled exception was thrown by the Error Prone static analysis plugin.
     Please report this at https://github.com/google/error-prone/issues/new and include the following:

     error-prone version: 2.3.5-SNAPSHOT
     BugPattern: (see stack trace)
     Stack Trace:
     java.lang.NoClassDefFoundError: Could not initialize class com.google.errorprone.util.ASTHelpers
        at com.google.errorprone.SuppressionInfo$1.visitClass(SuppressionInfo.java:117)
        at com.google.errorprone.SuppressionInfo$1.visitClass(SuppressionInfo.java:114)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:823)
        at jdk.compiler/com.sun.source.util.SimpleTreeVisitor.visit(SimpleTreeVisitor.java:80)
        at jdk.compiler/com.sun.source.util.SimpleTreeVisitor.visit(SimpleTreeVisitor.java:94)
        at com.google.errorprone.SuppressionInfo.forCompilationUnit(SuppressionInfo.java:121)
        at com.google.errorprone.scanner.Scanner.updateSuppressions(Scanner.java:87)
        at com.google.errorprone.scanner.Scanner.scan(Scanner.java:54)
        at com.google.errorprone.scanner.ErrorProneScannerTransformer.apply(ErrorProneScannerTransformer.java:43)
        at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:152)
        at com.google.devtools.build.buildjar.javac.plugins.errorprone.ErrorPronePlugin.postFlow(ErrorPronePlugin.java:161)

Interestingly, with outdated EP version on Bazel@HEAD (2.3.2-SNAPSHOT) it worked. This is the test program:

function test_java14_record_type() {
  mkdir -p java/main
  cat >java/main/BUILD <<EOF
java_binary(
    name = 'Javac14Example',
    srcs = ['Javac14Example.java'],
    main_class = 'Javac14Example',
    javacopts = ["--enable-preview"],
    jvm_flags = ["--enable-preview"],
)
EOF

  cat >java/main/Javac14Example.java <<EOF
public class Javac14Example {
  record Point(int x, int y) {}
  public static void main(String[] args) {
    Point point = new Point(0, 1);
    System.out.println(point.x);
  }
}
EOF
  bazel run java/main:Javac14Example --test_output=all --verbose_failures &>"${TEST_log}"
  expect_log "0"
}

Is there any versions of EP available for me to try out to overcome that problem today? Let me know if you need a reproducer.

@cushon
Copy link
Collaborator

cushon commented May 24, 2020

@davido Error Prone doesn't support JDK 14+ yet, this is the bug for that. This branch includes some WIP that has the tests passing on 14: https://github.com/google/error-prone/tree/jdk14

It's not clear why you're getting a NCDFE, or whether it's related to JDK 14 support. Can you file a new bug with a repro? Are you sure you're not just missing a dependency (maybe on caffeine, which ASTHelpers now references)?

@davido
Copy link
Contributor

davido commented May 25, 2020

@cushon Thanks, indeed, caffeine-cache was missing ;-(

Are you sure you're not just missing a dependency (maybe on caffeine, which ASTHelpers now references)?

I uploaded two PRs for upgrading EP version in Bazel: to 2.3.4 (with new dependency on caffeine-cache) and to 2.3.5-SNAPSHOT (with new dependency on threeten-extra-1.5.0.jar). In preparation of the third PR: adding support for JDK 14 I did a mistake any only cherry-picked commit for 2.3.5-SNAPSHOT upgrade and in fact, transitive dependency on caffeine-cache was missing.

cushon added a commit to cushon/error-prone that referenced this issue May 26, 2020
kevinb9n pushed a commit that referenced this issue May 26, 2020
They've been deprecated since 2018 and are incompatible with JDK 15.

#1106

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=313252393
kevinb9n pushed a commit that referenced this issue May 26, 2020
kevinb9n pushed a commit that referenced this issue May 26, 2020
They've been deprecated since 2018 and are incompatible with JDK 15.

#1106

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=313252393
kevinb9n pushed a commit that referenced this issue May 26, 2020
cushon added a commit to cushon/error-prone that referenced this issue May 26, 2020
kevinb9n pushed a commit that referenced this issue May 26, 2020
It has a new getter for instanceof patterns, for now we proxy it to handle the
new getter (and the new PatterTree AST node type that it returns) and
unconditionally return `null`. This will require more work to actually support
refaster matches on instanceof patterns.

#1106

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=313270135
kevinb9n pushed a commit that referenced this issue May 26, 2020
The return type is a non-null 'void' type in recent JDK versions.

#1106

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=313289453
kevinb9n pushed a commit that referenced this issue May 27, 2020
It has a new getter for instanceof patterns, for now we proxy it to handle the
new getter (and the new PatterTree AST node type that it returns) and
unconditionally return `null`. This will require more work to actually support
refaster matches on instanceof patterns.

#1106

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=313270135
kevinb9n pushed a commit that referenced this issue May 27, 2020
The return type is a non-null 'void' type in recent JDK versions.

#1106

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=313289453
cushon added a commit to cushon/error-prone that referenced this issue May 27, 2020
@cushon cushon closed this as completed in 746c15f May 27, 2020
@cushon
Copy link
Collaborator

cushon commented May 27, 2020

As of 746c15f, CI is passing with JDK 14 and 15.

I filed #1639 to track a 2.4.0 release that will include all of those changes.

@cushon cushon unpinned this issue May 27, 2020
@TimvdLippe
Copy link
Contributor

FYI 2.4.0 has now been released and is available on maven central: https://mvnrepository.com/artifact/com.google.errorprone/error_prone_core

@don-vip
Copy link
Contributor Author

don-vip commented Oct 25, 2020

@cushon can you please take a look to #1872 ? I don't see an easy way to keep compatibility with older and newer versions of Java with this change.

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