Skip to content

Commit 02d2493

Browse files
author
Justin Lu
committed
8347613: Remove leftover doPrivileged call in Currency test: CheckDataVersion.java
Reviewed-by: naoto
1 parent 10d08db commit 02d2493

File tree

1 file changed

+16
-28
lines changed

1 file changed

+16
-28
lines changed

test/jdk/java/util/Currency/CheckDataVersion.java

+16-28
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
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.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -33,8 +33,6 @@
3333
import java.io.FileReader;
3434
import java.io.IOException;
3535
import java.io.InputStream;
36-
import java.security.AccessController;
37-
import java.security.PrivilegedAction;
3836
import java.util.Currency;
3937

4038
class CheckDataVersion {
@@ -63,33 +61,23 @@ static void check() {
6361
break;
6462
}
6563
}
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+")");
6677
} catch (IOException ioe) {
67-
throw new RuntimeException(ioe);
78+
throw new RuntimeException(
79+
"currency.data was not retrieved properly", ioe);
6880
}
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-
});
9381
checked = true;
9482
}
9583
}

0 commit comments

Comments
 (0)