Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6442982
Votes 59
Synopsis Javadoc crashes with ClasscastException when processing annotations
Category java:javadoctool
Reported Against
Release Fixed
State 5-Cause Known, bug
Priority: 4-Low
Related Bugs
Submit Date 23-JUN-2006
Description
FULL PRODUCT VERSION :
java version "1.5.0_07"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_07-b03)
Java HotSpot(TM) Client VM (build 1.5.0_07-b03, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
 customer  Windows 2000 [Versione 5.00.2195]

A DESCRIPTION OF THE PROBLEM :
javadoc exists with a classcastexception when trying to process annotations.

The stack trace is:

java.lang.ClassCastException: com.sun.tools.javadoc.ClassDocImpl
        at com.sun.tools.javadoc.AnnotationDescImpl.annotationType(AnnotationDescImpl.java:46)
        at com.sun.tools.doclets.internal.toolkit.util.Util.isDeprecated(Util.java:804)
        at com.sun.tools.doclets.formats.html.TagletWriterImpl.deprecatedTagOutput(TagletWriterImpl.java:70)
        at com.sun.tools.doclets.internal.toolkit.taglets.DeprecatedTaglet.getTagletOutput(DeprecatedTaglet.java:40)
        at com.sun.tools.doclets.formats.html.HtmlSerialFieldWriter.writeMemberDeprecatedInfo(HtmlSerialFieldWriter.java
:96)
        at com.sun.tools.doclets.internal.toolkit.builders.SerializedFormBuilder.buildFieldInfo(SerializedFormBuilder.ja
va:444)
        at sun.reflect.GeneratedMethodAccessor140.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at com.sun.tools.doclets.internal.toolkit.builders.SerializedFormBuilder.invokeMethod(SerializedFormBuilder.java
:131)
        at com.sun.tools.doclets.internal.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:90)
        at com.sun.tools.doclets.internal.toolkit.builders.SerializedFormBuilder.buildSerializableFields(SerializedFormB
uilder.java:482)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at com.sun.tools.doclets.internal.toolkit.builders.SerializedFormBuilder.invokeMethod(SerializedFormBuilder.java
:131)
        at com.sun.tools.doclets.internal.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:90)
        at com.sun.tools.doclets.internal.toolkit.builders.SerializedFormBuilder.buildClassSerializedForm(SerializedForm
Builder.java:185)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at com.sun.tools.doclets.internal.toolkit.builders.SerializedFormBuilder.invokeMethod(SerializedFormBuilder.java
:131)
        at com.sun.tools.doclets.internal.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:90)
        at com.sun.tools.doclets.internal.toolkit.builders.SerializedFormBuilder.buildPackageSerializedForm(SerializedFo
rmBuilder.java:167)
        at sun.reflect.GeneratedMethodAccessor138.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at com.sun.tools.doclets.internal.toolkit.builders.SerializedFormBuilder.invokeMethod(SerializedFormBuilder.java
:131)
        at com.sun.tools.doclets.internal.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:90)
        at com.sun.tools.doclets.internal.toolkit.builders.SerializedFormBuilder.buildSerializedFormSummaries(Serialized
FormBuilder.java:148)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at com.sun.tools.doclets.internal.toolkit.builders.SerializedFormBuilder.invokeMethod(SerializedFormBuilder.java
:131)
        at com.sun.tools.doclets.internal.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:90)
        at com.sun.tools.doclets.internal.toolkit.builders.SerializedFormBuilder.buildSerializedForm(SerializedFormBuild
er.java:116)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at com.sun.tools.doclets.internal.toolkit.builders.SerializedFormBuilder.invokeMethod(SerializedFormBuilder.java
:131)
        at com.sun.tools.doclets.internal.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:90)
        at com.sun.tools.doclets.internal.toolkit.builders.SerializedFormBuilder.build(SerializedFormBuilder.java:101)
        at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.generateOtherFiles(AbstractDoclet.java:137)
        at com.sun.tools.doclets.formats.html.HtmlDoclet.generateOtherFiles(HtmlDoclet.java:66)
        at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.startGeneration(AbstractDoclet.java:122)
        at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.start(AbstractDoclet.java:64)
        at com.sun.tools.doclets.formats.html.HtmlDoclet.start(HtmlDoclet.java:42)
        at com.sun.tools.doclets.standard.Standard.start(Standard.java:23)
        at gr.spinellis.umlgraph.doclet.UmlDoc.start(UmlDoc.java:48)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at com.sun.tools.javadoc.DocletInvoker.invoke(DocletInvoker.java:269)
        at com.sun.tools.javadoc.DocletInvoker.start(DocletInvoker.java:143)
        at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:340)
        at com.sun.tools.javadoc.Start.begin(Start.java:128)
        at com.sun.tools.javadoc.Main.execute(Main.java:41)
        at com.sun.tools.javadoc.Main.main(Main.java:31)


The bug is triggered by two tools I know of, maven and annogen, when runnig the standard doclet (so, not from command line, but from an external application that calls  com.sun.tools.javadoc.Main.
Unfortunately I don't have a test case for it, but you can refer to the associated bug reports on the maven and annogen issue trackers:

http://jira.codehaus.org/browse/ANNOGEN-14
http://jira.codehaus.org/browse/MJAVADOC-72


REPRODUCIBILITY :
This bug can be reproduced always.
Posted Date : 2006-06-23 22:59:22.0
Work Around
N/A
Evaluation
The Annogen bug report says:
  There seems to be a bug in 1.5 javadoc that comes up when trying to get 
  annotations of types that are not correctly imported in the source file.

When an annotation's type is erroneous, DocEnv.getClassDoc may return
a ClassDocImpl to AnnotationDescImpl.annotationType.  Perhaps it should
return an AnnotationTypeDocImpl instead.  Or else 
AnnotationDescImpl.annotationType must be smarter about checking for
error conditions.
Posted Date : 2006-06-24 00:51:40.0
Comments
  
  Include a link with my name & email   

Submitted On 16-NOV-2007
Also observed using:
java version "1.5.0_11"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_11-b03)
Java HotSpot(TM) Client VM (build 1.5.0_11-b03, mixed mode, sharing)


Submitted On 25-MAR-2008
lsauvage
This bug has no workaround and javadoc is often generated from ant (it does reproduce this bug). I don't understand why this bug has so low priority.


Submitted On 27-MAR-2008
varkhan
Also observed on using jdk1.6.0_02, on Fedora Core 6.
I have not found  a workaround, and it crashes javadoc before it can output the main class listing files, which severely impairs navigation in the resulting documentation. In my view it simply makes javadoc unusable on any project that contains externally defined annotations. This bug priority should be high or severe.


Submitted On 10-APR-2008
KarenC
Any method annotated with @WebMethod (which is not a javadoc tag) causes standard doclet to crash and not generate index-all.html, using standard doclet 1.5.0_07


Submitted On 25-APR-2008
Also observed on the command line - does not have to be from ant or maven. Also, javadoc crashes even with javax annotations like:
javax.jws.WebService
javax.xml.bind.annotation.XmlAttribute

This bug doesn't allow us to create ANY javadocs if the java file has any annotations not already defined up to java1.4. 


Submitted On 29-APR-2008
I had the same problem. The workaround that I found is to include the jars that have the java annotation class using -classpath. In my case, it was @Test from junit


Submitted On 21-MAY-2008
I was able to get around this issue with a workaround as described in this article:

http://www.theresearchkitchen.com/blog/archives/35

which is to include the jars with the class files (for the source code that you trying to generate javadocs for) in the classpath when invoking javadoc. That worked very nicely for me.

-Pritpal-





Submitted On 30-APR-2009
projectiris
I took the source and changed AnnotationDescImpl.annotationType to return a AnnotationTypeDocImpl when the returned ClassDocImpl didn't implement the appropriate interface. This stopped the exception, but the output was corrupted. Despite annotations being annotations implicitly, it seems if the .class file for the annotation isn't available, the class's flags are not read and later the structure is interpreted as a non-annotation class in some places in the code, causing the bug. Please fix this.


Submitted On 18-JUN-2009
Mary_at_Palantir
Please fix this bug! It is incredibly annoying when building large projects. We have to write special ant code to bring in all the dependencies. And, it makes small scale, local testing of Javadoc virtually impossible.


Submitted On 08-JAN-2010
kasthurirengan
I have some idea regarding this problem but this not exact soultion to get javadoc.

If you give single comment line "\\" before annotation and try to run the javadoc once again. This problem will solve

Eg: sample.java File
   
@ChannelPipeline

Makes changes in

//@ChannelPipeline

Try to run javadoc command once again


Submitted On 05-FEB-2010
JasonMOT
I echo the same sentiments as others here:  Why is this bug so low priority?  Please fix this bug.



PLEASE NOTE: JDK6 is formerly known as Project Mustang