/[classpath]/classpath/java/util/ResourceBundle.java
ViewVC logotype

Diff of /classpath/java/util/ResourceBundle.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.27 by mkoch, Wed Dec 29 11:15:02 2004 UTC revision 1.28 by archie172, Tue Jan 4 17:45:50 2005 UTC
# Line 39  exception statement from your version. * Line 39  exception statement from your version. *
39    
40  package java.util;  package java.util;
41    
42    import gnu.classpath.VMStackWalker;
43  import java.io.IOException;  import java.io.IOException;
44  import java.io.InputStream;  import java.io.InputStream;
45  import java.security.AccessController;  import java.security.AccessController;
# Line 104  public abstract class ResourceBundle Line 105  public abstract class ResourceBundle
105    private Locale locale;    private Locale locale;
106    
107    /**    /**
    * We override SecurityManager in order to access getClassContext().  
    */  
   private static final class Security extends SecurityManager  
   {  
     /**  
      * Avoid accessor method of private constructor.  
      */  
     Security()  
     {  
     }  
   
     /**  
      * Return the ClassLoader of the class which called into this  
      * ResourceBundle, or null if it cannot be determined.  
      */  
     ClassLoader getCallingClassLoader()  
     {  
       Class[] stack = getClassContext();  
       for (int i = 0; i < stack.length; i++)  
        {  
          if (stack[i] != Security.class && stack[i] != ResourceBundle.class)  
            return stack[i].getClassLoader();  
        }  
   
       return null;  
     }  
   }  
   
   /** A security context for grabbing the correct class loader. */  
   private static final Security security  
     = (Security) AccessController.doPrivileged(new PrivilegedAction()  
       {  
         // This will always work since java.util classes have (all) system  
         // permissions.  
         public Object run()  
         {  
           return new Security();  
         }  
       }  
     );  
   
   /**  
108     * The resource bundle cache.     * The resource bundle cache.
109     */     */
110    private static Map bundleCache;    private static Map bundleCache;
# Line 256  public abstract class ResourceBundle Line 215  public abstract class ResourceBundle
215     */     */
216    public static ResourceBundle getBundle(String baseName)    public static ResourceBundle getBundle(String baseName)
217    {    {
218      ClassLoader cl = security.getCallingClassLoader();      ClassLoader cl = VMStackWalker.getCallingClassLoader();
219      if (cl == null)      if (cl == null)
220        cl = ClassLoader.getSystemClassLoader();        cl = ClassLoader.getSystemClassLoader();
221      return getBundle(baseName, Locale.getDefault(), cl);      return getBundle(baseName, Locale.getDefault(), cl);
# Line 276  public abstract class ResourceBundle Line 235  public abstract class ResourceBundle
235     */     */
236    public static ResourceBundle getBundle(String baseName, Locale locale)    public static ResourceBundle getBundle(String baseName, Locale locale)
237    {    {
238      ClassLoader cl = security.getCallingClassLoader();      ClassLoader cl = VMStackWalker.getCallingClassLoader();
239      if (cl == null)      if (cl == null)
240        cl = ClassLoader.getSystemClassLoader();        cl = ClassLoader.getSystemClassLoader();
241      return getBundle(baseName, locale, cl);      return getBundle(baseName, locale, cl);

Legend:
Removed from v.1.27  
changed lines
  Added in v.1.28

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26