Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,9 @@

public final class HugeFactoryAuthProxy {

private static final Logger LOG = Log.logger(HugeFactoryAuthProxy.class);
public static final String GRAPH_FACTORY =
"gremlin.graph=org.apache.hugegraph.auth.HugeFactoryAuthProxy";

private static final Logger LOG = Log.logger(HugeFactoryAuthProxy.class);
private static final Set<String> PROTECT_METHODS = ImmutableSet.of("instance");

private static final Map<HugeGraph, HugeGraph> GRAPHS = new HashMap<>();
Expand Down Expand Up @@ -498,8 +497,6 @@ public static void filterCriticalSystemClasses() {
Reflection.registerMethodsToFilter(loadClass("java.lang.ProcessImpl"), "forkAndExec",
"setAccessible", "start");

optionalMethodsToFilter("sun.invoke.util.BytecodeDescriptor", "parseMethod", "parseSig");
optionalMethodsToFilter("sun.reflect.misc.MethodUtil", "invoke");
optionalMethodsToFilter("jdk.internal.reflect.MethodAccessor", "invoke");
optionalMethodsToFilter("jdk.internal.reflect.NativeMethodAccessorImpl", "invoke");
}
Expand Down Expand Up @@ -636,8 +633,8 @@ public static void optionalMethodsToFilter(String className, String... methodNam
try {
clazz = Class.forName(className);
} catch (ClassNotFoundException e) {
// TODO: we just ignore the exception, change it after we drop Java8 support
LOG.warn("Skip register class {} to filter", className);
LOG.debug("Internal class {} not found in this JDK implementation, skipping filter " +
"registration", className, e);
}
if (clazz != null) {
Reflection.registerMethodsToFilter(clazz, methodNames);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public class HugeSecurityManager extends SecurityManager {

private static final Set<String> ACCEPT_CLASS_LOADERS = ImmutableSet.of(
"groovy.lang.GroovyClassLoader",
"sun.reflect.DelegatingClassLoader",
"jdk.internal.reflect.DelegatingClassLoader",
"org.codehaus.groovy.reflection.SunClassLoader",
"org.codehaus.groovy.runtime.callsite.CallSiteClassLoader",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,49 +33,36 @@ public class Reflection {
private static final Method REGISTER_FILEDS_TO_FILTER_METHOD;
private static final Method REGISTER_METHODS_TO_FILTER_METHOD;

public static final String JDK_INTERNAL_REFLECT_REFLECTION = "jdk.internal.reflect.Reflection";
public static final String SUN_REFLECT_REFLECTION = "sun.reflect.Reflection";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove this constant variables?


static {
Method registerFieldsToFilterMethodTemp = null;
Method registerMethodsToFilterMethodTemp = null;
Class<?> reflectionClazzTemp = null;
try {
reflectionClazzTemp = Class.forName(JDK_INTERNAL_REFLECT_REFLECTION);
reflectionClazzTemp = Class.forName("jdk.internal.reflect.Reflection");

registerFieldsToFilterMethodTemp =
reflectionClazzTemp.getMethod("registerFieldsToFilter",
Class.class, String[].class);

registerMethodsToFilterMethodTemp =
reflectionClazzTemp.getMethod("registerMethodsToFilter",
Class.class, String[].class);
} catch (ClassNotFoundException e) {
try {
reflectionClazzTemp = Class.forName(SUN_REFLECT_REFLECTION);
} catch (ClassNotFoundException ex) {
LOG.error("Can't find Reflection class", ex);
}
LOG.error("Can't find jdk.internal.reflect.Reflection class, " +
"please ensure you are using Java 11", e);
} catch (NoSuchMethodException e) {
LOG.error("Can't find reflection filter methods", e);
}

REFLECTION_CLAZZ = reflectionClazzTemp;

if (REFLECTION_CLAZZ != null) {
try {
registerFieldsToFilterMethodTemp =
REFLECTION_CLAZZ.getMethod("registerFieldsToFilter",
Class.class, String[].class);
} catch (Throwable e) {
LOG.error("Can't find registerFieldsToFilter method", e);
}

try {
registerMethodsToFilterMethodTemp =
REFLECTION_CLAZZ.getMethod("registerMethodsToFilter",
Class.class, String[].class);
} catch (NoSuchMethodException e) {
LOG.error("Can't find registerMethodsToFilter method", e);
}
}
REGISTER_FILEDS_TO_FILTER_METHOD = registerFieldsToFilterMethodTemp;
REGISTER_METHODS_TO_FILTER_METHOD = registerMethodsToFilterMethodTemp;
}

public static void registerFieldsToFilter(Class<?> containingClass, String... fieldNames) {
if (REGISTER_FILEDS_TO_FILTER_METHOD == null) {
throw new NotSupportException("Reflection.registerFieldsToFilter()");
throw new NotSupportException("Reflection.registerFieldsToFilter() - " +
"requires Java 11 or higher");
}

try {
Expand All @@ -89,7 +76,8 @@ public static void registerFieldsToFilter(Class<?> containingClass, String... fi

public static void registerMethodsToFilter(Class<?> containingClass, String... methodNames) {
if (REGISTER_METHODS_TO_FILTER_METHOD == null) {
throw new NotSupportException("Reflection.registerMethodsToFilterMethod()");
throw new NotSupportException("Reflection.registerMethodsToFilter() - " +
"requires Java 11 or higher");
}

try {
Expand Down
Loading