-
Notifications
You must be signed in to change notification settings - Fork 339
feat(java): implement FinalFieldReplaceResolveSerializer for final fields with writeReplace/readResolve methods #2917
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
base: main
Are you sure you want to change the base?
Conversation
…elds with writeReplace/readResolve methods. This helps to avoid writing class names for final fields to the payload.
…ing descriptor context
… fields with writeReplace/readResolve methods
…t for final fields
|
@chaokunyang re-created my PR, addressed your comments in slack, please check |
| if (JavaSerializer.getWriteReplaceMethod(cls) != null) { | ||
| return ReplaceResolveSerializer.class; | ||
| if (!fory.isCompatible() && !fory.isShareMeta() && Modifier.isFinal(cls.getModifiers())) { | ||
| return FinalFieldReplaceResolveSerializer.class; |
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 don't think we can return this here? If FinalFieldReplaceResolveSerializer don't write class info, and fory don't write class into, then for deserialization, how do we know which class to use to create object instance?
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.
FinalFieldReplaceResolveSerializer can only be used for field serializer, and getSerializerClass is used for non-field object serialization too.
Another thing is that this change make all tests pass, it should not. We may need add a test to cover this
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.
you're right. wdyt about 0645ed9 ?
java/fory-core/src/main/java/org/apache/fory/serializer/AbstractObjectSerializer.java
Outdated
Show resolved
Hide resolved
…dling in serializers. Add a cache for final fields.
Why?
Based on the discussion #2786.
We can optimize the payload in cases where we have final fields in some Object.
re-created, closed PR #2904
What does this PR do?
Introduce
FinalFieldReplaceResolverwhich does not write the classname into the payload.Related issues
Does this PR introduce any user-facing change?
Benchmark