Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8297602

Compiler crash with type annotation and generic record during pattern matching

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 20
    • 19, 20
    • tools
    • None
    • b27

      Reproduction:

          void meth(Foo<Integer> p) {
              switch(p) {
                  case Foo<@Annot(field = "") Integer>(): {} // crash
              };

              if (p instanceof Foo<@Annot(field = "") Integer>()) { // crash

              }
          }

          @Target({ElementType.TYPE_USE})
          @interface Annot {
              String field();
          }

          record Foo<T>() { }

      StackTrace:

      An exception has occurred in the compiler (20-internal). Please file a bug against the Java compiler via the Java bug reporting page (https://bugreport.java.com) after checking the Bug Database (https://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
      java.lang.AssertionError: Unresolved frame: Foo<@Annot(field = "") Integer>() of kind: DECONSTRUCTION_PATTERN
          Looking for tree: Foo<@Annot(field = "") Integer>
              at jdk.compiler/com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.resolveFrame(TypeAnnotations.java:1092)
              at jdk.compiler/com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.resolveFrame(TypeAnnotations.java:862)
              at jdk.compiler/com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.resolveFrame(TypeAnnotations.java:1029)
              at jdk.compiler/com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.findPosition(TypeAnnotations.java:1440)
              at jdk.compiler/com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitAnnotatedType(TypeAnnotations.java:1331)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCAnnotatedType.accept(JCTree.java:3050)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
              at jdk.compiler/com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:296)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.visitTypeApply(TreeScanner.java:368)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCTypeApply.accept(JCTree.java:2796)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
              at jdk.compiler/com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:296)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.visitRecordPattern(TreeScanner.java:332)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCRecordPattern.accept(JCTree.java:2459)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
              at jdk.compiler/com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:296)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.visitPatternCaseLabel(TreeScanner.java:321)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCPatternCaseLabel.accept(JCTree.java:2371)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
              at jdk.compiler/com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:296)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.visitCase(TreeScanner.java:180)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCase.accept(JCTree.java:1328)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
              at jdk.compiler/com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:296)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.visitSwitch(TreeScanner.java:176)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCSwitch.accept(JCTree.java:1287)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
              at jdk.compiler/com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:296)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
              at jdk.compiler/com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitBlock(TypeAnnotations.java:1324)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1082)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
              at jdk.compiler/com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:296)
              at jdk.compiler/com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitMethodDef(TypeAnnotations.java:1214)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:912)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
              at jdk.compiler/com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:296)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:57)
              at jdk.compiler/com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitClassDef(TypeAnnotations.java:1144)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:810)
              at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.scan(TreeScanner.java:49)
              at jdk.compiler/com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.scan(TypeAnnotations.java:296)
              at jdk.compiler/com.sun.tools.javac.code.TypeAnnotations.organizeTypeAnnotationsBodies(TypeAnnotations.java:156)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:5603)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:5466)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:5290)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attrib(Attr.java:5229)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1318)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:947)
              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)

      Credits to [~mcimadamore]

            abimpoudis Angelos Bimpoudis
            abimpoudis Angelos Bimpoudis
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: