urlyy commented on issue #2160:
URL: https://github.com/apache/fury/issues/2160#issuecomment-2834684666
I don't find an example in `MetaSharedCompatibleTest.class` which has
`fury.withLanguage(Language.XLANG)`, so I add this, and add
`fury.register(beanA)`, `fury.register(beanB)`, but test failed.
I don't know if it's my test code incorrect or the implementation of `XLANG
& COMPATIBLE` is incorrect.
Here is my code. Is there someone can help me?
```java
@Test
public void testWriteCompatibleCollectionSimple() throws Exception {
BeanA beanA = BeanA.createBeanA(2);
String pkg = BeanA.class.getPackage().getName();
String code =
""
+ "package "
+ pkg
+ ";\n"
+ "import java.util.*;\n"
+ "import java.math.*;\n"
+ "public class BeanA {\n"
+ " private List<Double> doubleList;\n"
+ " private Iterable<BeanB> beanBIterable;\n"
+ " private List<BeanB> beanBList;\n"
+ "}";
Class<?> cls1 =
loadClass(
BeanA.class,
code,
MetaSharedCompatibleTest.class +
"testWriteCompatibleCollectionBasic_1");
Fury fury1 =
furyBuilder()
.withCodegen(false)
.withMetaShare(true)
.withLanguage(Language.XLANG)
.withCompatibleMode(CompatibleMode.COMPATIBLE)
.withClassLoader(cls1.getClassLoader())
.build();
fury1.register(beanA.getClass(), "test.BeanA");
fury1.register(BeanB.class, "test.BeanB");
code =
""
+ "package "
+ pkg
+ ";\n"
+ "import java.util.*;\n"
+ "import java.math.*;\n"
+ "public class BeanA {\n"
+ " private List<Double> doubleList;\n"
+ " private Iterable<BeanB> beanBIterable;\n"
+ "}";
Class<?> cls2 =
loadClass(
BeanA.class,
code,
MetaSharedCompatibleTest.class +
"testWriteCompatibleCollectionBasic_2");
Object o2 = cls2.newInstance();
ReflectionUtils.unsafeCopy(beanA, o2);
Fury fury2 =
furyBuilder()
.withCodegen(false)
.withMetaShare(true)
.withLanguage(Language.XLANG)
.withCompatibleMode(CompatibleMode.COMPATIBLE)
.withClassLoader(cls2.getClassLoader())
.build();
fury2.register(beanA.getClass(), "test.BeanA");
fury2.register(BeanB.class, "test.BeanB");
MetaContext context1 = new MetaContext();
MetaContext context2 = new MetaContext();
fury1.getSerializationContext().setMetaContext(context1);
byte[] objBytes = fury1.serialize(beanA);
fury2.getSerializationContext().setMetaContext(context2);
Object obj2 = fury2.deserialize(objBytes);
Assert.assertTrue(ReflectionUtils.objectCommonFieldsEquals(obj2, o2));
}
```
--
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]