File tree 3 files changed +26
-2
lines changed
src/java.base/share/classes/jdk/internal/foreign
3 files changed +26
-2
lines changed Original file line number Diff line number Diff line change 29
29
import java .lang .invoke .MethodHandles ;
30
30
import java .nio .file .Files ;
31
31
import java .nio .file .Path ;
32
+ import java .security .AccessController ;
33
+ import java .security .PrivilegedAction ;
32
34
import java .util .Objects ;
33
35
import java .util .Optional ;
34
36
import java .util .function .Function ;
@@ -72,11 +74,24 @@ private static SymbolLookup makeSystemLookup() {
72
74
}
73
75
74
76
private static SymbolLookup makeWindowsLookup () {
75
- Path system32 = Path .of (System .getenv ("SystemRoot" ), "System32" );
77
+ @ SuppressWarnings ("removal" )
78
+ String systemRoot = AccessController .doPrivileged (new PrivilegedAction <String >() {
79
+ @ Override
80
+ public String run () {
81
+ return System .getenv ("SystemRoot" );
82
+ }
83
+ });
84
+ Path system32 = Path .of (systemRoot , "System32" );
76
85
Path ucrtbase = system32 .resolve ("ucrtbase.dll" );
77
86
Path msvcrt = system32 .resolve ("msvcrt.dll" );
78
87
79
- boolean useUCRT = Files .exists (ucrtbase );
88
+ @ SuppressWarnings ("removal" )
89
+ boolean useUCRT = AccessController .doPrivileged (new PrivilegedAction <Boolean >() {
90
+ @ Override
91
+ public Boolean run () {
92
+ return Files .exists (ucrtbase );
93
+ }
94
+ });
80
95
Path stdLib = useUCRT ? ucrtbase : msvcrt ;
81
96
SymbolLookup lookup = libLookup (libs -> libs .load (stdLib ));
82
97
Original file line number Diff line number Diff line change 27
27
* @requires jdk.foreign.linker != "UNSUPPORTED"
28
28
* @modules java.base/jdk.internal.foreign
29
29
* @run testng TestLinker
30
+ * @run testng/othervm/policy=security.policy
31
+ * -Djava.security.manager=default TestLinker
30
32
*/
31
33
32
34
import jdk .internal .foreign .CABI ;
Original file line number Diff line number Diff line change
1
+ grant codeBase "file:${test.classes}/*" {
2
+ // Permissions needed to run the test
3
+ permission java.util.PropertyPermission "os.name", "read";
4
+ permission java.util.PropertyPermission "NativeTestHelper.DEFAULT_RANDOM.seed", "read";
5
+ permission java.lang.RuntimePermission "accessClassInPackage.jdk.internal.foreign";
6
+ };
7
+
You can’t perform that action at this time.
0 commit comments