jaxp/src/javax/xml/validation/SchemaFactoryFinder.java
changeset 16953 a44e04deb948
parent 15545 a19e13e7c521
child 17264 3aff554ad461
equal deleted inserted replaced
16416:bcebd3fdefc9 16953:a44e04deb948
    52     private static boolean debug = false;
    52     private static boolean debug = false;
    53     /**
    53     /**
    54      *<p> Take care of restrictions imposed by java security model </p>
    54      *<p> Take care of restrictions imposed by java security model </p>
    55      */
    55      */
    56     private static SecuritySupport ss = new SecuritySupport();
    56     private static SecuritySupport ss = new SecuritySupport();
       
    57     private static final String DEFAULT_PACKAGE = "com.sun.org.apache.xerces.internal";
    57     /**
    58     /**
    58      * <p>Cache properties for performance.</p>
    59      * <p>Cache properties for performance.</p>
    59      */
    60      */
    60         private static Properties cacheProps = new Properties();
    61         private static Properties cacheProps = new Properties();
    61 
    62 
   211             if (debug) {
   212             if (debug) {
   212                 ex.printStackTrace();
   213                 ex.printStackTrace();
   213             }
   214             }
   214         }
   215         }
   215 
   216 
   216         /**
       
   217         // try to read from $java.home/lib/jaxp.properties
       
   218         try {
       
   219             String javah = ss.getSystemProperty( "java.home" );
       
   220             String configFile = javah + File.separator +
       
   221             "lib" + File.separator + "jaxp.properties";
       
   222             File f = new File( configFile );
       
   223             if( ss.doesFileExist(f)) {
       
   224                 sf = loadFromProperty(
       
   225                         propertyName,f.getAbsolutePath(), new FileInputStream(f));
       
   226                 if(sf!=null)    return sf;
       
   227             } else {
       
   228                 debugPrintln("Tried to read "+ f.getAbsolutePath()+", but it doesn't exist.");
       
   229             }
       
   230         } catch(Throwable e) {
       
   231             if( debug ) {
       
   232                 debugPrintln("failed to read $java.home/lib/jaxp.properties");
       
   233                 e.printStackTrace();
       
   234             }
       
   235         }
       
   236          */
       
   237 
       
   238         // try META-INF/services files
   217         // try META-INF/services files
   239         Iterator sitr = createServiceFileIterator();
   218         Iterator sitr = createServiceFileIterator();
   240         while(sitr.hasNext()) {
   219         while(sitr.hasNext()) {
   241             URL resource = (URL)sitr.next();
   220             URL resource = (URL)sitr.next();
   242             debugPrintln("looking into " + resource);
   221             debugPrintln("looking into " + resource);
   267      * @param className Name of class to create.
   246      * @param className Name of class to create.
   268      * @return Created class or <code>null</code>.
   247      * @return Created class or <code>null</code>.
   269      */
   248      */
   270     private Class createClass(String className) {
   249     private Class createClass(String className) {
   271             Class clazz;
   250             Class clazz;
   272 
   251         // make sure we have access to restricted packages
   273             // use approprite ClassLoader
   252         boolean internal = false;
       
   253         if (System.getSecurityManager() != null) {
       
   254             if (className != null && className.startsWith(DEFAULT_PACKAGE)) {
       
   255                 internal = true;
       
   256             }
       
   257         }
       
   258 
   274             try {
   259             try {
   275                     if (classLoader != null) {
   260                 if (classLoader != null && !internal) {
   276                             clazz = classLoader.loadClass(className);
   261                         clazz = classLoader.loadClass(className);
   277                     } else {
   262                 } else {
   278                             clazz = Class.forName(className);
   263                         clazz = Class.forName(className);
   279                     }
   264                 }
   280             } catch (Throwable t) {
   265             } catch (Throwable t) {
   281                 if(debug)   t.printStackTrace();
   266                 if(debug)   t.printStackTrace();
   282                     return null;
   267                     return null;
   283             }
   268             }
   284 
   269