refactor(java): refactor fory java serialization api#3537
Merged
chaokunyang merged 33 commits intoapache:mainfrom Apr 6, 2026
Merged
refactor(java): refactor fory java serialization api#3537chaokunyang merged 33 commits intoapache:mainfrom
chaokunyang merged 33 commits intoapache:mainfrom
Conversation
…lization_arc # Conflicts: # docs/guide/java/configuration.md # docs/guide/java/index.md # docs/guide/java/schema-evolution.md # docs/guide/java/type-registration.md # java/fory-core/src/main/java/org/apache/fory/ThreadLocalFory.java # java/fory-core/src/main/java/org/apache/fory/ThreadSafeFory.java # java/fory-core/src/main/java/org/apache/fory/ThreadSafeForyPool.java # java/fory-core/src/main/java/org/apache/fory/config/ForyBuilder.java # java/fory-core/src/main/java/org/apache/fory/resolver/SharedRegistry.java # java/fory-core/src/main/java/org/apache/fory/serializer/ForwardSerializer.java # java/fory-core/src/main/resources/META-INF/native-image/org.apache.fory/fory-core/native-image.properties # java/fory-core/src/test/java/org/apache/fory/ThreadSafeForyTest.java # java/fory-core/src/test/java/org/apache/fory/builder/JITContextTest.java # java/fory-core/src/test/java/org/apache/fory/resolver/AllowListCheckerTest.java # java/fory-core/src/test/java/org/apache/fory/serializer/ForwardSerializerTest.java # java/fory-latest-jdk-tests/src/test/java/org/apache/fory/VirtualThreadSafeForyTest.java
8172693 to
f81aaa5
Compare
f81aaa5 to
c8ea40b
Compare
f26a803 to
ff73c52
Compare
34b99aa to
52a2393
Compare
pandalee99
approved these changes
Apr 6, 2026
4 tasks
chaokunyang
added a commit
that referenced
this pull request
Apr 8, 2026
## Why? Refactor the Python serialization runtime to make serializer ownership and per-operation state explicit. This moves read and write state out of `Fory`, aligns the Python and Cython code paths around the same context model, and simplifies how custom serializers interact with the runtime. ## What does this PR do? - Introduces explicit `Config`, `WriteContext`, and `ReadContext` runtime objects and moves serialization state management out of `Fory`. - Refactors Python and Cython serializer APIs to take `type_resolver` in constructors and to read or write through `read_context` and `write_context` instead of raw buffer methods. - Reorganizes the Python serialization implementation by moving context-owned logic into `context.py` and `context.pxi`, slimming `serialization.pyx`, and wiring collection, primitive, struct, union, and registry paths through the new boundaries. - Updates the Python custom serializer and type registration docs to the new constructor and context-based serializer method signatures. - Refreshes the affected Python tests to use the new serializer and runtime context API shape. ## Related issues #3537 ## AI Contribution Checklist - [ ] Substantial AI assistance was used in this PR: `yes` / `no` - [ ] If `yes`, I included a completed [AI Contribution Checklist](https://github.com/apache/fory/blob/main/AI_POLICY.md#9-contributor-checklist-for-ai-assisted-prs) in this PR description and the required `AI Usage Disclosure`. ## Does this PR introduce any user-facing change? This refactor changes the Python custom serializer constructor and read or write method signatures, and updates the Python docs accordingly. - [x] Does this PR introduce any public API change? - [ ] Does this PR introduce any binary protocol compatibility change? ## Benchmark
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why?
What does this PR do?
WriteContext,ReadContext,CopyContext,RefReader,RefWriter,MetaStringReader,MetaStringWriter,MetaWriteContext, andMetaReadContext.SerializationContext,RefResolver,MetaStringResolver,MetaStringRef,MapRefResolver,NoRefResolver, andForwardSerializer.Fory, moves per-operation state out of the root runtime object, and rewires resolver, serializer, and codegen paths to use the explicit contexts.shareable()contract.EncodedMetaStringcaching inSharedRegistryand context-owned read/write state.Related issues
#1017
AI Contribution Checklist
yes/noyes, I included a completed AI Contribution Checklist in this PR description and the requiredAI Usage Disclosure.Does this PR introduce any user-facing change?
Benchmark