8184916: DisabledAlgorithmConstraints loading should be delayed until needed
authoralanb
Wed, 19 Jul 2017 19:31:48 +0100
changeset 45925 1771cc023624
parent 45924 8bbd04c0791e
child 45926 43879a69df50
8184916: DisabledAlgorithmConstraints loading should be delayed until needed Reviewed-by: mullan
jdk/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java
--- a/jdk/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java	Wed Jul 19 19:30:08 2017 +0100
+++ b/jdk/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java	Wed Jul 19 19:31:48 2017 +0100
@@ -59,9 +59,15 @@
     /* Are we debugging ? */
     private static final Debug debug = Debug.getInstance("jar");
 
-    private static final DisabledAlgorithmConstraints JAR_DISABLED_CHECK =
+    /**
+     * Holder class to delay initialization of DisabledAlgorithmConstraints
+     * until needed.
+     */
+    private static class ConfigurationHolder {
+        static final DisabledAlgorithmConstraints JAR_DISABLED_CHECK =
             new DisabledAlgorithmConstraints(
                     DisabledAlgorithmConstraints.PROPERTY_JAR_DISABLED_ALGS);
+    }
 
     private ArrayList<CodeSigner[]> signerCache;
 
@@ -371,7 +377,7 @@
         Boolean permitted = permittedAlgs.get(algorithm);
         if (permitted == null) {
             try {
-                JAR_DISABLED_CHECK.permits(algorithm,
+                ConfigurationHolder.JAR_DISABLED_CHECK.permits(algorithm,
                         new ConstraintsParameters(timestamp));
             } catch(GeneralSecurityException e) {
                 permittedAlgs.put(algorithm, Boolean.FALSE);