jMonkeyEngine / jMonkeyEngine/jmonkeyengine
Specifying Serializer through @Serializable
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4.3k
- Forks
- 1.2k
- Avg merge
- 4d 7h
- Merged PRs (30d)
- 14
Description
Trying to specify the Serializer for a class annotated with @Serializable though the "serializer " attribute does not work:
The class is correctly fetched in Serializer.java:224 from the annotation, but the succeeding call to getSerializer in line 228 is forwarded through line 316 to getSerializerRegistration, effectively looking for a Serializer for the specified Serializer class. Since that class isn't registered, the method falls through to the end (failOnerror is set to false by getSerializer) and returns fieldSerializer, which is actually returned back to the original registerClass call for the annotated class.
Workaround:
specifying an instance of the desired Serializer upon registering the class:
@Serializable( serializer = MySerializer.class )
class Foo{
}
Does not work:
Serializer.registerClass( Foo.class );
Works:
Serializer.registerClass( Foo.class, new MySerializer() );
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in Serializer.java around lines 224, 228, and 316, tracing how @Serializable.serializer is passed through getSerializer and getSerializerRegistration. The fix is done when registering Foo.class honors the serializer declared by the annotation, matching the explicit Serializer.registerClass(Foo.class, new MySerializer()) workaround.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100