langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/Start.java
changeset 37757 f38cc75b6fa0
parent 37750 d213951c811b
child 37759 f0b5daef41b6
equal deleted inserted replaced
37756:87dff934a38a 37757:f38cc75b6fa0
   329         }
   329         }
   330         return !failed;
   330         return !failed;
   331     }
   331     }
   332 
   332 
   333     /**
   333     /**
   334      * Ensures that the module of the given class is readable to this
       
   335      * module.
       
   336      * @param targetClass class in module to be made readable
       
   337      */
       
   338     private void ensureReadable(Class<?> targetClass) {
       
   339         try {
       
   340             Method getModuleMethod = Class.class.getMethod("getModule");
       
   341             Object thisModule = getModuleMethod.invoke(this.getClass());
       
   342             Object targetModule = getModuleMethod.invoke(targetClass);
       
   343 
       
   344             Class<?> moduleClass = getModuleMethod.getReturnType();
       
   345             Method addReadsMethod = moduleClass.getMethod("addReads", moduleClass);
       
   346             addReadsMethod.invoke(thisModule, targetModule);
       
   347         } catch (NoSuchMethodException e) {
       
   348             // ignore
       
   349         } catch (Exception e) {
       
   350             throw new InternalError(e);
       
   351         }
       
   352     }
       
   353 
       
   354     /**
       
   355      * Main program - internal
   334      * Main program - internal
   356      */
   335      */
   357     private boolean parseAndExecute(List<String> argList,
   336     private boolean parseAndExecute(List<String> argList,
   358             Iterable<? extends JavaFileObject> fileObjects) throws IOException {
   337             Iterable<? extends JavaFileObject> fileObjects) throws IOException {
   359         long tm = System.currentTimeMillis();
   338         long tm = System.currentTimeMillis();
   548                     throw new Messager.ExitJavadoc();
   527                     throw new Messager.ExitJavadoc();
   549                 }
   528                 }
   550             }
   529             }
   551             try {
   530             try {
   552                 Class<?> klass = cl.loadClass(userDocletName);
   531                 Class<?> klass = cl.loadClass(userDocletName);
   553                 ensureReadable(klass);
       
   554                 return klass;
   532                 return klass;
   555             } catch (ClassNotFoundException cnfe) {
   533             } catch (ClassNotFoundException cnfe) {
   556                 error("main.doclet_class_not_found", userDocletName);
   534                 error("main.doclet_class_not_found", userDocletName);
   557                 throw new Messager.ExitJavadoc();
   535                 throw new Messager.ExitJavadoc();
   558             }
   536             }
   599             throw new Messager.ExitJavadoc();
   577             throw new Messager.ExitJavadoc();
   600         }
   578         }
   601         for (String tagletName : tagletNames) {
   579         for (String tagletName : tagletNames) {
   602             try {
   580             try {
   603                 Class<?> klass = cl.loadClass(tagletName);
   581                 Class<?> klass = cl.loadClass(tagletName);
   604                 ensureReadable(klass);
       
   605                 if (com.sun.tools.doclets.Taglet.class.isAssignableFrom(klass)) {
   582                 if (com.sun.tools.doclets.Taglet.class.isAssignableFrom(klass)) {
   606                     return true;
   583                     return true;
   607                 }
   584                 }
   608             } catch (ClassNotFoundException cnfe) {
   585             } catch (ClassNotFoundException cnfe) {
   609                 error("main.doclet_class_not_found", tagletName);
   586                 error("main.doclet_class_not_found", tagletName);