Search before asking
Version
Hello,
We were using apache fory 0.11.1 successfully. After updating to 0.16.0 , we no longer can serialise our complex cyclic object graph. Apache fory was chosen specifically because it had that capability.
I am reporting is as a bug because I hope the functionality can be bring back.
Component(s)
Java
Minimal reproduce step
Reproduction example is here:
https://github.com/PiotrDuz/fory-compiler-error-repro
Just please run a test.
What did you expect to see?
I want the object to be serialised and deserialised properly.
In reproduction example, test should be green.
What did you see instead?
The exception in auto-generated code:
Caused by: org.apache.fory.shaded.org.codehaus.commons.compiler.CompileException: File 'io/cashforce/ng/platformapi/data/masterdata/mdsnapshot/ReproNodeForyRefCodec_0.java', Line 387, Column 9: Assignment conversion not possible from type "java.lang.Enum" to type "io.cashforce.ng.platformapi.data.masterdata.mdsnapshot.ReproType" at org.apache.fory.shaded.org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:13228) at org.apache.fory.shaded.org.codehaus.janino.UnitCompiler.assignmentConversion(UnitCompiler.java:11445) at org.apache.fory.shaded.org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:4186) at org.apache.fory.shaded.org.codehaus.janino.UnitCompiler.access$6300(UnitCompiler.java:240) at org.apache.fory.shaded.org.codehaus.janino.UnitCompiler$13.visitAssignment(UnitCompiler.java:4143) at org.apache.fory.shaded.org.codehaus.janino.UnitCompiler$13.visitAssignment(UnitCompiler.java:4126) at org.apache.fory.shaded.org.codehaus.janino.Java$Assignment.accept(Java.java:4864) at org.apache.fory.shaded.org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:4126)
Anything Else?
I have used AI to generate simple reproducible example, as I could not attach our production code.
Please do not be repelled by some AI artefacts.
The test successfully shows the error we see in our staging environment.
Also, here is AI found root cause (which looks sound, but I am warning that haven't put much thought to review):
Root cause: The generated serializer (ReproNodeForyRefCodec_0) for a Map<ReproType, Set> field emits:
ReproType key = ((Enum) entry.getKey()); // line 387
But Enum cannot be assigned to ReproType without a cast. It should generate:
ReproType key = ((ReproType) entry.getKey());
Are you willing to submit a PR?
Search before asking
Version
Hello,
We were using apache fory 0.11.1 successfully. After updating to 0.16.0 , we no longer can serialise our complex cyclic object graph. Apache fory was chosen specifically because it had that capability.
I am reporting is as a bug because I hope the functionality can be bring back.
Component(s)
Java
Minimal reproduce step
Reproduction example is here:
https://github.com/PiotrDuz/fory-compiler-error-repro
Just please run a test.
What did you expect to see?
I want the object to be serialised and deserialised properly.
In reproduction example, test should be green.
What did you see instead?
The exception in auto-generated code:
Caused by: org.apache.fory.shaded.org.codehaus.commons.compiler.CompileException: File 'io/cashforce/ng/platformapi/data/masterdata/mdsnapshot/ReproNodeForyRefCodec_0.java', Line 387, Column 9: Assignment conversion not possible from type "java.lang.Enum" to type "io.cashforce.ng.platformapi.data.masterdata.mdsnapshot.ReproType" at org.apache.fory.shaded.org.codehaus.janino.UnitCompiler.compileError(UnitCompiler.java:13228) at org.apache.fory.shaded.org.codehaus.janino.UnitCompiler.assignmentConversion(UnitCompiler.java:11445) at org.apache.fory.shaded.org.codehaus.janino.UnitCompiler.compile2(UnitCompiler.java:4186) at org.apache.fory.shaded.org.codehaus.janino.UnitCompiler.access$6300(UnitCompiler.java:240) at org.apache.fory.shaded.org.codehaus.janino.UnitCompiler$13.visitAssignment(UnitCompiler.java:4143) at org.apache.fory.shaded.org.codehaus.janino.UnitCompiler$13.visitAssignment(UnitCompiler.java:4126) at org.apache.fory.shaded.org.codehaus.janino.Java$Assignment.accept(Java.java:4864) at org.apache.fory.shaded.org.codehaus.janino.UnitCompiler.compile(UnitCompiler.java:4126)Anything Else?
I have used AI to generate simple reproducible example, as I could not attach our production code.
Please do not be repelled by some AI artefacts.
The test successfully shows the error we see in our staging environment.
Also, here is AI found root cause (which looks sound, but I am warning that haven't put much thought to review):
Root cause: The generated serializer (ReproNodeForyRefCodec_0) for a Map<ReproType, Set> field emits:
ReproType key = ((Enum) entry.getKey()); // line 387
But Enum cannot be assigned to ReproType without a cast. It should generate:
ReproType key = ((ReproType) entry.getKey());
Are you willing to submit a PR?