|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2007, 2025, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * This code is free software; you can redistribute it and/or modify it
|
|
33 | 33 | import java.io.FileReader;
|
34 | 34 | import java.io.IOException;
|
35 | 35 | import java.io.InputStream;
|
36 |
| -import java.security.AccessController; |
37 |
| -import java.security.PrivilegedAction; |
38 | 36 | import java.util.Currency;
|
39 | 37 |
|
40 | 38 | class CheckDataVersion {
|
@@ -63,33 +61,23 @@ static void check() {
|
63 | 61 | break;
|
64 | 62 | }
|
65 | 63 | }
|
| 64 | + InputStream JREdata = Currency.class.getModule().getResourceAsStream("java/util/currency.data"); |
| 65 | + DataInputStream dis = new DataInputStream(JREdata); |
| 66 | + int magic = dis.readInt(); |
| 67 | + if (magic != 0x43757244) { |
| 68 | + throw new RuntimeException("The magic number in the JRE's currency data is incorrect. Expected: 0x43757244, Got: 0x"+magic); |
| 69 | + } |
| 70 | + int fileVerNumber = dis.readInt(); |
| 71 | + int dataVerNumber = dis.readInt(); |
| 72 | + if (Integer.parseInt(fileVersion) != fileVerNumber || |
| 73 | + Integer.parseInt(dataVersion) != dataVerNumber) { |
| 74 | + throw new RuntimeException("Test data and JRE's currency data are inconsistent. test: (file: "+fileVersion+" data: "+dataVersion+"), JRE: (file: "+fileVerNumber+" data: "+dataVerNumber+")"); |
| 75 | + } |
| 76 | + System.out.println("test: (file: "+fileVersion+" data: "+dataVersion+"), JRE: (file: "+fileVerNumber+" data: "+dataVerNumber+")"); |
66 | 77 | } catch (IOException ioe) {
|
67 |
| - throw new RuntimeException(ioe); |
| 78 | + throw new RuntimeException( |
| 79 | + "currency.data was not retrieved properly", ioe); |
68 | 80 | }
|
69 |
| - |
70 |
| - AccessController.doPrivileged(new PrivilegedAction<Object>() { |
71 |
| - public Object run() { |
72 |
| - try { |
73 |
| - InputStream in = Currency.class.getModule().getResourceAsStream("java/util/currency.data"); |
74 |
| - String sep = File.separator; |
75 |
| - DataInputStream dis = new DataInputStream(in); |
76 |
| - int magic = dis.readInt(); |
77 |
| - if (magic != 0x43757244) { |
78 |
| - throw new RuntimeException("The magic number in the JRE's currency data is incorrect. Expected: 0x43757244, Got: 0x"+magic); |
79 |
| - } |
80 |
| - int fileVerNumber = dis.readInt(); |
81 |
| - int dataVerNumber = dis.readInt(); |
82 |
| - if (Integer.parseInt(fileVersion) != fileVerNumber || |
83 |
| - Integer.parseInt(dataVersion) != dataVerNumber) { |
84 |
| - throw new RuntimeException("Test data and JRE's currency data are inconsistent. test: (file: "+fileVersion+" data: "+dataVersion+"), JRE: (file: "+fileVerNumber+" data: "+dataVerNumber+")"); |
85 |
| - } |
86 |
| -System.out.println("test: (file: "+fileVersion+" data: "+dataVersion+"), JRE: (file: "+fileVerNumber+" data: "+dataVerNumber+")"); |
87 |
| - } catch (IOException ioe) { |
88 |
| - throw new RuntimeException(ioe); |
89 |
| - } |
90 |
| - return null; |
91 |
| - } |
92 |
| - }); |
93 | 81 | checked = true;
|
94 | 82 | }
|
95 | 83 | }
|
|
0 commit comments