From ddb57666713a3fe51fbe720a45b5270ec625d5ff Mon Sep 17 00:00:00 2001 From: chaokunyang Date: Sun, 3 Nov 2024 22:52:29 +0800 Subject: [PATCH] fix fury --- java/fury-core/src/main/java/org/apache/fury/Fury.java | 8 +++++++- .../main/java/org/apache/fury/resolver/XtypeResolver.java | 2 +- .../src/main/java/org/apache/fury/type/ScalaTypes.java | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/java/fury-core/src/main/java/org/apache/fury/Fury.java b/java/fury-core/src/main/java/org/apache/fury/Fury.java index 6dd1535816..7757bf3a2b 100644 --- a/java/fury-core/src/main/java/org/apache/fury/Fury.java +++ b/java/fury-core/src/main/java/org/apache/fury/Fury.java @@ -197,7 +197,13 @@ public void register(Class cls, int id, boolean createSerializer) { /** register class with given type tag which will be used for cross-language serialization. */ public void register(Class cls, String typeName) { Preconditions.checkArgument(language != Language.JAVA); - register(cls, "", typeName); + int idx = typeName.lastIndexOf('.'); + String namespace = ""; + if (idx > 0) { + namespace = typeName.substring(0, idx); + typeName = typeName.substring(idx); + } + register(cls, namespace, typeName); } public void register(Class cls, String namespace, String typeName) { diff --git a/java/fury-core/src/main/java/org/apache/fury/resolver/XtypeResolver.java b/java/fury-core/src/main/java/org/apache/fury/resolver/XtypeResolver.java index 397a995fb0..986e9cf876 100644 --- a/java/fury-core/src/main/java/org/apache/fury/resolver/XtypeResolver.java +++ b/java/fury-core/src/main/java/org/apache/fury/resolver/XtypeResolver.java @@ -76,7 +76,7 @@ public void register(Class type, int typeId) { if (serializer == null) { if (type.isEnum()) { classResolver.registerSerializer( - type, new EnumSerializer<>(classResolver.getFury(), type.asSubclass(Enum.class))); + type, new EnumSerializer(classResolver.getFury(), (Class) type)); } else { classResolver.registerSerializer( type, new StructSerializer<>(classResolver.getFury(), type)); diff --git a/java/fury-core/src/main/java/org/apache/fury/type/ScalaTypes.java b/java/fury-core/src/main/java/org/apache/fury/type/ScalaTypes.java index 8aa1b09637..6d044bb3d6 100644 --- a/java/fury-core/src/main/java/org/apache/fury/type/ScalaTypes.java +++ b/java/fury-core/src/main/java/org/apache/fury/type/ScalaTypes.java @@ -28,6 +28,7 @@ /** Scala types utils using reflection without dependency on scala library. */ @SuppressWarnings({"unchecked", "rawtypes"}) public class ScalaTypes { + private static final Class SCALA_MAP_TYPE; private static final Class SCALA_SEQ_TYPE; private static final Class SCALA_SET_TYPE;