Skip to content

Remove SecurityManager related code from API #412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 1 addition & 20 deletions api/src/main/java/jakarta/json/spi/JsonProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
Expand Down Expand Up @@ -108,9 +106,7 @@ protected JsonProvider() {
*/
public static JsonProvider provider() {
LOG.log(Level.FINE, "Checking system property {0}", JSONP_PROVIDER_FACTORY);
final String factoryClassName = System.getSecurityManager() != null
? AccessController.doPrivileged((PrivilegedAction<String>) () -> System.getProperty(JSONP_PROVIDER_FACTORY))
: System.getProperty(JSONP_PROVIDER_FACTORY);
final String factoryClassName = System.getProperty(JSONP_PROVIDER_FACTORY);
if (factoryClassName != null) {
JsonProvider provider = newInstance(factoryClassName);
LOG.log(Level.FINE, "System property used; returning object [{0}]",
Expand Down Expand Up @@ -152,7 +148,6 @@ public static JsonProvider provider() {
*/
private static JsonProvider newInstance(String className) {
try {
checkPackageAccess(className);
@SuppressWarnings({"unchecked"})
Class<JsonProvider> clazz = (Class<JsonProvider>) Class.forName(className);
return clazz.getConstructor().newInstance();
Expand All @@ -166,20 +161,6 @@ private static JsonProvider newInstance(String className) {
}
}

/**
* Make sure that the current thread has an access to the package of the given name.
* @param className The class name to check.
*/
private static void checkPackageAccess(String className) {
SecurityManager s = System.getSecurityManager();
if (s != null) {
int i = className.lastIndexOf('.');
if (i != -1) {
s.checkPackageAccess(className.substring(0, i));
}
}
}

/**
* Creates a JSON parser from a character stream.
*
Expand Down