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

NullPointerException occurs when passing anonymous class to annotation.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 8u40
    • Fix Version/s: None
    • Component/s: tools
    • Labels:
    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      linux

      Description

      FULL PRODUCT VERSION :
      javac 1.8.0_40


      A DESCRIPTION OF THE PROBLEM :
      I've found weird behavior when I was trying to implement passing logic to annotation by lambda or anonymous class, which was considered on our classes and some people decided that it is impossible in Java.

      Unfortunately/fortunately instead of compilation error I've get what I send you.



      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      An exception has occurred in the compiler (1.8.0_40). Please file a bug at the Java Developer Connection (http://java.sun.com/webapps/bugreport) after checking the Bug Parade for duplicates. Include your program and the following diagnostic in your report. Thank you.
      java.lang.NullPointerException
              at com.sun.tools.javac.comp.Attr.visitNewClass(Attr.java:2139)
              at com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1516)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
              at com.sun.tools.javac.comp.Attr.visitParens(Attr.java:2954)
              at com.sun.tools.javac.tree.JCTree$JCParens.accept(JCTree.java:1661)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
              at com.sun.tools.javac.comp.Attr.visitSelect(Attr.java:3218)
              at com.sun.tools.javac.tree.JCTree$JCFieldAccess.accept(JCTree.java:1897)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
              at com.sun.tools.javac.comp.Attr.visitApply(Attr.java:1806)
              at com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1465)
              at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:566)
              at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:608)
              at com.sun.tools.javac.comp.Annotate.enterAttributeValue(Annotate.java:405)
              at com.sun.tools.javac.comp.Annotate.enterAnnotation(Annotate.java:312)
              at com.sun.tools.javac.comp.Annotate.enterAnnotation(Annotate.java:236)
              at com.sun.tools.javac.comp.MemberEnter.actualEnterAnnotations(MemberEnter.java:923)
              at com.sun.tools.javac.comp.MemberEnter.access$600(MemberEnter.java:64)
              at com.sun.tools.javac.comp.MemberEnter$5.run(MemberEnter.java:876)
              at com.sun.tools.javac.comp.Annotate.flush(Annotate.java:143)
              at com.sun.tools.javac.comp.Annotate.enterDone(Annotate.java:129)
              at com.sun.tools.javac.comp.Enter.complete(Enter.java:512)
              at com.sun.tools.javac.comp.Enter.main(Enter.java:471)
              at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:982)
              at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:857)
              at com.sun.tools.javac.main.Main.compile(Main.java:523)
              at com.sun.tools.javac.main.Main.compile(Main.java:381)
              at com.sun.tools.javac.main.Main.compile(Main.java:370)
              at com.sun.tools.javac.main.Main.compile(Main.java:361)
              at com.sun.tools.javac.Main.compile(Main.java:56)
              at com.sun.tools.javac.Main.main(Main.java:42)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      @interface A{
      Class c() default Object.class;
      }
      @A(c = (new Object(){}).getClass())
      class C{
      }

      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mcimadamore Maurizio Cimadamore
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: