Skip to content

fix(java): avoid instantiating abstract meta-share types#3677

Merged
chaokunyang merged 1 commit into
apache:mainfrom
chaokunyang:issue-3674-compatible-interface-metashare
May 13, 2026
Merged

fix(java): avoid instantiating abstract meta-share types#3677
chaokunyang merged 1 commit into
apache:mainfrom
chaokunyang:issue-3674-compatible-interface-metashare

Conversation

@chaokunyang
Copy link
Copy Markdown
Collaborator

@chaokunyang chaokunyang commented May 13, 2026

Why?

Java compatible meta-share can receive a TypeDef whose root class is an interface or abstract class. Instantiating compatible serializers allocate their root type during read, so those meta roots must not get a serializer that can call Unsafe.allocateInstance on an uninstantiable declared type.

What does this PR do?

  • Leaves abstract/interface meta-share roots without an instantiating compatible serializer in TypeResolver#getMetaSharedTypeInfo.
  • Keeps concrete values on the existing runtime type metadata or target-class transformation path.
  • Adds a resolver-level regression for interface-root meta-share TypeDefs.
  • Adds an interface-field compatible meta-share round-trip regression after generated serializers compile.

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, my PR description includes the required ai_review summary and screenshot evidence of the final clean AI review results from both fresh reviewers on the current PR diff or current HEAD after the latest code changes.

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?

Benchmark

N/A. This change prevents instantiating serializers for abstract/interface meta-share roots and does not change hot-path serialization for concrete runtime values.

Tests

  • ENABLE_FORY_DEBUG_OUTPUT=1 mvn -T16 -pl fory-core -Dtest=org.apache.fory.resolver.MetaShareContextTest#testMetaSharedInterfaceDoesNotBuildInstantiatingSerializer,org.apache.fory.serializer.MetaShareCompatibleTest#testInterfaceFieldCompatibleMetaShare test
  • ENABLE_FORY_DEBUG_OUTPUT=1 mvn -T16 -pl fory-core -Dtest=org.apache.fory.resolver.MetaShareContextTest,org.apache.fory.serializer.MetaShareCompatibleTest test
  • mvn -T16 -pl fory-core spotless:check
  • mvn -T16 -pl fory-core checkstyle:check

@chaokunyang chaokunyang merged commit 7ce550b into apache:main May 13, 2026
55 checks passed
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.

COMPATIBLE mode + META_SHARE: JIT codec for interface field types calls Unsafe.allocateInstance and throws InstantiationException

2 participants