I am writing a brand new custom doclet using JDK 1.7. These are the problems I have found so far:
Doc methods isAnnotationType()
, isAnnotationTypeElement()
, isEnum()
and isEnumConstant()
do not work. They always return false.
PackageDoc
method enums()
does not work. It always returns an empty array. Enums
are included in the result of methods allClasses()
and ordinaryClasses()
.
ClassDoc
method enumConstants()
does not work. It always returns an empty array. Enum
constants are included in the result of method fields()
.
PackageDoc
method annotationTypes()
does not work. It always returns an empty array. Annotations
are included in the result of method interfaces()
, so I could implement the following work-around:
AnnotationTypeDoc annotationDoc;
ClassDoc[] interfaces = packageDoc.interfaces();
for (ClassDoc classDoc : interfaces) {
if (classDoc instanceof AnnotationTypeDoc) {
annotationDoc = (AnnotationTypeDoc) classDoc;
} else {
continue;
}
process(annotationDoc);
}
Based on something that I found in the "What's New in Javadoc 5.0" page (http://docs.oracle.com/javase/7/docs/technotes/guides/javadoc/whatsnew-1.5.0.html) I am guessing that, even though I am writing it with JDK 1.7, my doclet is working in some kind of pre-5.0 compatibility mode. This is what I found in the "What's New in Javadoc 5.0" page:
Incompatibilities with Custom Doclets
Custom doclets written prior to 5.0 will have compatibility problems when run on source files that use new language features in 5.0. New Language Features: The Doclet API and standard doclet were revised to handle the new 5.0 language features -- generics, enums, varargs and annotations. To handle these features, custom doclets would also need to be revised. The Javadoc tool tries -- to the extent possible -- to present so-called "legacy" doclets with a view of the program that 1) continues to work with pre-5.0 source code, and 2) matches their expectations for 5.0 source code. So, for example, type parameters and type arguments are stripped from generic constructs, type variables and wildcard types are replaced by their erasures, and ClassDoc.fields() will return enum constants.
Solved! It really was working in pre-5.0 compatibility mode. All I had to do to was to add the following method to my custom doclet:
public static LanguageVersion languageVersion() {
return LanguageVersion.JAVA_1_5;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With