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

Crash with annotated nested types #4343

Closed
wmdietl opened this issue Mar 22, 2024 · 0 comments · Fixed by #4345
Closed

Crash with annotated nested types #4343

wmdietl opened this issue Mar 22, 2024 · 0 comments · Fixed by #4345
Assignees

Comments

@wmdietl
Copy link
Contributor

wmdietl commented Mar 22, 2024

Take:

import java.lang.annotation.ElementType;
import java.lang.annotation.Target;

@Target(ElementType.TYPE_USE)
@interface TA {}

class Crash {
  class Nested {
    class DoublyNested {}
  }

  void foo(Crash.@TA Nested.DoublyNested p) {}
}

Running error-prone on this results in a few warnings plus:

Crash.java:12: error: An unhandled exception was thrown by the Error Prone static analysis plugin.
  void foo(Crash.@TA Nested.DoublyNested p) {}
                           ^
     Please report this at https://github.com/google/error-prone/issues/new and include the following:
  
     error-prone version: 2.26.1
     BugPattern: NonCanonicalType
     Stack Trace:
     java.lang.AssertionError: ANNOTATED_TYPE
        at com.google.errorprone.bugpatterns.NonCanonicalType.getNonCanonicalName(NonCanonicalType.java:139)
        at com.google.errorprone.bugpatterns.NonCanonicalType.getNonCanonicalName(NonCanonicalType.java:133)
        at com.google.errorprone.bugpatterns.NonCanonicalType.matchMemberSelect(NonCanonicalType.java:60)
        at com.google.errorprone.scanner.ErrorProneScanner.processMatchers(ErrorProneScanner.java:449)
        at com.google.errorprone.scanner.ErrorProneScanner.visitMemberSelect(ErrorProneScanner.java:726)
        at com.google.errorprone.scanner.ErrorProneScanner.visitMemberSelect(ErrorProneScanner.java:150)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:2138)
        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.scanAndReduce(TreeScanner.java:90)
        at jdk.compiler/com.sun.source.util.TreeScanner.visitVariable(TreeScanner.java:221)
        at com.google.errorprone.scanner.ErrorProneScanner.visitVariable(ErrorProneScanner.java:885)
        at com.google.errorprone.scanner.ErrorProneScanner.visitVariable(ErrorProneScanner.java:150)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:990)
        ...

I didn't find issues with ANNOTATED_TYPE in them. Sorry if this is a duplicate.

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

Successfully merging a pull request may close this issue.

2 participants