Skip to content

Conversation

pjfanning
Copy link
Member

What does this PR do?

It wasn't clear from the docs how Fory handled polymorphism.
The final test fails, so I set it to be ignored. deserializeJavaObject does not work if the class you pass to it is a superclass.

Related issues

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

@pjfanning pjfanning requested a review from chaokunyang as a code owner July 4, 2025 16:05
@pjfanning pjfanning changed the title add Scala PolymorphicTest chore(Scala): add Scala PolymorphicTest Jul 4, 2025
}
"serialize/deserialize circle class (Java object format - shape hint)" ignore {
val c = Circle(5.0)
fory.deserializeJavaObject(fory.serializeJavaObject(c), classOf[Shape]) shouldEqual c
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test fails - so set to ignore

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For polymorphicc class, fory needs final class be passed. Or use serialize/deserialize app i directly

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using the plain serialize/deserialize in practice but I thought I'd try serializeJavaObject/deserializeJavaObject to see how they worked.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deserializeJavaObject needs teh exact concreate type be passed. Actually I think we can provide better error message here if wrong type is 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.

2 participants