chaokunyang commented on code in PR #2701:
URL: https://github.com/apache/fory/pull/2701#discussion_r2459126874
##########
java/fory-core/src/main/java/org/apache/fory/serializer/ObjectStreamSerializer.java:
##########
@@ -80,10 +80,60 @@
public class ObjectStreamSerializer extends AbstractObjectSerializer {
private static final Logger LOG =
LoggerFactory.getLogger(ObjectStreamSerializer.class);
- private final SlotsInfo[] slotsInfos;
+ private final SlotInfo[] slotsInfos;
+
+ /**
+ * Interface for slot information used in ObjectStreamSerializer. This
allows both full SlotsInfo
+ * and minimal MinimalSlotsInfo implementations.
+ */
+ private interface SlotInfo {
+ Class<?> getCls();
+
+ StreamClassInfo getStreamClassInfo();
+
+ CompatibleSerializerBase getSlotsSerializer();
+
+ ForyObjectOutputStream getObjectOutputStream();
+
+ ForyObjectInputStream getObjectInputStream();
+
+ ObjectArray getFieldPool();
+
+ ObjectIntMap<String> getFieldIndexMap();
+
+ FieldResolver getPutFieldsResolver();
+
+ CompatibleSerializer getCompatibleStreamSerializer();
+ }
+
+ /**
+ * Safe wrapper for ObjectStreamClass.lookup that handles GraalVM native
image limitations. In
+ * GraalVM native image, ObjectStreamClass.lookup may fail for certain
classes like Throwable due
+ * to missing SerializationConstructorAccessor. This method catches such
exceptions and returns
+ * null, allowing the serializer to use alternative approaches like
Unsafe.allocateInstance.
+ */
+ private static ObjectStreamClass safeObjectStreamClassLookup(Class<?> type) {
+ if (GraalvmSupport.isGraalRuntime()) {
Review Comment:
Just use `GraalvmSupport.IS_GRAALVM_NATIVE_IMAGE`
--
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]