Improve error message if codec not found Fixes #12300

This commit is contained in:
Gus Heck 2023-05-16 15:48:43 -04:00
parent f53eb28af0
commit 5b505006e7
1 changed files with 9 additions and 1 deletions

View File

@ -99,6 +99,8 @@ public final class NamedSPILoader<S extends NamedSPILoader.NamedSPI> implements
return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z') || ('0' <= c && c <= '9');
}
@SuppressWarnings("removal")
@SuppressForbidden(reason = "security manager")
public S lookup(String name) {
final S service = services.get(name);
if (service != null) return service;
@ -110,7 +112,13 @@ public final class NamedSPILoader<S extends NamedSPILoader.NamedSPI> implements
+ "' does not exist."
+ " You need to add the corresponding JAR file supporting this SPI to your classpath."
+ " The current classpath supports the following names: "
+ availableServices());
+ availableServices()
+ ((System.getSecurityManager() == null)
? ""
: "We have detected that a security manager is installed so it is also possible "
+ "that the jar containing the codec is inaccessible under the current "
+ "security policy. (Java does not throw SecurityException if this is the "
+ "case, it just ignores the jar!)"));
}
public Set<String> availableServices() {