Patch for finding and reading property files
Anthony Green
green@cygnus.com
Sat Oct 16 20:11:00 GMT 1999
Once this patch is applied, ResourceBundle.getBundle will create and
return a PropertyResourceBundle if the appropriate properties file is
found on the java.class.path.
1999-10-16 Anthony Green <green@cygnus.com>
* java/lang/ClassLoader.java (getSystemResource): Use
getSystemClassLoader instead of ClassLoader.system.
(getSystemResourceAsStream): Ditto.
* java/lang/natClassLoader.cc (redirect): Make static and
remove #ifdef INTERPRETER so it is always defined.
(getVMClassLoader0): Remove #ifdef INTERPRETER so it always
returns a VMClassLoader.
* java/util/ResourceBundle.java (trySomeGetBundle): Create a
PropertyResourceBundle if a properties file is found before a
ResourceBundle class.
Index: libjava/java/lang/ClassLoader.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/lang/ClassLoader.java,v
retrieving revision 1.4
diff -u -r1.4 ClassLoader.java
--- ClassLoader.java 1999/08/18 14:16:41 1.4
+++ ClassLoader.java 1999/10/17 02:56:46
@@ -360,11 +360,11 @@
protected native Class findLoadedClass(String name);
public static final InputStream getSystemResourceAsStream(String name) {
- return system.getResourceAsStream (name);
+ return getSystemClassLoader().getResourceAsStream (name);
}
public static final URL getSystemResource(String name) {
- return system.getResource (name);
+ return getSystemClassLoader().getResource (name);
}
/**
Index: libjava/java/lang/natClassLoader.cc
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/lang/natClassLoader.cc,v
retrieving revision 1.9
diff -u -r1.9 natClassLoader.cc
--- natClassLoader.cc 1999/09/10 22:03:08 1.9
+++ natClassLoader.cc 1999/10/17 02:56:47
@@ -48,20 +48,14 @@
/////////// java.lang.ClassLoader native methods ////////////
-#ifdef INTERPRETER
-gnu::gcj::runtime::VMClassLoader *redirect = 0;
-#endif
+static gnu::gcj::runtime::VMClassLoader *redirect = 0;
java::lang::ClassLoader*
java::lang::ClassLoader::getVMClassLoader0 ()
{
-#ifdef INTERPRETER
- if (redirect == 0)
- redirect = new gnu::gcj::runtime::VMClassLoader;
- return redirect;
-#else
- return 0;
-#endif
+ if (redirect == 0)
+ redirect = new gnu::gcj::runtime::VMClassLoader;
+ return redirect;
}
void
Index: libjava/java/util/ResourceBundle.java
===================================================================
RCS file: /cvs/java/libgcj/libjava/java/util/ResourceBundle.java,v
retrieving revision 1.4
diff -u -r1.4 ResourceBundle.java
--- ResourceBundle.java 1999/05/24 15:00:02 1.4
+++ ResourceBundle.java 1999/10/17 02:56:47
@@ -8,6 +8,8 @@
package java.util;
+import java.io.InputStream;
+
/**
* @author Anthony Green <green@cygnus.com>
* @date November 26, 1998.
@@ -105,6 +107,23 @@
{
// Fall through.
}
+
+ // Look for a properties file.
+ {
+ InputStream i =
+ ClassLoader.getSystemResourceAsStream (bundleName.replace ('.', '/')
+ + ".properties");
+ if (i != null)
+ {
+ try {
+ return new PropertyResourceBundle (i);
+ } catch (java.io.IOException e) {
+ // The docs don't appear to define what happens in
+ // this case, but it seems like continuing the
+ // search is a reasonable thing to do.
+ }
+ }
+ }
if (bundleName.equals(stopHere))
return result;
--
Anthony Green Cygnus Solutions
Sunnyvale, California
More information about the Java-patches
mailing list