changeset 10195:8070aad1c879

8039317: Read currency.data as a resource Reviewed-by: alanb, chegar
author naoto
date Thu, 26 Jun 2014 10:48:43 -0700
parents 0c3f5f579a3b
children 45592d253efe
files make/GenerateData.gmk make/profile-includes.txt src/share/classes/java/util/Currency.java test/java/util/Currency/CheckDataVersion.java test/java/util/Currency/CurrencyTest.java test/java/util/Currency/ValidateISO4217.java
diffstat 6 files changed, 10 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/make/GenerateData.gmk	Thu Jun 26 15:59:57 2014 +0400
+++ b/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/make/profile-includes.txt	Thu Jun 26 15:59:57 2014 +0400
+++ b/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/src/share/classes/java/util/Currency.java	Thu Jun 26 15:59:57 2014 +0400
+++ b/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/test/java/util/Currency/CheckDataVersion.java	Thu Jun 26 15:59:57 2014 +0400
+++ b/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/test/java/util/Currency/CurrencyTest.java	Thu Jun 26 15:59:57 2014 +0400
+++ b/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/test/java/util/Currency/ValidateISO4217.java	Thu Jun 26 15:59:57 2014 +0400
+++ b/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.
  */