private synchronized ResourceBundle findResourceBundle ( String name , boolean useCallersClassLoader ) { // For all lookups, we first check the thread context class loader // if it is set. If not, we use the system classloader. If we // still haven't found it we use the callersClassLoaderRef if it // is set and useCallersClassLoader is true. We set // callersClassLoaderRef initially upon creating the logger with a // non-null resource bundle name. // Return a null bundle for a null name. if ( name == null ) { return null ; } Locale currentLocale = Locale . getDefault ( ) ; // Normally we should hit on our simple one entry cache. if ( catalog != null && currentLocale . equals ( catalogLocale ) && name . equals ( catalogName ) ) { return catalog ; } if ( name . equals ( SYSTEM_LOGGER_RB_NAME ) ) { catalog = findSystemResourceBundle ( currentLocale ) ; catalogName = name ; catalogLocale = currentLocale ; return catalog ; } // Use the thread's context ClassLoader. If there isn't one, use the // {@linkplain java.lang.ClassLoader#getSystemClassLoader() system ClassLoader}. ClassLoader cl = Thread . currentThread ( ) . getContextClassLoader ( ) ; if ( cl == null ) { cl = ClassLoader . getSystemClassLoader ( ) ; } try { catalog = ResourceBundle . getBundle ( name , currentLocale , cl ) ; catalogName = name ; catalogLocale = currentLocale ; return catalog ; } catch ( MissingResourceException ex ) { // We can't find the ResourceBundle in the default // ClassLoader. Drop through. } /* J2ObjC removed: J2ObjC only has one class loader. if (useCallersClassLoader) { // Try with the caller's ClassLoader ClassLoader callersClassLoader = getCallersClassLoader(); if (callersClassLoader != null && callersClassLoader != cl) { try { catalog = ResourceBundle.getBundle(name, currentLocale, callersClassLoader); catalogName = name; catalogLocale = currentLocale; return catalog; } catch (MissingResourceException ex) { } } } // If -Djdk.logging.allowStackWalkSearch=true is set, // does stack walk to search for the resource bundle if (LoggerHelper.allowStackWalkSearch) { return findResourceBundleFromStack(name, currentLocale, cl); } else { return null; } */ return null ; }
Private utility method to map a resource bundle name to an actual resource bundle using a simple one - entry cache . Returns null for a null name . May also return null if we can t find the resource bundle and there is no suitable previous cached value .