chaokunyang commented on code in PR #2701:
URL: https://github.com/apache/fory/pull/2701#discussion_r2455560139
##########
java/fory-core/src/main/java/org/apache/fory/util/GraalvmSupport.java:
##########
@@ -54,6 +65,103 @@ public static boolean isGraalRuntime() {
&&
GRAAL_IMAGE_RUNTIME.equals(System.getProperty(GRAAL_IMAGE_CODE_KEY));
}
+ /**
+ * Returns all classes registered for GraalVM native image compilation
across all configurations.
+ */
+ public static Set<Class<?>> getRegisteredClasses() {
+ return getAllRegisteredClasses();
+ }
+
+ /** Returns all proxy interfaces registered for GraalVM native image
compilation. */
+ public static Set<Class<?>> getProxyInterfaces() {
+ return getAllProxyInterfaces();
+ }
+
+ /** Clears all GraalVM native image registrations. Primarily for testing
purposes. */
+ public static void clearRegistrations() {
+ clearGraalvmRegistrations();
+ }
+
+ /**
+ * Get all registered classes across all GraalVM registries for native image
compilation.
+ *
+ * @return unmodifiable set of all registered classes
+ */
+ public static Set<Class<?>> getAllRegisteredClasses() {
+ Set<Class<?>> allClasses = ConcurrentHashMap.newKeySet();
+ for (GraalvmClassRegistry registry : GRAALVM_REGISTRY.values()) {
+ allClasses.addAll(registry.registeredClasses);
+ }
+ return Collections.unmodifiableSet(allClasses);
+ }
+
+ /**
+ * Get all registered proxy interfaces across all GraalVM registries for
native image compilation.
+ *
+ * @return unmodifiable set of all registered proxy interfaces
+ */
+ public static Set<Class<?>> getAllProxyInterfaces() {
+ Set<Class<?>> allInterfaces = ConcurrentHashMap.newKeySet();
+ for (GraalvmClassRegistry registry : GRAALVM_REGISTRY.values()) {
+ allInterfaces.addAll(registry.proxyInterfaces);
+ }
+ return Collections.unmodifiableSet(allInterfaces);
+ }
+
+ /**
+ * Register a class in the GraalVM registry for native image compilation.
+ *
+ * @param cls the class to register
+ * @param configHash the configuration hash for the Fory instance
+ */
+ public static void registerClassForGraalvm(Class<?> cls, int configHash) {
+ if (!IN_GRAALVM_NATIVE_IMAGE) {
+ return;
+ }
+ GraalvmClassRegistry registry =
+ GRAALVM_REGISTRY.computeIfAbsent(configHash, k -> new
GraalvmClassRegistry());
+ registry.registeredClasses.add(cls);
+ }
+
+ /**
+ * Register a proxy interface in the GraalVM registry for native image
compilation.
+ *
+ * @param proxyInterface the proxy interface to register
+ * @param configHash the configuration hash for the Fory instance
+ */
+ public static void registerProxyInterfaceForGraalvm(Class<?> proxyInterface,
int configHash) {
Review Comment:
The class is already GraalvmSupport, we don't need to replicate `graalvm` in
teh method name
--
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]