1
1
/*
2
- * Copyright (c) 2015, 2021 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2015, 2024 , 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
38
38
import java .nio .ByteBuffer ;
39
39
import java .nio .file .Files ;
40
40
import java .nio .file .Path ;
41
- import java .security .AccessController ;
42
- import java .security .PrivilegedAction ;
43
41
import java .util .ArrayDeque ;
44
42
import java .util .Collections ;
45
43
import java .util .Deque ;
@@ -208,21 +206,7 @@ public static ModuleFinder ofSystem() {
208
206
Path dir = Path .of (home , "modules" );
209
207
if (!Files .isDirectory (dir ))
210
208
throw new InternalError ("Unable to detect the run-time image" );
211
- ModuleFinder f = ModulePath .of (ModuleBootstrap .patcher (), dir );
212
- return new ModuleFinder () {
213
- @ SuppressWarnings ("removal" )
214
- @ Override
215
- public Optional <ModuleReference > find (String name ) {
216
- PrivilegedAction <Optional <ModuleReference >> pa = () -> f .find (name );
217
- return AccessController .doPrivileged (pa );
218
- }
219
- @ SuppressWarnings ("removal" )
220
- @ Override
221
- public Set <ModuleReference > findAll () {
222
- PrivilegedAction <Set <ModuleReference >> pa = f ::findAll ;
223
- return AccessController .doPrivileged (pa );
224
- }
225
- };
209
+ return ModulePath .of (ModuleBootstrap .patcher (), dir );
226
210
}
227
211
228
212
/**
@@ -314,7 +298,7 @@ static ModuleReference toModuleReference(ModuleDescriptor descriptor,
314
298
Supplier <ModuleReader > readerSupplier = new Supplier <>() {
315
299
@ Override
316
300
public ModuleReader get () {
317
- return new SystemModuleReader (mn , uri );
301
+ return new SystemModuleReader (mn );
318
302
}
319
303
};
320
304
@@ -377,9 +361,7 @@ public byte[] generate(String algorithm) {
377
361
}
378
362
379
363
/**
380
- * Holder class for the ImageReader
381
- *
382
- * @apiNote This class must be loaded before a security manager is set.
364
+ * Holder class for the ImageReader.
383
365
*/
384
366
private static class SystemImage {
385
367
static final ImageReader READER = ImageReaderFactory .getImageReader ();
@@ -396,25 +378,7 @@ private static class SystemModuleReader implements ModuleReader {
396
378
private final String module ;
397
379
private volatile boolean closed ;
398
380
399
- /**
400
- * If there is a security manager set then check permission to
401
- * connect to the run-time image.
402
- */
403
- private static void checkPermissionToConnect (URI uri ) {
404
- @ SuppressWarnings ("removal" )
405
- SecurityManager sm = System .getSecurityManager ();
406
- if (sm != null ) {
407
- try {
408
- URLConnection uc = uri .toURL ().openConnection ();
409
- sm .checkPermission (uc .getPermission ());
410
- } catch (IOException ioe ) {
411
- throw new UncheckedIOException (ioe );
412
- }
413
- }
414
- }
415
-
416
- SystemModuleReader (String module , URI uri ) {
417
- checkPermissionToConnect (uri );
381
+ SystemModuleReader (String module ) {
418
382
this .module = module ;
419
383
}
420
384
0 commit comments