< prev index next >

src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/SchemaGenerator.java

Print this page




 165                         LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
 166                     }
 167                 }
 168             }
 169             cl = cl.getParent();
 170         }
 171 
 172         appendPath(cp, findJaxbApiJar());
 173         return cp.toString();
 174     }
 175 
 176     private static void appendPath(StringBuilder cp, String url) {
 177         if (url == null || url.trim().isEmpty())
 178             return;
 179         if (cp.length() != 0)
 180             cp.append(File.pathSeparatorChar);
 181         cp.append(url);
 182     }
 183 
 184     /**
 185      * Computes the file system path of <tt>jaxb-api.jar</tt> so that
 186      * Annotation Processing will see them in the <tt>-cp</tt> option.
 187      *
 188      * <p>
 189      * In Java, you can't do this reliably (for that matter there's no guarantee
 190      * that such a jar file exists, such as in Glassfish), so we do the best we can.
 191      *
 192      * @return
 193      *      null if failed to locate it.
 194      */
 195     private static String findJaxbApiJar() {
 196         String url = Which.which(JAXBContext.class);
 197         if(url==null)       return null;    // impossible, but hey, let's be defensive
 198 
 199         if(!url.startsWith("jar:") || url.lastIndexOf('!')==-1)
 200             // no jar file
 201             return null;
 202 
 203         String jarFileUrl = url.substring(4,url.lastIndexOf('!'));
 204         if(!jarFileUrl.startsWith("file:"))
 205             return null;    // not from file system
 206 




 165                         LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
 166                     }
 167                 }
 168             }
 169             cl = cl.getParent();
 170         }
 171 
 172         appendPath(cp, findJaxbApiJar());
 173         return cp.toString();
 174     }
 175 
 176     private static void appendPath(StringBuilder cp, String url) {
 177         if (url == null || url.trim().isEmpty())
 178             return;
 179         if (cp.length() != 0)
 180             cp.append(File.pathSeparatorChar);
 181         cp.append(url);
 182     }
 183 
 184     /**
 185      * Computes the file system path of {@code jaxb-api.jar} so that
 186      * Annotation Processing will see them in the {@code -cp} option.
 187      *
 188      * <p>
 189      * In Java, you can't do this reliably (for that matter there's no guarantee
 190      * that such a jar file exists, such as in Glassfish), so we do the best we can.
 191      *
 192      * @return
 193      *      null if failed to locate it.
 194      */
 195     private static String findJaxbApiJar() {
 196         String url = Which.which(JAXBContext.class);
 197         if(url==null)       return null;    // impossible, but hey, let's be defensive
 198 
 199         if(!url.startsWith("jar:") || url.lastIndexOf('!')==-1)
 200             // no jar file
 201             return null;
 202 
 203         String jarFileUrl = url.substring(4,url.lastIndexOf('!'));
 204         if(!jarFileUrl.startsWith("file:"))
 205             return null;    // not from file system
 206 


< prev index next >