chaokunyang commented on code in PR #2701:
URL: https://github.com/apache/fory/pull/2701#discussion_r2424627489


##########
java/fory-core/src/main/java/org/apache/fory/reflect/ObjectCreators.java:
##########
@@ -77,16 +77,47 @@ public static <T> ObjectCreator<T> 
getObjectCreator(Class<T> type) {
     return (ObjectCreator<T>) cache.get(type, () -> 
creategetObjectCreator(type));
   }
 
+  /**
+   * Checks if a class is problematic for object creation and requires special 
handling in GraalVM.
+   *
+   * <p>A class is considered problematic if it lacks a public no-arg 
constructor and would
+   * typically require ReflectionFactory or unsafe allocation for 
instantiation.
+   *
+   * @param type the class to check
+   * @return true if the class is problematic for creation, false otherwise
+   */
+  public static boolean isProblematicForCreation(Class<?> type) {
+    if (type.isInterface()
+        || java.lang.reflect.Modifier.isAbstract(type.getModifiers())
+        || type.isArray()
+        || type.isEnum()
+        || type.isAnonymousClass()
+        || type.isLocalClass()
+        || RecordUtils.isRecord(type)) {
+      return false;
+    }
+    Constructor<?>[] constructors = type.getDeclaredConstructors();
+    if (constructors.length == 0) {
+      return true;
+    }
+    for (Constructor<?> constructor : constructors) {
+      if (constructor.getParameterCount() == 0) {
+        return false;

Review Comment:
   For JDK17+ record, if its constructor is public accessible, then it can be 
invoked by Fory



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to