当前位置:  开发笔记 > 编程语言 > 正文

为什么在生成javadoc时会出现ClassCastException?

如何解决《为什么在生成javadoc时会出现ClassCastException?》经验,为你挑选了1个好方法。

我正在使用ant生成javadocs,但一遍又一遍地得到这个例外 - 为什么?

我正在使用JDK版本1.6.0_06.

[javadoc] java.lang.ClassCastException: com.sun.tools.javadoc.ClassDocImpl cannot be cast to com.sun.javadoc.AnnotationTypeDoc
  [javadoc]     at com.sun.tools.javadoc.AnnotationDescImpl.annotationType(AnnotationDescImpl.java:46)
  [javadoc]     at com.sun.tools.doclets.formats.html.HtmlDocletWriter.getAnnotations(HtmlDocletWriter.java:1739)
  [javadoc]     at com.sun.tools.doclets.formats.html.HtmlDocletWriter.writeAnnotationInfo(HtmlDocletWriter.java:1713)
  [javadoc]     at com.sun.tools.doclets.formats.html.HtmlDocletWriter.writeAnnotationInfo(HtmlDocletWriter.java:1702)
  [javadoc]     at com.sun.tools.doclets.formats.html.HtmlDocletWriter.writeAnnotationInfo(HtmlDocletWriter.java:1681)
  [javadoc]     at com.sun.tools.doclets.formats.html.FieldWriterImpl.writeSignature(FieldWriterImpl.java:130)
  [javadoc]     at com.sun.tools.doclets.internal.toolkit.builders.FieldBuilder.buildSignature(FieldBuilder.java:184)
  [javadoc]     at sun.reflect.GeneratedMethodAccessor8.invoke(Unknown Source)
  [javadoc]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  [javadoc]     at java.lang.reflect.Method.invoke(Method.java:597)
  [javadoc]     at com.sun.tools.doclets.internal.toolkit.builders.FieldBuilder.invokeMethod(FieldBuilder.java:114)
  [javadoc]     at com.sun.tools.doclets.internal.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:90)
  [javadoc]     at com.sun.tools.doclets.internal.toolkit.builders.AbstractMemberBuilder.build(AbstractMemberBuilder.java:56)
  [javadoc]     at com.sun.tools.doclets.internal.toolkit.builders.FieldBuilder.buildFieldDoc(FieldBuilder.java:158)
  [javadoc]     at sun.reflect.GeneratedMethodAccessor51.invoke(Unknown Source)
  [javadoc]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  [javadoc]     at java.lang.reflect.Method.invoke(Method.java:597)
  [javadoc]     at com.sun.tools.doclets.internal.toolkit.builders.FieldBuilder.invokeMethod(FieldBuilder.java:114)
  [javadoc]     at com.sun.tools.doclets.internal.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:90)
  [javadoc]     at com.sun.tools.doclets.internal.toolkit.builders.AbstractMemberBuilder.build(AbstractMemberBuilder.java:56)
  [javadoc]     at com.sun.tools.doclets.internal.toolkit.builders.ClassBuilder.buildFieldDetails(ClassBuilder.java:301)
  [javadoc]     at sun.reflect.GeneratedMethodAccessor43.invoke(Unknown Source)
  [javadoc]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  [javadoc]     at java.lang.reflect.Method.invoke(Method.java:597)
  [javadoc]     at com.sun.tools.doclets.internal.toolkit.builders.ClassBuilder.invokeMethod(ClassBuilder.java:101)
  [javadoc]     at com.sun.tools.doclets.internal.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:90)
  [javadoc]     at com.sun.tools.doclets.internal.toolkit.builders.ClassBuilder.buildClassDoc(ClassBuilder.java:124)
  [javadoc]     at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source)
  [javadoc]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  [javadoc]     at java.lang.reflect.Method.invoke(Method.java:597)
  [javadoc]     at com.sun.tools.doclets.internal.toolkit.builders.ClassBuilder.invokeMethod(ClassBuilder.java:101)
  [javadoc]     at com.sun.tools.doclets.internal.toolkit.builders.AbstractBuilder.build(AbstractBuilder.java:90)
  [javadoc]     at com.sun.tools.doclets.internal.toolkit.builders.ClassBuilder.build(ClassBuilder.java:108)
  [javadoc]     at com.sun.tools.doclets.formats.html.HtmlDoclet.generateClassFiles(HtmlDoclet.java:155)
  [javadoc]     at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.generateClassFiles(AbstractDoclet.java:164)
  [javadoc]     at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.startGeneration(AbstractDoclet.java:106)
  [javadoc]     at com.sun.tools.doclets.internal.toolkit.AbstractDoclet.start(AbstractDoclet.java:64)
  [javadoc]     at com.sun.tools.doclets.formats.html.HtmlDoclet.start(HtmlDoclet.java:42)
  [javadoc]     at com.sun.tools.doclets.standard.Standard.start(Standard.java:23)
  [javadoc]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  [javadoc]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  [javadoc]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  [javadoc]     at java.lang.reflect.Method.invoke(Method.java:597)
  [javadoc]     at com.sun.tools.javadoc.DocletInvoker.invoke(DocletInvoker.java:215)
  [javadoc]     at com.sun.tools.javadoc.DocletInvoker.start(DocletInvoker.java:91)
  [javadoc]     at com.sun.tools.javadoc.Start.parseAndExecute(Start.java:340)
  [javadoc]     at com.sun.tools.javadoc.Start.begin(Start.java:128)
  [javadoc]     at com.sun.tools.javadoc.Main.execute(Main.java:41)
  [javadoc]     at com.sun.tools.javadoc.Main.main(Main.java:31)

John Meagher.. 54

看起来这已被报告为Java错误.它似乎是由于使用来自第三方库(如JUnit)的注释而不是在javadoc调用中包含带有该注释的jar引起的.

如果是这种情况,只需在javadoc上使用-classpath选项并包含额外的jar文件.



1> John Meagher..:

看起来这已被报告为Java错误.它似乎是由于使用来自第三方库(如JUnit)的注释而不是在javadoc调用中包含带有该注释的jar引起的.

如果是这种情况,只需在javadoc上使用-classpath选项并包含额外的jar文件.


这对我有用.`locate junit`翻了很多,所以我随机选了一个,把它放在类路径上,那个特殊的异常就消失了.考虑到它的使用范围有多广,我仍然认为javadoc是荒谬可笑的.
对我来说,我必须将Jackson库添加到javadoc类路径中.
推荐阅读
贴进你的心聆听你的世界
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有