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

Marker annotation on inner class access crashes javac compiler

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Fedora Linux 42, replicated on Oracle build and Temurin build

      A DESCRIPTION OF THE PROBLEM :
      Annotating an inner class array reference (eg A.B[]) as such: @Marker A.B @Marker[] , followed by an expression method reference (i.e. @Marker A.B @Marker[]::foo) causes the compiler to crash

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Make a file as listed in the test case then attempt to compile it.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Program fails to compile because arrays do not have a method `foo` that accepts an integer.
      ACTUAL -
      An exception has occurred in the compiler (25). 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
              at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:155)
              at jdk.compiler/com.sun.tools.javac.util.Assert.check(Assert.java:46)
              at jdk.compiler/com.sun.tools.javac.code.Type.addMetadata(Type.java:388)
              at jdk.compiler/com.sun.tools.javac.code.Type.preannotatedType(Type.java:468)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.visitAnnotatedType(Attr.java:5256)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCAnnotatedType.accept(JCTree.java:3096)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:677)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.visitReference(Attr.java:3610)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMemberReference.accept(JCTree.java:2657)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:677)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:723)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.visitVarDef(Attr.java:1317)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVariableDecl.accept(JCTree.java:1066)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:677)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:751)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStats(Attr.java:770)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.visitBlock(Attr.java:1463)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1136)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:677)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:751)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.visitMethodDef(Attr.java:1244)
              at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:960)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:677)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribStat(Attr.java:751)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClassBody(Attr.java:5664)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:5550)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:5365)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attrib(Attr.java:5302)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1346)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:968)
              at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:319)
              at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:178)
              at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:66)
              at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:52)

      ---------- BEGIN SOURCE ----------
      public class HelloWorld {

      interface I {
      void foo(int i);
      }

      @interface Marker {
      }
      // crash happens with static or nonstatic classes
      static class X {
      static class Y {
      }
      }

      public static void main(String... args) {
      I i = @Marker X. Y @Marker [][] @Marker []::foo;
      }
      }
      ---------- END SOURCE ----------

            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: