8039317: Read currency.data as a resource
authornaoto
Thu, 26 Jun 2014 10:48:43 -0700
changeset 25174 f861c3fec754
parent 25173 4f093fa54fa1
child 25175 a97b521192b6
8039317: Read currency.data as a resource Reviewed-by: alanb, chegar
jdk/make/GenerateData.gmk
jdk/make/profile-includes.txt
jdk/src/share/classes/java/util/Currency.java
jdk/test/java/util/Currency/CheckDataVersion.java
jdk/test/java/util/Currency/CurrencyTest.java
jdk/test/java/util/Currency/ValidateISO4217.java
--- a/jdk/make/GenerateData.gmk	Thu Jun 26 15:59:57 2014 +0400
+++ b/jdk/make/GenerateData.gmk	Thu Jun 26 10:48:43 2014 -0700
@@ -62,7 +62,7 @@
 
 ##########################################################################################
 
-GENDATA_CURDATA := $(JDK_OUTPUTDIR)/lib/currency.data
+GENDATA_CURDATA := $(JDK_OUTPUTDIR)/classes/java/util/currency.data
 
 $(GENDATA_CURDATA): $(JDK_TOPDIR)/make/data/currency/CurrencyData.properties $(BUILD_TOOLS)
 	$(MKDIR) -p $(@D)
--- a/jdk/make/profile-includes.txt	Thu Jun 26 15:59:57 2014 +0400
+++ b/jdk/make/profile-includes.txt	Thu Jun 26 10:48:43 2014 -0700
@@ -56,7 +56,6 @@
     $(OPENJDK_TARGET_CPU_LEGACY_LIB)/server/Xusage.txt \
     calendars.properties \
     classlist \
-    currency.data \
     ext/localedata.jar \
     ext/meta-index \
     ext/sunec.jar \
--- a/jdk/src/share/classes/java/util/Currency.java	Thu Jun 26 15:59:57 2014 +0400
+++ b/jdk/src/share/classes/java/util/Currency.java	Thu Jun 26 10:48:43 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -212,13 +212,9 @@
         AccessController.doPrivileged(new PrivilegedAction<Void>() {
             @Override
             public Void run() {
-                String homeDir = System.getProperty("java.home");
                 try {
-                    String dataFile = homeDir + File.separator +
-                            "lib" + File.separator + "currency.data";
                     try (DataInputStream dis = new DataInputStream(
-                             new BufferedInputStream(
-                             new FileInputStream(dataFile)))) {
+                             new BufferedInputStream(getClass().getResourceAsStream("/java/util/currency.data")))) {
                         if (dis.readInt() != MAGIC_NUMBER) {
                             throw new InternalError("Currency data is possibly corrupted");
                         }
@@ -248,7 +244,7 @@
                 // look for the properties file for overrides
                 String propsFile = System.getProperty("java.util.currency.data");
                 if (propsFile == null) {
-                    propsFile = homeDir + File.separator + "lib" +
+                    propsFile = System.getProperty("java.home") + File.separator + "lib" +
                         File.separator + "currency.properties";
                 }
                 try {
--- a/jdk/test/java/util/Currency/CheckDataVersion.java	Thu Jun 26 15:59:57 2014 +0400
+++ b/jdk/test/java/util/Currency/CheckDataVersion.java	Thu Jun 26 10:48:43 2014 -0700
@@ -64,7 +64,8 @@
                 public Object run() {
                     try {
                         String sep = File.separator;
-                        DataInputStream dis = new DataInputStream(new FileInputStream(System.getProperty("java.home")+sep+"lib"+sep+"currency.data"));
+                        DataInputStream dis = new DataInputStream(
+                             new BufferedInputStream(getClass().getResourceAsStream("/java/util/currency.data")));
                         int magic = dis.readInt();
                         if (magic != 0x43757244) {
                             throw new RuntimeException("The magic number in the JRE's currency data is incorrect.  Expected: 0x43757244, Got: 0x"+magic);
--- a/jdk/test/java/util/Currency/CurrencyTest.java	Thu Jun 26 15:59:57 2014 +0400
+++ b/jdk/test/java/util/Currency/CurrencyTest.java	Thu Jun 26 10:48:43 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,7 +23,7 @@
 /*
  * @test
  * @bug 4290801 4692419 4693631 5101540 5104960 6296410 6336600 6371531
- *    6488442 7036905
+ *    6488442 7036905 8039317
  * @summary Basic tests for Currency class.
  */
 
--- a/jdk/test/java/util/Currency/ValidateISO4217.java	Thu Jun 26 15:59:57 2014 +0400
+++ b/jdk/test/java/util/Currency/ValidateISO4217.java	Thu Jun 26 10:48:43 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -23,6 +23,7 @@
 /*
  * @test
  * @bug 4691089 4819436 4942982 5104960 6544471 6627549 7066203 7195759
+ *     8039317
  * @summary Validate ISO 4217 data for Currency class.
  */