java.lang.reflect.Method getCCL = Thread.class.getMethod("getContextClassLoader", NO_CLASSES); if (getCCL != null) { ClassLoader contextClassLoader = (ClassLoader) getCCL.invoke(Thread.currentThread(), NO_OBJS); is = contextClassLoader.getResourceAsStream("org/apache/xalan/templates/" + resourceName); }
try {         accessControllerClass=Class.forName("java.security.AccessController");      is =(InputStream)java.security.AccessController.doPrivileged ( new java.security.PrivilegedAction() {  public Object run() { try { java.lang.reflect.Method getCCL = Thread.class.getMethod( "getContextClassLoader", NO_CLASSES); if (getCCL != null) { ClassLoader contextClassLoader = (ClassLoader) getCCL.invoke(Thread.currentThread(), NO_OBJS); return ( contextClassLoader.getResourceAsStream ( "org/apache/xalan/templates/" + resourceName) ); } } catch ( Exception e ) { }  return null;  } }); } catch ( ClassNotFoundException e ) {   try { java.lang.reflect.Method getCCL = Thread.class.getMethod( "getContextClassLoader", NO_CLASSES); if (getCCL != null) { ClassLoader contextClassLoader = (ClassLoader) getCCL.invoke(Thread.currentThread(), NO_OBJS); is = contextClassLoader.getResourceAsStream ( "org/apache/xalan/templates/" + resourceName ); } } catch ( Exception exception ) { } }
  static private Properties loadPropertiesFile(String resourceName, Properties defaults)    throws IOException  {    // This static method should eventually be moved to a thread-specific class    // so that we can cache the ContextClassLoader and bottleneck all properties file    // loading throughout Xalan.    Properties props = new Properties(defaults);    InputStream is = null;    BufferedInputStream bis = null;    try {      try {        java.lang.reflect.Method getCCL = Thread.class.getMethod("getContextClassLoader", NO_CLASSES);        if (getCCL != null) {          ClassLoader contextClassLoader = (ClassLoader) getCCL.invoke(Thread.currentThread(), NO_OBJS);          is = contextClassLoader.getResourceAsStream("org/apache/xalan/templates/" + resourceName);        }      }      catch (Exception e) {}      if ( is == null ) {        is = OutputProperties.class.getResourceAsStream(resourceName);      }            bis = new BufferedInputStream(is);      props.load(bis);    }     catch (IOException ioe) {      if ( defaults == null ) {        throw ioe;      }      else {        throw new WrappedRuntimeException(XSLMessages.createMessage(XSLTErrorResources.ER_COULD_NOT_LOAD_RESOURCE, new Object[]{resourceName}), ioe); //"Could not load '"+resourceName+"' (check CLASSPATH), now using just the defaults ", ioe);      }    }    catch (SecurityException se) {      // Repeat IOException handling for sandbox/applet case -sc      if ( defaults == null ) {        throw se;      }      else {        throw new WrappedRuntimeException(XSLMessages.createMessage(XSLTErrorResources.ER_COULD_NOT_LOAD_RESOURCE, new Object[]{resourceName}), se); //"Could not load '"+resourceName+"' (check CLASSPATH, applet security), now using just the defaults ", se);      }    }     finally {      if ( bis != null ) {        bis.close();      }      if (is != null ) {        is.close();      }    }        // Note that we're working at the HashTable level here,     // and not at the Properties level!  This is important     // because we don't want to modify the default properties.    // NB: If fixupPropertyString ends up changing the property    // name or value, we need to remove the old key and re-add    // with the new key and value.  However, then our Enumeration    // could lose its place in the HashTable.  So, we first    // clone the HashTable and enumerate over that since the    // clone will not change.  When we migrate to Collections,    // this code should be revisited and cleaned up to use    // an Iterator which may (or may not) alleviate the need for    // the clone.  Many thanks to Padraig O'hIceadha    // <padraig@gradient.ie> for finding this problem.  Bugzilla 2000.    Enumeration keys = ((Properties) props.clone()).keys();    while(keys.hasMoreElements())    {      String key = (String)keys.nextElement();      // Now check if the given key was specified as a       // System property. If so, the system property       // overides the default value in the propery file.      String value = null;      try {        value = System.getProperty(key);      }      catch (SecurityException se) {        // No-op for sandbox/applet case, leave null -sc      }      if (value == null)              value = (String)props.get(key);                                   String newKey = fixupPropertyString(key, true);      String newValue = null;      try {        newValue = System.getProperty(newKey);      }      catch (SecurityException se) {        // No-op for sandbox/applet case, leave null -sc      }      if (newValue == null)        newValue = fixupPropertyString(value, false);      else        newValue = fixupPropertyString(newValue, false);             if(key != newKey || value != newValue)      {        props.remove(key);        props.put(newKey, newValue);      }          }        return props;  }