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

javac crashes with type annotation on pattern binding declaration

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: repo-amber
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      The following program crashes javac:

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

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

      public class X {

          public static void main(String args[]) {
              Object o = null;
              if (o __matches @TA String x) {
              }
          }
      }

      With the following stack trace:

      at jdk.compiler/com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.resolveFrame(TypeAnnotations.java:1070)
      at jdk.compiler/com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.resolveFrame(TypeAnnotations.java:1007)
      at jdk.compiler/com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.findPosition(TypeAnnotations.java:1416)
      at jdk.compiler/com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitAnnotatedType(TypeAnnotations.java:1289)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCAnnotatedType.accept(JCTree.java:2790)
      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:283)
      at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.visitVariablePattern(TreeScanner.java:303)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariablePattern.accept(JCTree.java:2162)
      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:283)
      at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.visitPatternTest(TreeScanner.java:298)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMatches.accept(JCTree.java:2113)
      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:283)
      at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.visitParens(TreeScanner.java:264)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCParens.accept(JCTree.java:1883)
      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:283)
      at jdk.compiler/com.sun.tools.javac.tree.TreeScanner.visitIf(TreeScanner.java:207)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCIf.accept(JCTree.java:1457)
      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:283)
      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:1282)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1034)
      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:283)
      at jdk.compiler/com.sun.tools.javac.code.TypeAnnotations$TypeAnnotationPositions.visitMethodDef(TypeAnnotations.java:1189)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:880)
      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:283)
      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:1122)
      at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:788)
      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:283)
      at jdk.compiler/com.sun.tools.javac.code.TypeAnnotations.organizeTypeAnnotationsBodies(TypeAnnotations.java:146)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:4914)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4774)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:4703)
      at jdk.compiler/com.sun.tools.javac.comp.Attr.attrib(Attr.java:4648)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1332)
      at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:964)
      at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:305)
      at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:165)
      at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:57)
      at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:43)
      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:564)
      at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            sadayapalam Srikanth Adayapalam
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: