This is an automated email from the ASF dual-hosted git repository.

jin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph.git


The following commit(s) were added to refs/heads/master by this push:
     new da6b12360 refactor: remove the package existing in java8 (#2792)
da6b12360 is described below

commit da6b123606df13ec223bbe9d7e52638ca3a7c6df
Author: Tsukilc <[email protected]>
AuthorDate: Sun Sep 28 12:24:20 2025 +0800

    refactor: remove the package existing in java8 (#2792)
    
    * refactor: Delete the package existing in java8
    
    * chore(format): remove custom line breaks
---
 .../hugegraph/auth/HugeFactoryAuthProxy.java       |  9 ++---
 .../hugegraph/security/HugeSecurityManager.java    |  1 -
 .../java/org/apache/hugegraph/util/Reflection.java | 46 ++++++++--------------
 3 files changed, 20 insertions(+), 36 deletions(-)

diff --git 
a/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/auth/HugeFactoryAuthProxy.java
 
b/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/auth/HugeFactoryAuthProxy.java
index 3ffaefb04..41e9186d7 100644
--- 
a/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/auth/HugeFactoryAuthProxy.java
+++ 
b/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/auth/HugeFactoryAuthProxy.java
@@ -66,10 +66,9 @@ import com.google.common.collect.ImmutableSet;
 
 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<>();
@@ -498,8 +497,6 @@ public final class HugeFactoryAuthProxy {
         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");
     }
@@ -636,8 +633,8 @@ public final class HugeFactoryAuthProxy {
         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);
diff --git 
a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/security/HugeSecurityManager.java
 
b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/security/HugeSecurityManager.java
index f32491ece..13ca80122 100644
--- 
a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/security/HugeSecurityManager.java
+++ 
b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/security/HugeSecurityManager.java
@@ -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",
diff --git 
a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/Reflection.java
 
b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/Reflection.java
index f85382402..6e5fd0752 100644
--- 
a/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/Reflection.java
+++ 
b/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/util/Reflection.java
@@ -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";
-
     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 {
@@ -89,7 +76,8 @@ public class Reflection {
 
     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 {

Reply via email to