/[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.28 by archie172, Tue Jan 4 17:45:50 2005 UTC revision 1.29 by archie172, Tue Jan 4 19:18:30 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    
 import gnu.classpath.VMStackWalker;  
42  import java.io.IOException;  import java.io.IOException;
43  import java.io.InputStream;  import java.io.InputStream;
44  import java.security.AccessController;  import java.security.AccessController;
# Line 105  public abstract class ResourceBundle Line 104  public abstract class ResourceBundle
104    private Locale locale;    private Locale locale;
105    
106    /**    /**
107       * We override SecurityManager in order to access getClassContext().
108       */
109      private static final class Security extends SecurityManager
110      {
111        /**
112         * Avoid accessor method of private constructor.
113         */
114        Security()
115        {
116        }
117    
118        /**
119         * Return the ClassLoader of the class which called into this
120         * ResourceBundle, or null if it cannot be determined.
121         */
122        ClassLoader getCallingClassLoader()
123        {
124          Class[] stack = getClassContext();
125          for (int i = 0; i < stack.length; i++)
126           {
127             if (stack[i] != Security.class && stack[i] != ResourceBundle.class)
128               return stack[i].getClassLoader();
129           }
130    
131          return null;
132        }
133      }
134    
135      /** A security context for grabbing the correct class loader. */
136      private static final Security security
137        = (Security) AccessController.doPrivileged(new PrivilegedAction()
138          {
139            // This will always work since java.util classes have (all) system
140            // permissions.
141            public Object run()
142            {
143              return new Security();
144            }
145          }
146        );
147    
148      /**
149     * The resource bundle cache.     * The resource bundle cache.
150     */     */
151    private static Map bundleCache;    private static Map bundleCache;
# Line 215  public abstract class ResourceBundle Line 256  public abstract class ResourceBundle
256     */     */
257    public static ResourceBundle getBundle(String baseName)    public static ResourceBundle getBundle(String baseName)
258    {    {
259      ClassLoader cl = VMStackWalker.getCallingClassLoader();      ClassLoader cl = security.getCallingClassLoader();
260      if (cl == null)      if (cl == null)
261        cl = ClassLoader.getSystemClassLoader();        cl = ClassLoader.getSystemClassLoader();
262      return getBundle(baseName, Locale.getDefault(), cl);      return getBundle(baseName, Locale.getDefault(), cl);
# Line 235  public abstract class ResourceBundle Line 276  public abstract class ResourceBundle
276     */     */
277    public static ResourceBundle getBundle(String baseName, Locale locale)    public static ResourceBundle getBundle(String baseName, Locale locale)
278    {    {
279      ClassLoader cl = VMStackWalker.getCallingClassLoader();      ClassLoader cl = security.getCallingClassLoader();
280      if (cl == null)      if (cl == null)
281        cl = ClassLoader.getSystemClassLoader();        cl = ClassLoader.getSystemClassLoader();
282      return getBundle(baseName, locale, cl);      return getBundle(baseName, locale, cl);

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

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