chaokunyang commented on code in PR #2485:
URL: https://github.com/apache/fory/pull/2485#discussion_r2309284798
##########
java/fory-core/src/main/java/org/apache/fory/resolver/ClassResolver.java:
##########
@@ -2311,4 +2312,34 @@ private Class<? extends Serializer>
getMetaSharedDeserializerClassFromGraalvmReg
}
return null;
}
+
+ /**
+ * Register compressed array serializers if compression flags are enabled
and the
+ * fory-array-compression module is available on the classpath.
+ */
+ private void registerCompressedSerializersIfEnabled() {
+ boolean compressInt = fory.getConfig().compressIntArray();
+ boolean compressLong = fory.getConfig().compressLongArray();
+
+ if (compressInt || compressLong) {
+ try {
+ // Try to load the compressed array serializers class and call its
register method
+ Class<?> compressedSerializersClass =
+
Class.forName("org.apache.fory.serializer.CompressedArraySerializers");
+
+ // Call the static register method
+ java.lang.reflect.Method registerMethod =
+ compressedSerializersClass.getDeclaredMethod("registerIfEnabled",
Fory.class);
Review Comment:
Could we define an interface and let some module to implement
registerSerializers? In thsi way, we can avoid use reflection
##########
java/fory-core/src/main/java/org/apache/fory/resolver/ClassResolver.java:
##########
@@ -2311,4 +2312,34 @@ private Class<? extends Serializer>
getMetaSharedDeserializerClassFromGraalvmReg
}
return null;
}
+
+ /**
+ * Register compressed array serializers if compression flags are enabled
and the
+ * fory-array-compression module is available on the classpath.
+ */
+ private void registerCompressedSerializersIfEnabled() {
+ boolean compressInt = fory.getConfig().compressIntArray();
+ boolean compressLong = fory.getConfig().compressLongArray();
+
+ if (compressInt || compressLong) {
+ try {
+ // Try to load the compressed array serializers class and call its
register method
+ Class<?> compressedSerializersClass =
+
Class.forName("org.apache.fory.serializer.CompressedArraySerializers");
+
+ // Call the static register method
+ java.lang.reflect.Method registerMethod =
+ compressedSerializersClass.getDeclaredMethod("registerIfEnabled",
Fory.class);
Review Comment:
Could we define an interface and let some module to implement
registerSerializers? In thsi way, we can avoid to use reflection
--
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]