Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.ClassCastException while serializing a complex Java object #2085

Open
1 of 2 tasks
cquezel opened this issue Feb 28, 2025 · 0 comments
Open
1 of 2 tasks

java.lang.ClassCastException while serializing a complex Java object #2085

cquezel opened this issue Feb 28, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@cquezel
Copy link

cquezel commented Feb 28, 2025

Search before asking

  • I had searched in the issues and found no similar issues.

Version

Fury 0.10.0
Open JDK 21
Windows

Component(s)

Java

Minimal reproduce step

I am very sorry but I cannot reproduce this using a simple unit test. It is a long data import process which is ultimately serialized in a 1,2 GB object on disk. I hope the stack trace can provide a sufficient hint at the problem.

This is the Fury code

private static <T> void écrireFury(FileOutputStream fos, T objet) throws IOException {
	Fury fury = Fury.builder().withLanguage(Language.JAVA)
		.requireClassRegistration(false)
		.withRefTracking(true)
		.build();
	byte[] bytes = fury.serialize(objet);		
	fos.write(bytes);
}

To replace the Java:

private static <T> void écrireJava(FileOutputStream fos, T objet) throws FileNotFoundException, IOException {
	try (ObjectOutput oos = new ObjectOutputStream(fos)) {
		oos.writeObject(objet);
	}
}

What did you expect to see?

A successful serialization to disk.

What did you see instead?

Caused by: java.lang.ClassCastException: class myproject.modelecompletimpl.GroupeRéguliersImpl cannot be cast to class myproject.modelecompletimpl.ModuleImpl (myproject.modelecompletimpl.GroupeRéguliersImpl and myproject.modelecompletimpl.ModuleImpl are in module myproject.modelecompletimpl of loader 'app')
at myproject.modelecompletimpl.ModuleImplFuryRefCodec_0.write(ModuleImplFuryRefCodec_0.java:1743) ~[?:?]
at myproject.modelecompletimpl.NoeudsQuiFontRéférenceAuCatalogueImplFuryRefCodec_0.writeChunk$(NoeudsQuiFontRéférenceAuCatalogueImplFuryRefCodec_0.java:193) ~[?:?]
at myproject.modelecompletimpl.NoeudsQuiFontRéférenceAuCatalogueImplFuryRefCodec_0.writeFields1$(NoeudsQuiFontRéférenceAuCatalogueImplFuryRefCodec_0.java:228) ~[?:?]
at myproject.modelecompletimpl.NoeudsQuiFontRéférenceAuCatalogueImplFuryRefCodec_0.write(NoeudsQuiFontRéférenceAuCatalogueImplFuryRefCodec_0.java:463) ~[?:?]
at [email protected]/org.apache.fury.Fury.writeNonRef(Fury.java:479) ~[fury-core-0.10.0.jar:?]
at [email protected]/org.apache.fury.serializer.ArraySerializers$ObjectArraySerializer.write(ArraySerializers.java:106) ~[fury-core-0.10.0.jar:?]
at [email protected]/org.apache.fury.serializer.ArraySerializers$ObjectArraySerializer.write(ArraySerializers.java:43) ~[fury-core-0.10.0.jar:?]
... a thousand more lines

Anything Else?

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR!
@cquezel cquezel added the bug Something isn't working label Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant