FULL PRODUCT VERSION :
java version "1.7.0_45"
OpenJDK Runtime Environment (fedora-2.4.3.0.fc19-x86_64 u45-b15)
ADDITIONAL OS VERSION INFORMATION :
Fedora release 19 (Schr??dinger???s Cat)
3.9.9-0cse.0 #1 SMP Tue Jul 9 14:16:52 PDT 2013 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
Compiler throws a NullPointerException when passing in a new object that has a body:
@interface MyAnno {
String value();
}
@MyAnno(new Object(){})
class MyClass { }
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Attempt to compile the provided source.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would expect a normal compiler error message such as:
NPE.java:6: error: attribute value must be constant
@MyAnno(new String(""))
^
1 error
ACTUAL -
An exception has occurred in the compiler (1.7.0_45). 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:1802)
at com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1372)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:431)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:418)
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:449)
at com.sun.tools.javac.comp.Annotate.enterAttributeValue(Annotate.java:203)
at com.sun.tools.javac.comp.Annotate.enterAnnotation(Annotate.java:181)
at com.sun.tools.javac.comp.MemberEnter.enterAnnotations(MemberEnter.java:783)
at com.sun.tools.javac.comp.MemberEnter.access$300(MemberEnter.java:57)
at com.sun.tools.javac.comp.MemberEnter$5.enterAnnotation(MemberEnter.java:751)
at com.sun.tools.javac.comp.Annotate.flush(Annotate.java:109)
at com.sun.tools.javac.comp.Annotate.enterDone(Annotate.java:101)
at com.sun.tools.javac.comp.Enter.complete(Enter.java:510)
at com.sun.tools.javac.comp.Enter.main(Enter.java:469)
at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:929)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824)
at com.sun.tools.javac.main.Main.compile(Main.java:439)
at com.sun.tools.javac.main.Main.compile(Main.java:353)
at com.sun.tools.javac.main.Main.compile(Main.java:342)
at com.sun.tools.javac.main.Main.compile(Main.java:333)
at com.sun.tools.javac.Main.compile(Main.java:76)
at com.sun.tools.javac.Main.main(Main.java:61)
ERROR MESSAGES/STACK TRACES THAT OCCUR :
An exception has occurred in the compiler (1.7.0_45). 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:1802)
at com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1372)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:431)
at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:418)
at com.sun.tools.javac.comp.Attr.attribExpr(Attr.java:449)
at com.sun.tools.javac.comp.Annotate.enterAttributeValue(Annotate.java:203)
at com.sun.tools.javac.comp.Annotate.enterAnnotation(Annotate.java:181)
at com.sun.tools.javac.comp.MemberEnter.enterAnnotations(MemberEnter.java:783)
at com.sun.tools.javac.comp.MemberEnter.access$300(MemberEnter.java:57)
at com.sun.tools.javac.comp.MemberEnter$5.enterAnnotation(MemberEnter.java:751)
at com.sun.tools.javac.comp.Annotate.flush(Annotate.java:109)
at com.sun.tools.javac.comp.Annotate.enterDone(Annotate.java:101)
at com.sun.tools.javac.comp.Enter.complete(Enter.java:510)
at com.sun.tools.javac.comp.Enter.main(Enter.java:469)
at com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:929)
at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:824)
at com.sun.tools.javac.main.Main.compile(Main.java:439)
at com.sun.tools.javac.main.Main.compile(Main.java:353)
at com.sun.tools.javac.main.Main.compile(Main.java:342)
at com.sun.tools.javac.main.Main.compile(Main.java:333)
at com.sun.tools.javac.Main.compile(Main.java:76)
at com.sun.tools.javac.Main.main(Main.java:61)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
@interface MyAnno {
String value();
}
@MyAnno(new Object(){ })
class MyClass { }
---------- END SOURCE ----------