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

Nested record causes AssertionError in PrivateConstructorForUtilityClass #2323

Closed
dododge opened this issue May 7, 2021 · 1 comment
Closed

Comments

@dododge
Copy link

dododge commented May 7, 2021

ATTENTION! Please read and follow:

Description of the problem / feature request:

PrivateConstructorForUtilityClass doesn't seem to handle a utility class that has a record inside.

     error-prone version: 2.6.0
     BugPattern: PrivateConstructorForUtilityClass
     Stack Trace:
     java.lang.AssertionError: unknown member type:RECORD
  	at com.google.errorprone.bugpatterns.PrivateConstructorForUtilityClass.isInstance(PrivateConstructorForUtilityClass.java:110)
  	at java.base/java.util.stream.MatchOps$1MatchSink.accept(MatchOps.java:90)
  	at java.base/java.util.Collections$2.tryAdvance(Collections.java:4820)
  	at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129)
  	at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
  	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
  	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
  	at java.base/java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:230)
  	at java.base/java.util.stream.MatchOps$MatchOp.evaluateSequential(MatchOps.java:196)
  	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
  	at java.base/java.util.stream.ReferencePipeline.anyMatch(ReferencePipeline.java:632)
  	at com.google.errorprone.bugpatterns.PrivateConstructorForUtilityClass.matchClass(PrivateConstructorForUtilityClass.java:76)
  	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:832)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:86)
  	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:109)
  	at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:117)
  	at jdk.compiler/com.sun.source.util.TreeScanner.visitCompilationUnit(TreeScanner.java:148)
  	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:603)
  	at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:60)
  	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:1421)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1368)
  	at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:960)
  	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:317)
  	at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:176)
  	at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:64)
  	at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:50)

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

This seems to be enough to trigger the problem:

package example;

public final class ExampleUtilityClass
{
    public record SomeRecord(String value) { }
}

What version of Error Prone are you using?

2.6.0

copybara-service bot pushed a commit that referenced this issue May 12, 2021
Fixes #2324, #2323, #2322

PiperOrigin-RevId: 373431735
copybara-service bot pushed a commit that referenced this issue May 12, 2021
Fixes #2324, #2323, #2322

PiperOrigin-RevId: 373431735
copybara-service bot pushed a commit that referenced this issue May 12, 2021
Fixes #2324, #2323, #2322

PiperOrigin-RevId: 373452319
@cushon
Copy link
Collaborator

cushon commented May 29, 2021

51b5c4d

@cushon cushon closed this as completed May 29, 2021
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

2 participants