Skip to content

fix(java): Correct generated ObjectStream layer bootstrap for GraalVM#3533

Closed
chaokunyang wants to merge 7 commits intoapache:mainfrom
chaokunyang:codex/pr3514-actual-fix
Closed

fix(java): Correct generated ObjectStream layer bootstrap for GraalVM#3533
chaokunyang wants to merge 7 commits intoapache:mainfrom
chaokunyang:codex/pr3514-actual-fix

Conversation

@chaokunyang
Copy link
Copy Markdown
Collaborator

Why?

This PR addresses the same bug as #3514 and is intended to replace it from a writable fork branch.

ObjectStreamSerializer can hit the async/generated meta-shared layer path for customized JDK serialization cases such as TreeSet/TreeMap subclasses. The original failure is tracked in #3515. The JVM-side async fix is necessary, but the final implementation also has to keep the generated layer serializer working for GraalVM native-image runtime.

What does this PR do?

  • fixes generated meta-shared layer serializer bootstrap for ObjectStreamSerializer
  • preloads generated layer serializer constructors during GraalVM build time so native-image runtime does not fall back to broken constructor discovery
  • persists layer TypeDef metadata through the GraalVM registry so newly created runtime Fory instances can rebuild generated layer serializers correctly
  • adds GraalVM coverage for a compatible ObjectStreamSerializer case using defaultWriteObject/defaultReadObject with TreeSet/TreeMap subclasses

This PR supersedes #3514.
Closes #3515.

Related issues

AI Contribution Checklist

  • Substantial AI assistance was used in this PR: yes
  • If yes, I included a completed AI Contribution Checklist in this PR description and the required AI Usage Disclosure.
  • If yes, I can explain and defend all important changes without AI help.
  • If yes, I reviewed AI-assisted code changes line by line before submission.
  • If yes, I ran adequate human verification and recorded evidence (checks run locally or in CI, pass/fail summary, and confirmation I reviewed results).
  • If yes, I added/updated tests and specs where required.
  • If yes, I validated protocol/performance impacts with evidence when applicable.
  • If yes, I verified licensing and provenance compliance.

AI Usage Disclosure

  • substantial_ai_assistance: yes
  • scope: implementation, refactor, GraalVM validation, test coverage updates
  • affected_files_or_subsystems: java/fory-core generated meta-shared layer bootstrap, GraalVM runtime registry/bootstrap path, integration_tests/graalvm_tests
  • human_verification: reviewed changes line by line; ran targeted JVM tests, checkstyle, and GraalVM native-image build/runtime validation locally; reviewed all passing results
  • performance_verification: no formal performance claim is made; the change preserves generated layer serializers on the hot path instead of falling back to interpreter behavior
  • provenance_license_confirmation: Apache-2.0-compatible provenance confirmed; no incompatible third-party code introduced

Does this PR introduce any user-facing change?

  • Does this PR introduce any public API change?
  • Does this PR introduce any binary protocol compatibility change?

Testing

  • ENABLE_FORY_DEBUG_OUTPUT=1 mvn -pl fory-core -am -Dtest=org.apache.fory.serializer.ObjectStreamSerializerTest,org.apache.fory.builder.JITContextTest -Dsurefire.failIfNoSpecifiedTests=false -nsu test
  • mvn -pl fory-core -DskipTests -nsu checkstyle:check
  • mvn -T16 -pl fory-core,fory-graalvm-feature -am install -DskipTests -nsu
  • cd integration_tests/graalvm_tests && mvn -T8 -DskipTests=true -Pnative package
  • cd integration_tests/graalvm_tests && ./target/main

@chaokunyang
Copy link
Copy Markdown
Collaborator Author

@mandrean I do not have the write permission to update your pr, so I created a new pr to address the errorrs

@chaokunyang chaokunyang requested review from pandalee99 and urlyy April 2, 2026 10:15
@chaokunyang chaokunyang closed this Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Java] ObjectStreamSerializer async meta-shared layer JIT fails for TreeSet/TreeMap subclasses

2 participants