-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(java): deserialize one pojo into another type #2012
Changes from 1 commit
04a9e14
52dfea2
2b58862
84bea5e
03f4ab7
b08afc4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1674,6 +1674,33 @@ public ClassInfo readClassInfo(MemoryBuffer buffer) { | |||||
return classInfo; | ||||||
} | ||||||
|
||||||
public ClassInfo readClassInfo(MemoryBuffer buffer, Class<?> targetClass) { | ||||||
if (metaContextShareEnabled) { | ||||||
ClassInfo classInfo = readClassInfoWithMetaShare(buffer, fury.getSerializationContext().getMetaContext()); | ||||||
|
||||||
// replace target class if needed | ||||||
if (!targetClass.getName().equals(classInfo.getCls().getName())) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
this will be much faster |
||||||
ClassInfo targetClassInfo = getClassInfo(targetClass); | ||||||
buildClassDef(targetClassInfo); | ||||||
classInfo.classDef = ClassDef.replaceRootClassTo(this, targetClassInfo); | ||||||
classInfo.serializer = createSerializer(targetClass); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line won't work as you expect. It just create a serializer for raw There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok I'll look into that first |
||||||
} | ||||||
|
||||||
return classInfo; | ||||||
} | ||||||
|
||||||
int header = buffer.readVarUint32Small14(); | ||||||
ClassInfo classInfo; | ||||||
if ((header & 0b1) != 0) { | ||||||
classInfo = readClassInfoFromBytes(buffer, classInfoCache, header); | ||||||
classInfoCache = classInfo; | ||||||
} else { | ||||||
classInfo = getOrUpdateClassInfo((short) (header >> 1)); | ||||||
} | ||||||
currentReadClass = classInfo.cls; | ||||||
return classInfo; | ||||||
} | ||||||
|
||||||
/** | ||||||
* Read class info from java data <code>buffer</code>. `classInfoCache` is used as a cache to | ||||||
* reduce map lookup to load class from binary. | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer to keep ClassDef immutable abd return a new ClassDef instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure ofc, im still stuck facing exception here and there.