changeset 59700:c5203b158ec8

8237508: Simplify JarFile.isInitializing Reviewed-by: dfuchs, coffeys, lancea
author redestad
date Mon, 20 Jan 2020 14:24:21 +0100
parents 62a003539b0c
children 67e7f7e8284a
files src/java.base/share/classes/java/util/jar/JarFile.java src/java.base/share/classes/java/util/jar/JavaUtilJarAccessImpl.java src/java.base/share/classes/jdk/internal/access/JavaUtilJarAccess.java
diffstat 3 files changed, 15 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/util/jar/JarFile.java	Mon Jan 20 11:15:45 2020 +0100
+++ b/src/java.base/share/classes/java/util/jar/JarFile.java	Mon Jan 20 14:24:21 2020 +0100
@@ -146,11 +146,13 @@
  * @since   1.2
  */
 public class JarFile extends ZipFile {
-    private final static Runtime.Version BASE_VERSION;
-    private final static int BASE_VERSION_FEATURE;
-    private final static Runtime.Version RUNTIME_VERSION;
-    private final static boolean MULTI_RELEASE_ENABLED;
-    private final static boolean MULTI_RELEASE_FORCED;
+    private static final Runtime.Version BASE_VERSION;
+    private static final int BASE_VERSION_FEATURE;
+    private static final Runtime.Version RUNTIME_VERSION;
+    private static final boolean MULTI_RELEASE_ENABLED;
+    private static final boolean MULTI_RELEASE_FORCED;
+    private static final ThreadLocal<Boolean> isInitializing = new ThreadLocal<>();
+
     private SoftReference<Manifest> manRef;
     private JarEntry manEntry;
     private JarVerifier jv;
@@ -159,8 +161,6 @@
     private final Runtime.Version version;  // current version
     private final int versionFeature;       // version.feature()
     private boolean isMultiRelease;         // is jar multi-release?
-    static final ThreadLocal<Boolean> isInitializing =
-            ThreadLocal.withInitial(() -> Boolean.FALSE);
 
     // indicates if Class-Path attribute present
     private boolean hasClassPathAttribute;
@@ -1043,6 +1043,11 @@
         }
     }
 
+    static boolean isInitializing() {
+        Boolean value = isInitializing.get();
+        return (value == null) ? false : value;
+    }
+
     /*
      * Returns a versioned {@code JarFileEntry} for the given entry,
      * if there is one. Otherwise returns the original entry. This
--- a/src/java.base/share/classes/java/util/jar/JavaUtilJarAccessImpl.java	Mon Jan 20 11:15:45 2020 +0100
+++ b/src/java.base/share/classes/java/util/jar/JavaUtilJarAccessImpl.java	Mon Jan 20 14:24:21 2020 +0100
@@ -69,7 +69,7 @@
         jar.ensureInitialization();
     }
 
-    public Boolean isInitializing() {
-        return JarFile.isInitializing.get();
+    public boolean isInitializing() {
+        return JarFile.isInitializing();
     }
 }
--- a/src/java.base/share/classes/jdk/internal/access/JavaUtilJarAccess.java	Mon Jan 20 11:15:45 2020 +0100
+++ b/src/java.base/share/classes/jdk/internal/access/JavaUtilJarAccess.java	Mon Jan 20 14:24:21 2020 +0100
@@ -45,5 +45,5 @@
     public List<Object> getManifestDigests(JarFile jar);
     public Attributes getTrustedAttributes(Manifest man, String name);
     public void ensureInitialization(JarFile jar);
-    public Boolean isInitializing();
+    public boolean isInitializing();
 }