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

VarChecker produces NoSuchMethodError on Java 10 #1054

Closed
PhilippWendler opened this issue Jun 12, 2018 · 4 comments
Closed

VarChecker produces NoSuchMethodError on Java 10 #1054

PhilippWendler opened this issue Jun 12, 2018 · 4 comments

Comments

@PhilippWendler
Copy link

What version of Error Prone are you using?

2.3.1

Does this issue reproduce with the latest release?

Yes

What did you do?

Compile the following code with Error-Prone enabled by -Xplugin on OpenJDK version "10.0.1" 2018-04-17 using the "Var" checker:

import java.io.IOException;

public class Test {

  private Test() throws IOException, ReflectiveOperationException {}

  public static void main() {
    try {
      new Test();
    } catch (IOException | ReflectiveOperationException e) {
      throw new RuntimeException(e);
    }
  }
}

What did you expect to see?

Builds goes through.

What did you see instead?

A NoSuchMethodError (full stacktrace is below).

The problem seems to always occur for multi-catch, but not for catch statements with only a single exception. Probably this is related to the fact that for multi-catch statements, the variable is effectively final.

The problem does not occur with OpenJDK version "9.0.4" (using the same way of calling Error-Prone), nor with Java 8 and the old way of calling Error-Prone.

[javac] Test.java:30: error: An unhandled exception was thrown by the Error Prone static analysis plugin.
[javac]     } catch (IOException | ReflectiveOperationException e) {
[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.1
[javac]      BugPattern: Var
[javac]      Stack Trace:
[javac]      java.lang.NoSuchMethodError: com.sun.tools.javac.code.Source.allowEffectivelyFinalInInnerClasses()Z
[javac]   	at com.google.errorprone.bugpatterns.VarChecker.handleLocalOrParam(VarChecker.java:96)
[javac]   	at com.google.errorprone.bugpatterns.VarChecker.matchVariable(VarChecker.java:79)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitVariable(ErrorProneScanner.java:1147)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitVariable(ErrorProneScanner.java:145)
[javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:974)
[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.visitCatch(TreeScanner.java:389)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitCatch(ErrorProneScanner.java:572)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitCatch(ErrorProneScanner.java:145)
[javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCatch.accept(JCTree.java:1361)
[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:105)
[javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:113)
[javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitTry(TreeScanner.java:375)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitTry(ErrorProneScanner.java:1078)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitTry(ErrorProneScanner.java:145)
[javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCTry.accept(JCTree.java:1328)
[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:105)
[javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:248)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitBlock(ErrorProneScanner.java:527)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitBlock(ErrorProneScanner.java:145)
[javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1032)
[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:90)
[javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:206)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:895)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:145)
[javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:898)
[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:90)
[javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
[javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:113)
[javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:187)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:587)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:145)
[javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:808)
[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:105)
[javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:113)
[javac]   	at jdk.compiler/com.sun.source.util.TreeScanner.visitCompilationUnit(TreeScanner.java:144)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:602)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:145)
[javac]   	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:591)
[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:120)
[javac]   	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1410)
[javac]   	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1357)
[javac]   	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:952)
[javac]   	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:306)
[javac]   	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:165)
[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:564)
[javac]   	at org.apache.tools.ant.taskdefs.compilers.Javac13.execute(Javac13.java:57)
[javac]   	at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1416)
[javac]   	at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:1142)
[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:564)
[javac]   	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[javac]   	at org.apache.tools.ant.Task.perform(Task.java:350)
[javac]   	at org.apache.tools.ant.Target.execute(Target.java:448)
[javac]   	at org.apache.tools.ant.Target.performTasks(Target.java:469)
[javac]   	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
[javac]   	at org.apache.tools.ant.Project.executeTarget(Project.java:1370)
[javac]   	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[javac]   	at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
[javac]   	at org.apache.tools.ant.Main.runBuild(Main.java:849)
[javac]   	at org.apache.tools.ant.Main.startAnt(Main.java:228)
[javac]   	at org.apache.tools.ant.launch.Launcher.run(Launcher.java:283)
[javac]   	at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)
[javac] 1 error
PhilippWendler added a commit to sosy-lab/java-common-lib that referenced this issue Jun 12, 2018
@tbroyer
Copy link
Contributor

tbroyer commented Jun 12, 2018

Fwiw, this is the commit that removed the method: AdoptOpenJDK/openjdk-jdk@286cfda (afaict, this is a private enum; and Error Prone does not officially support Java 10; see also #860 )

@PhilippWendler
Copy link
Author

I understood #860 such that Java 10 is supported by error-prone if using -Xplugin, which is what I do. Is this correct? (All other checks that I use work fine.)

@tbroyer
Copy link
Contributor

tbroyer commented Jun 12, 2018

Well, I'm the only one who mentioned -Xplugin in #860 😉, and I only said that "it works" (as that's what I experienced so far), not that "it's supported" 🤷‍♂️

@cushon
Copy link
Collaborator

cushon commented Aug 8, 2018

I fixed this in 564dbd3, and the tests are passing on JDK 10.

Using Error Prone on 10 (or 11) with -Xplugin should work now, but I haven't done a lot of validation on 10 or 11.

@cushon cushon closed this as completed Aug 8, 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