Skip to content

Commit 9ce276e

Browse files
committed
[GR-40544] Only register valid services in native image
PullRequest: graal/12496
2 parents 5b039c4 + bc9535e commit 9ce276e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SecurityServicesFeature.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,12 +617,23 @@ private static Map<String, Set<Service>> computeAvailableServices() {
617617
Map<String, Set<Service>> availableServices = new HashMap<>();
618618
for (Provider provider : Security.getProviders()) {
619619
for (Service s : provider.getServices()) {
620-
availableServices.computeIfAbsent(s.getType(), t -> new HashSet<>()).add(s);
620+
if (isValid(s)) {
621+
availableServices.computeIfAbsent(s.getType(), t -> new HashSet<>()).add(s);
622+
}
621623
}
622624
}
623625
return availableServices;
624626
}
625627

628+
/**
629+
* Check is service is valid. See {@code java.security.Provider.Service#isValid()}.
630+
*
631+
* Presumably, this is only needed due to an upstream bug introduced in JDK 19 [GR-40544].
632+
*/
633+
private static boolean isValid(Service s) {
634+
return (s.getType() != null) && (s.getAlgorithm() != null) && (s.getClassName() != null);
635+
}
636+
626637
/**
627638
* Return a Function which given the serviceType as a String will return the corresponding
628639
* constructor parameter Class, or null.

0 commit comments

Comments
 (0)