liulianggml-cmyk opened a new issue, #3836:
URL: https://github.com/apache/fory/issues/3836
### Question
In XLANG mode, serializing any object whose fields are declared in a
(abstract) parent class fails. With codegen enabled: NPE in
sun.misc.Unsafe.objectFieldOffset via CodecBuilder.fieldOffsetExpr (wrapped in
"Create sequential serializer failed"). With withCodegen(false):
NullPointerException: Cannot invoke "FieldAccessor.getObject(Object)" because
"fieldInfo.fieldAccessor" is null at
ObjectSerializer.writeFieldByCodecCategory. Field visibility
(public/protected/private) makes no difference. The same classes serialize fine
in JAVA mode.
Minimal repro:
public class Repro {
public static abstract class Parent {
public Map<String, BigDecimal> m = new ConcurrentHashMap<>();
}
public static class Child extends Parent {}
public static void main(String[] a) {
Fory f = Fory.builder().withLanguage(Language.XLANG)
.withRefTracking(true).withCodegen(false).build();
f.register(Child.class, "t.Child");
Child c = new Child();
c.m.put("a", BigDecimal.ONE);
f.deserialize(f.serialize(c)); // NPE here
}
}
A class with the identical field declared on itself (no inheritance) works.
The xlang guide does not document inheritance as unsupported, so either this
should work (flattening superclass fields into the struct) or the limitation
should be documented and a clear error raised at register() time instead of
an NPE at serialize time.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]