< prev index next >

test/java/util/Currency/CheckDataVersion.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2017, 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
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -26,10 +26,12 @@
  * Check the consistency between the regression tests and the currency data in the JRE
  */
 
 import java.io.*;
 import java.lang.reflect.*;
+import java.nio.file.Files;
+import java.nio.file.Paths;
 import java.security.*;
 import java.util.Currency;
 
 class CheckDataVersion {
     static final String datafile = "tablea1.txt";

@@ -61,25 +63,25 @@
                 throw new RuntimeException(ioe);
             }
 
             AccessController.doPrivileged(new PrivilegedAction<Object>() {
                 public Object run() {
-                    try {
-                        InputStream in = Currency.class.getModule().getResourceAsStream("java/util/currency.data");
-                        String sep = File.separator;
-                        DataInputStream dis = new DataInputStream(in);
+                    try (DataInputStream dis = new DataInputStream(
+                            new BufferedInputStream(Files.newInputStream(Paths
+                                    .get(System.getProperty("java.home"),
+                                            "lib", "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);
                         }
                         int fileVerNumber = dis.readInt();
                         int dataVerNumber = dis.readInt();
                         if (Integer.parseInt(fileVersion) != fileVerNumber ||
                             Integer.parseInt(dataVersion) != dataVerNumber) {
                             throw new RuntimeException("Test data and JRE's currency data are inconsistent.  test: (file: "+fileVersion+" data: "+dataVersion+"), JRE: (file: "+fileVerNumber+" data: "+dataVerNumber+")");
                         }
-System.out.println("test: (file: "+fileVersion+" data: "+dataVersion+"), JRE: (file: "+fileVerNumber+" data: "+dataVerNumber+")");
+                        System.out.println("test: (file: "+fileVersion+" data: "+dataVersion+"), JRE: (file: "+fileVerNumber+" data: "+dataVerNumber+")");
                     } catch (IOException ioe) {
                         throw new RuntimeException(ioe);
                     }
                     return null;
                 }
< prev index next >