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

HidingField: NoSuchMethodError: 'com.sun.tools.javac.util.List com.sun.tools.javac.code.Symbol$TypeSymbol.getEnclosedElements #2092

Closed
pzygielo opened this issue Jan 12, 2021 · 11 comments
Assignees

Comments

@pzygielo
Copy link
Contributor

pzygielo commented Jan 12, 2021

Description of the problem:

After upgrading errorprone from 2.4.0 to 2.5.0 following is reported in [my project's] maven build (with JDK8, JDK11, JDK12 or JDK13):

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.5.0
     BugPattern: HidingField
     Stack Trace:
     java.lang.NoSuchMethodError: 'com.sun.tools.javac.util.List com.sun.tools.javac.code.Symbol$TypeSymbol.getEnclosedElements()'
  	at com.google.errorprone.bugpatterns.HidingField.matchClass(HidingField.java:73)
  	at com.google.errorprone.scanner.ErrorProneScanner.processMatchers(ErrorProneScanner.java:450)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:548)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:151)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:808)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:113)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitCompilationUnit(TreeScanner.java:144)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:561)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:151)
  	at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:591)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:56)
  	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:58)
  	at com.google.errorprone.scanner.ErrorProneScannerTransformer.apply(ErrorProneScannerTransformer.java:43)
  	at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:152)
  	at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:132)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1418)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1365)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:960)
  	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
  	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:147)
  	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
  	at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
  	at org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java:126)
  	at org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:174)
  	at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1134)
  	at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:187)
  	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
  	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
  	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
  	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
  	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
  	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
  	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
  	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
  	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
  	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
  	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
  	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
  	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
  	at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
  	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
  	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
  	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
  	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
  	at org.apache.maven.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:39)
  	at org.apache.maven.wrapper.WrapperExecutor.execute(WrapperExecutor.java:122)
  	at org.apache.maven.wrapper.MavenWrapperMain.main(MavenWrapperMain.java:61)

The same code works fine with JDK14 and JDK15.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

What version of Error Prone are you using?

2.5.0

Have you found anything relevant by searching the web?

#1529

@cushon
Copy link
Collaborator

cushon commented Jan 12, 2021

This release was built against a newer JDK and picked up this backwards-incompatible change: openjdk/jdk@827e5e3#diff-9b6c5d86aacec00206bfcdbfc12caa41fbb0812426c4f2fd290c3fb1873a532fR840

I can work around that specific example, but if there are a lot more examples of this we should go back to building the release against JDK 8.

Do you mind disabling that particular check with -Xep:HidingField:OFF as an experiment, to see if there are other crashes?

@ZacSweers
Copy link

Our codebase appears to compile with that disabled

@pzygielo
Copy link
Contributor Author

Our codebase appears to compile with that disabled

The same on my side - with -Xep:HidingField:OFF build completes with no other error.

@lgemeinhardt
Copy link
Contributor

This issue looks similar, even if the BugPattern is ComputeIfAbsentAmbiguousReference

[javac]      Please report this at https://github.com/google/error-prone/issues/new and include the following:
[javac]   
[javac]      error-prone version: 2.5.0
[javac]      BugPattern: ComputeIfAbsentAmbiguousReference
[javac]      Stack Trace:
[javac]      java.lang.NoSuchMethodError: com.sun.tools.javac.code.Symbol$ClassSymbol.getEnclosedElements()Lcom/sun/tools/javac/util/List;
[javac]   	at com.google.errorprone.util.ASTHelpers.getConstructors(ASTHelpers.java:958)
[javac]   	at com.google.errorprone.bugpatterns.ComputeIfAbsentAmbiguousReference.matchMethodInvocation(ComputeIfAbsentAmbiguousReference.java:75)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.processMatchers(ErrorProneScanner.java:450)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitMethodInvocation(ErrorProneScanner.java:747)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitMethodInvocation(ErrorProneScanner.java:151)
[javac]   	at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1644)
[javac]   	at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
[javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
[javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
[javac]   	at com.sun.source.util.TreeScanner.visitMemberSelect(TreeScanner.java:680)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitMemberSelect(ErrorProneScanner.java:729)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitMemberSelect(ErrorProneScanner.java:151)
[javac]   	at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2112)
[javac]   	at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
[javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
[javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
[javac]   	at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:90)
[javac]   	at com.sun.source.util.TreeScanner.visitMethodInvocation(TreeScanner.java:508)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitMethodInvocation(ErrorProneScanner.java:752)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitMethodInvocation(ErrorProneScanner.java:151)
[javac]   	at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1644)
[javac]   	at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
[javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
[javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
[javac]   	at com.sun.source.util.TreeScanner.visitExpressionStatement(TreeScanner.java:433)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitExpressionStatement(ErrorProneScanner.java:634)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitExpressionStatement(ErrorProneScanner.java:151)
[javac]   	at com.sun.tools.javac.tree.JCTree$JCExpressionStatement.accept(JCTree.java:1454)
[javac]   	at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
[javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
[javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
[javac]   	at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:90)
[javac]   	at com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
[javac]   	at com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:248)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitBlock(ErrorProneScanner.java:521)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitBlock(ErrorProneScanner.java:151)
[javac]   	at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1026)
[javac]   	at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
[javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
[javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
[javac]   	at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:90)
[javac]   	at com.sun.source.util.TreeScanner.visitEnhancedForLoop(TreeScanner.java:306)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitEnhancedForLoop(ErrorProneScanner.java:621)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitEnhancedForLoop(ErrorProneScanner.java:151)
[javac]   	at com.sun.tools.javac.tree.JCTree$JCEnhancedForLoop.accept(JCTree.java:1166)
[javac]   	at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
[javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
[javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
[javac]   	at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:90)
[javac]   	at com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
[javac]   	at com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:248)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitBlock(ErrorProneScanner.java:521)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitBlock(ErrorProneScanner.java:151)
[javac]   	at com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1026)
[javac]   	at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
[javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
[javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
[javac]   	at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:90)
[javac]   	at com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:206)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:741)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:151)
[javac]   	at com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:898)
[javac]   	at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
[javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
[javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
[javac]   	at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:90)
[javac]   	at com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
[javac]   	at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:113)
[javac]   	at com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:187)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:549)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:151)
[javac]   	at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:808)
[javac]   	at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:82)
[javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
[javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
[javac]   	at com.sun.source.util.TreeScanner.scan(TreeScanner.java:105)
[javac]   	at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:113)
[javac]   	at com.sun.source.util.TreeScanner.visitCompilationUnit(TreeScanner.java:144)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:561)
[javac]   	at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:151)
[javac]   	at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:591)
[javac]   	at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:56)
[javac]   	at com.google.errorprone.scanner.Scanner.scan(Scanner.java:58)
[javac]   	at com.google.errorprone.scanner.ErrorProneScannerTransformer.apply(ErrorProneScannerTransformer.java:43)
[javac]   	at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:152)
[javac]   	at com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:120)
[javac]   	at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1404)
[javac]   	at com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1353)
[javac]   	at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:946)
[javac]   	at com.sun.tools.javac.main.Main.compile(Main.java:302)
[javac]   	at com.sun.tools.javac.main.Main.compile(Main.java:162)
[javac]   	at com.sun.tools.javac.Main.compile(Main.java:57)
[javac]   	at com.sun.tools.javac.Main.main(Main.java:43)
[javac] 1 error

@chanseokoh
Copy link
Member

Same error here. Using JDK 8.

@cushon
Copy link
Collaborator

cushon commented Jan 14, 2021

Thanks for the additional reports. #2092 (comment) looks like a distinct issue with the same root cause.

I'm going to release a 2.5.1 built on JDK 8 that will resolve this issue.

@cushon
Copy link
Collaborator

cushon commented Jan 15, 2021

https://github.com/google/error-prone/releases/tag/v2.5.1

@cushon cushon closed this as completed Jan 15, 2021
@tbroyer
Copy link
Contributor

tbroyer commented Jan 15, 2021

Fwiw, the release notes mention JDK 8, but it's also an issue with JDK 11 (or apparently any version before JDK 15 according to the JDK commit you linked to).

That said, thanks for the fix and the release!

@cushon
Copy link
Collaborator

cushon commented Jan 15, 2021

@tbroyer I updated the relnotes, thanks for the correction!

@msridhar
Copy link
Contributor

msridhar commented May 8, 2023

@cushon FYI I just saw this issue on JDK 11 when trying to update from Error Prone 2.18.0 to Error Prone 2.19.0. Is this unexpected? We can disable the HidingField check for now as a workaround.

DenuxPlays added a commit to jasonlessenich/DIH4JDA that referenced this issue May 9, 2023
DenuxPlays added a commit to jasonlessenich/DIH4JDA that referenced this issue May 9, 2023
* Bump com.google.errorprone:error_prone_core from 2.18.0 to 2.19.0

Bumps [com.google.errorprone:error_prone_core](https://github.com/google/error-prone) from 2.18.0 to 2.19.0.
- [Release notes](https://github.com/google/error-prone/releases)
- [Commits](google/error-prone@v2.18.0...v2.19.0)

---
updated-dependencies:
- dependency-name: com.google.errorprone:error_prone_core
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* applied suggested workaround for compiling with jdk 11

See here: google/error-prone#3895 and
google/error-prone#2092

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: -Denux <83671398+DenuxPlays@users.noreply.github.com>
akunzai added a commit to akunzai/log4j2-sendgrid-appender that referenced this issue May 9, 2023
@cushon
Copy link
Collaborator

cushon commented May 9, 2023

@msridhar thanks, let's track the new occurrence of this in #3895

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

7 participants