RFR: 8175079: Lazy initialization of ImageReader breaks rmid
Claes Redestad
claes.redestad at oracle.com
Thu Feb 16 16:30:14 UTC 2017
Done!
On 02/16/2017 05:27 PM, Alan Bateman wrote:
> I think go with the first for now.
>
> -Alan
>
>
> On 16/02/2017 16:24, Claes Redestad wrote:
>
>> Hi,
>>
>> please review this simple backout of a startup optimization that has
>> proven to destabilize things like rmid. Patch inline..
>>
>> Bug: https://bugs.openjdk.java.net/browse/JDK-8175079
>>
>> diff -r 87f2a6fb4b9a src/java.base/share/classes/java/lang/System.java
>> --- a/src/java.base/share/classes/java/lang/System.java Wed Feb 15
>> 15:57:18 2017 +0100
>> +++ b/src/java.base/share/classes/java/lang/System.java Thu Feb 16
>> 17:18:49 2017 +0100
>> @@ -1945,9 +1945,6 @@
>> // set security manager
>> String cn = System.getProperty("java.security.manager");
>> if (cn != null) {
>> - // ensure image reader for java.base is initialized
>> before security manager
>> - Object.class.getResource("module-info.class");
>> -
>> if (cn.isEmpty() || "default".equals(cn)) {
>> System.setSecurityManager(new SecurityManager());
>> } else {
>> diff -r 87f2a6fb4b9a
>> src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java
>> ---
>> a/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java
>> Wed Feb 15 15:57:18 2017 +0100
>> +++
>> b/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java
>> Thu Feb 16 17:18:49 2017 +0100
>> @@ -115,12 +115,7 @@
>> long t0 = System.nanoTime();
>>
>> // system modules (may be patched)
>> - ModuleFinder systemModules;
>> - if (SystemModules.MODULE_NAMES.length > 0) {
>> - systemModules = SystemModuleFinder.getInstance();
>> - } else {
>> - systemModules = ModuleFinder.ofSystem();
>> - }
>> + ModuleFinder systemModules = ModuleFinder.ofSystem();
>>
>> PerfCounters.systemModulesTime.addElapsedTimeFrom(t0);
>>
>>
>> An alternative patch is to move the force initialization of the image
>> reader from initPhase3 to SecurityManager,
>> which ensures it's initialized before a security manager is
>> installed. This preserves the startup optimization in
>> case a SM is not installed:
>>
>> diff -r 87f2a6fb4b9a
>> src/java.base/share/classes/java/lang/SecurityManager.java
>> --- a/src/java.base/share/classes/java/lang/SecurityManager.java Wed
>> Feb 15 15:57:18 2017 +0100
>> +++ b/src/java.base/share/classes/java/lang/SecurityManager.java Thu
>> Feb 16 17:23:57 2017 +0100
>> @@ -233,6 +233,11 @@
>> public
>> class SecurityManager {
>>
>> + static {
>> + // ensure image reader for java.base is initialized before
>> security
>> + // manager is installed
>> + Object.class.getResource("module-info.class");
>> + }
>> /**
>> * This field is <code>true</code> if there is a security check in
>> * progress; <code>false</code> otherwise.
>>
>>
>> Thanks!
>>
>> /Claes
>
More information about the security-dev
mailing list