diff --git a/java/fury-benchmark/src/main/java/io/fury/benchmark/state/JsonbState.java b/java/fury-benchmark/src/main/java/io/fury/benchmark/state/JsonbState.java
index 1d943eade9..c4c98401b9 100644
--- a/java/fury-benchmark/src/main/java/io/fury/benchmark/state/JsonbState.java
+++ b/java/fury-benchmark/src/main/java/io/fury/benchmark/state/JsonbState.java
@@ -18,7 +18,6 @@
import com.alibaba.fastjson2.JSONB;
import com.alibaba.fastjson2.JSONFactory;
-import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.JSONReader;
import com.alibaba.fastjson2.JSONWriter;
import com.alibaba.fastjson2.reader.ObjectReaderProvider;
@@ -239,12 +238,5 @@ public static void main(String[] args) {
state.setup();
state.bufferType = BufferType.directBuffer;
state.setup();
-
- ;
- JSONObject json = new JSONObject();
- json.put("k", 1);
- Fury fury = Fury.builder().requireClassRegistration(false).build();
- byte[] bytes = fury.serialize(json);
- System.out.println(fury.deserialize(bytes));
}
}
diff --git a/java/fury-core/src/main/java/io/fury/Fury.java b/java/fury-core/src/main/java/io/fury/Fury.java
index 563353b0db..3030847d3e 100644
--- a/java/fury-core/src/main/java/io/fury/Fury.java
+++ b/java/fury-core/src/main/java/io/fury/Fury.java
@@ -70,6 +70,7 @@
* @author chaokunyang
*/
@NotThreadSafe
+@SuppressWarnings("unchecked")
public final class Fury {
private static final Logger LOG = LoggerFactory.getLogger(Fury.class);
@@ -617,7 +618,33 @@ public long readLong(MemoryBuffer buffer) {
return LongSerializer.readLong(buffer, longEncoding);
}
- /** Deserialize obj
from a byte array. */
+ /**
+ * Deserialize obj
from a byte array. Note declared result type must be a class or
+ * superclass/interface of the serialized object, otherwise a {@link ClassCastException} will be
+ * thrown.
+ *
+ *
For example, if you serialized an object of type `Integer`, then your declared deserialized + * type is `String`, the deserialization will just throw a {@link ClassCastException}. + * + *
{@code + * byte[] bytes = fury.serialize(1); + * String o = fury.deserialize(bytes); // throw ClassCastException. + * }+ * + * @param bytes serialized data. + * @param
obj
from a byte array.
+ *
+ * @param bytes serialized data.
+ * @return deserialized object.
+ */
public Object deserialize(byte[] bytes) {
return deserialize(MemoryUtils.wrap(bytes), null);
}
diff --git a/java/fury-core/src/main/java/io/fury/ThreadLocalFury.java b/java/fury-core/src/main/java/io/fury/ThreadLocalFury.java
index ad0e0436e9..a87e967047 100644
--- a/java/fury-core/src/main/java/io/fury/ThreadLocalFury.java
+++ b/java/fury-core/src/main/java/io/fury/ThreadLocalFury.java
@@ -69,6 +69,10 @@ public MemoryBuffer serialize(MemoryBuffer buffer, Object obj) {
return bindingThreadLocal.get().get().serialize(buffer, obj);
}
+ public