Skip to content

Package private and private records cannot be deserialized #849

@theigl

Description

@theigl

Describe the bug
While testing #847 I noticed that package private records cannot be deserialized.

To Reproduce

    static record PackagePrivateRecord(int i, String s) {}
    
    @Test
    void testNonPublicRecords() {
        kryo.register(PackagePrivateRecord.class);

        roundTrip(4, new PackagePrivateRecord(1, "s1"));
    }

This fails with:

Caused by: java.lang.NoSuchMethodException: com.esotericsoftware.kryo.serializers.RecordSerializerTest$PackagePrivateRecord.<init>(int,java.lang.String)
	at java.base/java.lang.Class.getConstructor0(Class.java:3517)
	at java.base/java.lang.Class.getConstructor(Class.java:2238)
	at com.esotericsoftware.kryo.serializers.RecordSerializer.invokeCanonicalConstructor(RecordSerializer.java:224)
	... 70 more

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions