Skip to content

Commit 9df9f14

Browse files
committed
Ensure static fields set during signed jar process
When loading a signed jar file that is on the classpath, such as the bouncy castle signed JCE jar file, it has been observed that the value of `restrictedJarVerificationProviders` and `jarVerificationProviders` are set to `null`. This causes a NullPointerException during the loading process. This update moves the static declarations of both `restrictedJarVerificationProviders` and `jarVerificationProviders` to be prior to the method call `RestrictedSecurity.checkHashValues()` since this method call needs both of these fields to be initialized to work correctly. Signed-off-by: Jason Katonica <[email protected]>
1 parent c5b4b77 commit 9df9f14

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/java.base/share/classes/sun/security/jca/Providers.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,6 @@ public class Providers {
5656
// Note volatile immutable object, so no synchronization needed.
5757
private static volatile ProviderList providerList;
5858

59-
static {
60-
// set providerList to empty list first in case initialization somehow
61-
// triggers a getInstance() call (although that should not happen)
62-
providerList = ProviderList.EMPTY;
63-
providerList = ProviderList.fromSecurityProperties();
64-
RestrictedSecurity.checkHashValues();
65-
}
66-
6759
private Providers() {
6860
// empty
6961
}
@@ -114,6 +106,14 @@ private Providers() {
114106
"com.sun.crypto.provider.SunJCE",
115107
};
116108

109+
static {
110+
// set providerList to empty list first in case initialization somehow
111+
// triggers a getInstance() call (although that should not happen)
112+
providerList = ProviderList.EMPTY;
113+
providerList = ProviderList.fromSecurityProperties();
114+
RestrictedSecurity.checkHashValues();
115+
}
116+
117117
// Return Sun provider.
118118
// This method should only be called by
119119
// sun.security.util.ManifestEntryVerifier and java.security.SecureRandom.

0 commit comments

Comments
 (0)