-
Notifications
You must be signed in to change notification settings - Fork 299
Open
Labels
Description
Is your feature request related to a problem? Please describe.
Currently fury deserialize method return Object
type, if users serialized an object of type Foo
, users needs to cast to Foo
manually:
byte[] d = fury.serialize(foo);
Object o = fury.deserialize(d);
Foo o1 = (Foo) o;
This is inconvenient, and if there are generics such as:
Foo<A> foo = xxx;
byte[] d = fury.serialize(foo);
Object o = fury.deserialize(d);
Foo<A> foo o1 = (Foo<A> foo) o;
the cast will issue a javac warnings.
Then users will need to warp an util like this:
@SuppressWarnings("unchecked")
public static <T> T deserialize(byte[] b) {
Object o = fury.deserialize(b);
return (T) o;
}
We should do this for users.
Describe the solution you'd like
Implement cast in fuyr:
@SuppressWarnings("unchecked")
public static <T> T deserialize(byte[] b) {
Object o = fury.deserialize(b);
return (T) o;
}
Note if users declare error type, the deserialization will raise ClassCastException:
Foo<A> foo = xxx;
byte[] d = fury.serialize(foo);
Bar o = fury.deserialize(d); // raise ClassCastException.