Locale related utility classes are maintained by the i18n group - right?
--- Begin Message ---
Hi there,

in java.util.Currency, the currency.data is loaded from $JRE_DIR/lib.
I'm having a problem with this in the JamaicaVM, when an application is
built into a single bundle for use on an embedded machine. There is no
JRE installed on that machine, and this file can't be loaded. I suggest
to fall back to loading this file via the ClassLoader. See attached
patch. This should affect normal behaviour, and only adds the option to
put this file in the (boot) classpath instead. What do you think?

/Roman

-- 
Dipl.-Inform. (FH) Roman Kennke, Software Engineer, http://kennke.org
aicas Allerton Interworks Computer Automated Systems GmbH
Haid-und-Neu-Straße 18 * D-76131 Karlsruhe * Germany
http://www.aicas.com   * Tel: +49-721-663 968-0
USt-Id: DE216375633, Handelsregister HRB 109481, AG Karlsruhe
Geschäftsführer: Dr. James J. Hunt
Index: j2se/src/share/classes/java/util/Currency.java
===================================================================
--- j2se/src/share/classes/java/util/Currency.java	(Revision 256)
+++ j2se/src/share/classes/java/util/Currency.java	(Arbeitskopie)
@@ -29,8 +29,10 @@
 import java.io.DataInputStream;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.Serializable;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
@@ -195,9 +197,18 @@
                 try {
 		    String dataFile = homeDir + File.separator + 
 		            "lib" + File.separator + "currency.data";
+		    InputStream in;
+		    try {
+		    	in = new FileInputStream(dataFile);
+		    } catch (FileNotFoundException ex) {
+		    	// Try to load currency.data via ClassLoader.
+		    	in = Currency.class.getResourceAsStream("currency.data");
+		    	if (in == null) {
+		    		throw new InternalError("currency.data not found");
+		    	}
+		    }
 		    DataInputStream dis = new DataInputStream(
-		        new BufferedInputStream(
-			new FileInputStream(dataFile)));
+		        new BufferedInputStream(in));
 		    if (dis.readInt() != MAGIC_NUMBER) {
 		        throw new InternalError("Currency data is possibly corrupted");
 		    }

--- End Message ---

Reply via email to