public static boolean start ( RootDoc root ) { List < Object > objs = new ArrayList <> ( ) ; for ( ClassDoc doc : root . specifiedClasses ( ) ) { // TODO: Class.forName() expects a binary name but doc.qualifiedName() // returns a fully qualified name. I do not know a good way to convert // between these two name formats. For now, we simply ignore inner // classes. This limitation can be removed when we figure out a better // way to go from ClassDoc to Class<?>. if ( doc . containingClass ( ) != null ) { continue ; } Class < ? > clazz ; try { @ SuppressWarnings ( "signature" ) // Javadoc source code is not yet annotated @ BinaryName String className = doc . qualifiedName ( ) ; clazz = Class . forName ( className , true , Thread . currentThread ( ) . getContextClassLoader ( ) ) ; } catch ( ClassNotFoundException e ) { e . printStackTrace ( ) ; Options . printClassPath ( ) ; return false ; } if ( needsInstantiation ( clazz ) ) { try { Constructor < ? > c = clazz . getDeclaredConstructor ( ) ; c . setAccessible ( true ) ; objs . add ( c . newInstance ( new Object [ 0 ] ) ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; return false ; } } else { objs . add ( clazz ) ; } } if ( objs . isEmpty ( ) ) { System . out . println ( "Error: no classes found" ) ; return false ; } Object [ ] objarray = objs . toArray ( ) ; Options options = new Options ( objarray ) ; if ( options . getOptions ( ) . size ( ) < 1 ) { System . out . println ( "Error: no @Option-annotated fields found" ) ; return false ; } OptionsDoclet o = new OptionsDoclet ( root , options ) ; o . setOptions ( root . options ( ) ) ; o . processJavadoc ( ) ; try { o . write ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; return false ; } return true ; }
Entry point for the doclet .