JDK-6214965 : crash: java.lang.AssertionError at com.sun.tools.javac.jvm.ClassReader$AnnotationDeproxy.findAccessM
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-01-07
  • Updated: 2010-04-02
  • Resolved: 2006-01-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b67Fixed
Related Reports
Relates :  
Relates :  
Description
FULL PRODUCT VERSION :
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode)


ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
When using nested annotation types, after changing the name of one of the parameters in an annotation type an assertion error fails in the compiler. See the source.

This bug is probably related to 5065421.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile the two java files in the test case. Then in CompilerAnnotationTest2 change parameter name2 to name3. Then recompile, keeping the old class files in tact. Not changing CompilerAnnotationTest

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Compiler gives a compiler error.
ACTUAL -
Compiler crashes.

ERROR MESSAGES/STACK TRACES THAT OCCUR :
C:\>javac CompilerAnnotationTest2.java
An exception has occurred in the compiler (1.5.0). Please file a bug at the Java
 Developer Connection (http://java.sun.com/webapps/bugreport)  after checking th
e Bug Parade for duplicates. Include your program and the following diagnostic i
n your report.  Thank you.
java.lang.AssertionError: cannot find method CompilerAnnotationTest2.name2()
        at com.sun.tools.javac.jvm.ClassReader$AnnotationDeproxy.findAccessMetho
d(ClassReader.java:1074)
        at com.sun.tools.javac.jvm.ClassReader$AnnotationDeproxy.deproxyCompound
(ClassReader.java:1057)
        at com.sun.tools.javac.jvm.ClassReader$AnnotationDeproxy.visitCompoundAn
notationProxy(ClassReader.java:1151)
        at com.sun.tools.javac.jvm.ClassReader$CompoundAnnotationProxy.accept(Cl
assReader.java:1019)
        at com.sun.tools.javac.jvm.ClassReader$AnnotationDeproxy.deproxy(ClassRe
ader.java:1084)
        at com.sun.tools.javac.jvm.ClassReader$AnnotationDeproxy.visitArrayAttri
buteProxy(ClassReader.java:1145)
        at com.sun.tools.javac.jvm.ClassReader$ArrayAttributeProxy.accept(ClassR
eader.java:1004)
        at com.sun.tools.javac.jvm.ClassReader$AnnotationDeproxy.deproxy(ClassRe
ader.java:1084)
        at com.sun.tools.javac.jvm.ClassReader$AnnotationDeproxy.deproxyCompound
(ClassReader.java:1058)
        at com.sun.tools.javac.jvm.ClassReader$AnnotationDeproxy.deproxyCompound
List(ClassReader.java:1046)
        at com.sun.tools.javac.jvm.ClassReader$AnnotationCompleter.enterAnnotati
on(ClassReader.java:1195)
        at com.sun.tools.javac.comp.Annotate.flush(Annotate.java:94)
        at com.sun.tools.javac.comp.Annotate.enterDone(Annotate.java:86)
        at com.sun.tools.javac.comp.Enter.complete(Enter.java:473)
        at com.sun.tools.javac.comp.Enter.main(Enter.java:426)
        at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:382)
        at com.sun.tools.javac.main.Main.compile(Main.java:592)
        at com.sun.tools.javac.main.Main.compile(Main.java:544)
        at com.sun.tools.javac.Main.compile(Main.java:58)
        at com.sun.tools.javac.Main.main(Main.java:48)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
//CompilerAnnotationTest.java
@CompilerAnnotationTest(@CompilerAnnotationTest2(name="test",name2="test2"))
public @interface CompilerAnnotationTest
{
   CompilerAnnotationTest2[] value();
}

//CompilerAnnotationTest2.java
@CompilerAnnotationTest(@CompilerAnnotationTest2(name="test"))
@interface CompilerAnnotationTest2
{
   String name();
   String name2() default "test"; //compile and change this to name3, then recompile
}
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
remove old class files, or recompile all sources together
###@###.### 2005-1-07 00:21:06 GMT

Comments
SUGGESTED FIX http://sa.sfbay.sun.com/projects/langtools_data/mustang/6214965/
26-01-2006

SUGGESTED FIX Index: src/share/classes/com/sun/tools/javac/jvm/ClassReader.java ================================================================= @@ -1071,8 +1071,9 @@ } // we will need better error recovery than this. // we should fail soft, allowing some binary compatibility - throw new AssertionError("cannot find method " + - container + "." + name + "()"); + log.error(Position.NOPOS, "method.not.found", + currentClassFileName, container, name); + return null; } Index: src/share/classes/com/sun/tools/javac/resources/compiler.properties ========================================================================== @@ -366,6 +366,8 @@ unclosed string literal compiler.err.unknown.enum.constant=\ in class file {0}: unknown enum constant {1}.{2} +compiler.err.method.not.found=\ + in class file {0}: method not found {1}.{2}() compiler.err.unsupported.encoding=\ unsupported encoding: {0} compiler.err.io.exception=\ ###@###.### 2005-1-25 03:14:04 GMT
25-01-2005

EVALUATION We should replace the assertion with a diagnostic. We intend to fix this in mustang. We see no reason to backport this fix to JDK 5.0. ###@###.### 2005-1-25 03:14:04 GMT
25-01-2005

WORK AROUND Don't change your sources like suggested by the submitter :-) ###@###.### 2005-1-25 03:14:04 GMT
25-01-2005