简化部分代码
parent
eaae34d491
commit
dabed0519b
|
@ -15,19 +15,9 @@ public interface JfireSE
|
||||||
byte CONTENT_TRACK = 8;
|
byte CONTENT_TRACK = 8;
|
||||||
byte CONTENT_UN_TRACK = 9;
|
byte CONTENT_UN_TRACK = 9;
|
||||||
|
|
||||||
static JfireSEConfig supportRefTracking(boolean support)
|
static JfireSEConfig config()
|
||||||
{
|
{
|
||||||
return new JfireSEConfig().setRefTracking(support);
|
return new JfireSEConfig();
|
||||||
}
|
|
||||||
|
|
||||||
static JfireSEConfig staticRegisterClass(Class<?> clazz)
|
|
||||||
{
|
|
||||||
return new JfireSEConfig().staticRegisterClass(clazz);
|
|
||||||
}
|
|
||||||
|
|
||||||
static JfireSE build()
|
|
||||||
{
|
|
||||||
return new JfireSEConfig().build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] serialize(Object instance);
|
byte[] serialize(Object instance);
|
||||||
|
|
|
@ -168,12 +168,8 @@ public class JfireSEImpl implements JfireSE
|
||||||
ClassInfo[] tmp = new ClassInfo[newLen];
|
ClassInfo[] tmp = new ClassInfo[newLen];
|
||||||
System.arraycopy(deSerializedClassInfos, 0, tmp, 0, deSerializedClassInfos.length);
|
System.arraycopy(deSerializedClassInfos, 0, tmp, 0, deSerializedClassInfos.length);
|
||||||
deSerializedClassInfos = tmp;
|
deSerializedClassInfos = tmp;
|
||||||
deSerializedClassInfos[classId] = classInfo;
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
deSerializedClassInfos[classId] = classInfo;
|
deSerializedClassInfos[classId] = classInfo;
|
||||||
}
|
|
||||||
return classInfo;
|
return classInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ public abstract class ClassInfo implements RefTracking
|
||||||
protected int refTrackingIndex = 0;
|
protected int refTrackingIndex = 0;
|
||||||
protected Serializer serializer;
|
protected Serializer serializer;
|
||||||
protected JfireSE jfireSE;
|
protected JfireSE jfireSE;
|
||||||
protected boolean needClean = false;
|
protected boolean firstSerializedOrAddTracked = true;
|
||||||
protected static final Unsafe UNSAFE = Unsafe.getUnsafe();
|
protected static final Unsafe UNSAFE = Unsafe.getUnsafe();
|
||||||
|
|
||||||
public ClassInfo(short classId, Class<?> clazz, boolean refTrack)
|
public ClassInfo(short classId, Class<?> clazz, boolean refTrack)
|
||||||
|
@ -64,7 +64,7 @@ public abstract class ClassInfo implements RefTracking
|
||||||
}
|
}
|
||||||
refTrackingIndex = 0;
|
refTrackingIndex = 0;
|
||||||
}
|
}
|
||||||
needClean = false;
|
firstSerializedOrAddTracked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -114,9 +114,9 @@ public abstract class ClassInfo implements RefTracking
|
||||||
public Object readWithTrack(ByteArray byteArray)
|
public Object readWithTrack(ByteArray byteArray)
|
||||||
{
|
{
|
||||||
Object result = serializer.read(byteArray, this);
|
Object result = serializer.read(byteArray, this);
|
||||||
if (!needClean)
|
if (firstSerializedOrAddTracked)
|
||||||
{
|
{
|
||||||
needClean = true;
|
firstSerializedOrAddTracked = false;
|
||||||
jfireSE.scheduleForClean(this);
|
jfireSE.scheduleForClean(this);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -22,8 +22,7 @@ public class DynamicClassInfo extends ClassInfo
|
||||||
@Override
|
@Override
|
||||||
public void write(ByteArray byteArray, Object instance)
|
public void write(ByteArray byteArray, Object instance)
|
||||||
{
|
{
|
||||||
//如果needClean 为 false,意味着这个 classInfo 是首次输出。后续必然需要清理。
|
if (firstSerializedOrAddTracked)
|
||||||
if (!needClean)
|
|
||||||
{
|
{
|
||||||
if (refTrack)
|
if (refTrack)
|
||||||
{
|
{
|
||||||
|
@ -33,7 +32,7 @@ public class DynamicClassInfo extends ClassInfo
|
||||||
byteArray.writeString(classNameStringBytes, classNameStringCoder);
|
byteArray.writeString(classNameStringBytes, classNameStringCoder);
|
||||||
byteArray.writePositiveVarInt(classId);
|
byteArray.writePositiveVarInt(classId);
|
||||||
serializer.writeBytes(byteArray, instance);
|
serializer.writeBytes(byteArray, instance);
|
||||||
needClean = true;
|
firstSerializedOrAddTracked = false;
|
||||||
jfireSE.scheduleForClean(this);
|
jfireSE.scheduleForClean(this);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -31,9 +31,9 @@ public class RegisterClasInfo extends ClassInfo
|
||||||
byteArray.writePositiveVarInt(classId);
|
byteArray.writePositiveVarInt(classId);
|
||||||
byteArray.writePositiveVarInt(i);
|
byteArray.writePositiveVarInt(i);
|
||||||
}
|
}
|
||||||
if (!needClean)
|
if (firstSerializedOrAddTracked)
|
||||||
{
|
{
|
||||||
needClean = true;
|
firstSerializedOrAddTracked = false;
|
||||||
jfireSE.scheduleForClean(this);
|
jfireSE.scheduleForClean(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -472,14 +472,15 @@ public class ObjectSerializer implements Serializer
|
||||||
writeBody.append("else{\r\n");
|
writeBody.append("else{\r\n");
|
||||||
String objClassName = "objClass_$_" + fieldIndex;
|
String objClassName = "objClass_$_" + fieldIndex;
|
||||||
writeBody.append("Class ").append(objClassName).append(" = ").append(objName).append(".getClass();\r\n");
|
writeBody.append("Class ").append(objClassName).append(" = ").append(objName).append(".getClass();\r\n");
|
||||||
writeBody.append("classInfo = classInfo.getClazz() == objClass ? classInfo : jfireSE.getOrCreateClassInfo(objClass);".replace("objClass", objClassName) //
|
writeBody.append("""
|
||||||
.replace("classInfo", classInfoProperty));
|
if (firstClassInfo.getClazz() == objClass)
|
||||||
writeBody.append("if(").append(classInfoProperty).append("==").append(firstClassInfoProperty).append("){\r\n");
|
{
|
||||||
writeBody.append(classInfoProperty).append(".writeKnownClazz(byteArray,").append(objName).append(");\r\n");
|
firstClassInfo.writeKnownClazz(byteArray, $obj$);
|
||||||
writeBody.append("}\r\n");
|
}
|
||||||
writeBody.append("else{\r\n");
|
else
|
||||||
writeBody.append(classInfoProperty).append(".write(byteArray,").append(objName).append(");\r\n");
|
{
|
||||||
writeBody.append("}\r\n");
|
jfireSE.getOrCreateClassInfo(objClass).write(byteArray, $obj$);
|
||||||
|
}""".replace("firstClassInfo", firstClassInfoProperty).replace("objClass", objClassName).replace("$obj$", objName));
|
||||||
writeBody.append("}\r\n");
|
writeBody.append("}\r\n");
|
||||||
String flagName = "flag_$_" + fieldIndex;
|
String flagName = "flag_$_" + fieldIndex;
|
||||||
readBody.append("byte ").append(flagName).append(" = byteArray.get();\r\n");
|
readBody.append("byte ").append(flagName).append(" = byteArray.get();\r\n");
|
||||||
|
|
|
@ -43,14 +43,13 @@ public class VariableFieldInfo extends FieldInfo
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Class<?> objClass = obj.getClass();
|
Class<?> objClass = obj.getClass();
|
||||||
classInfo = classInfo.getClazz() == objClass ? classInfo : jfireSE.getOrCreateClassInfo(objClass);
|
if (firstClassInfo.getClazz() == objClass)
|
||||||
if (classInfo == firstClassInfo)
|
|
||||||
{
|
{
|
||||||
classInfo.writeKnownClazz(byteArray, obj);
|
firstClassInfo.writeKnownClazz(byteArray, obj);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
classInfo.write(byteArray, obj);
|
jfireSE.getOrCreateClassInfo(objClass).write(byteArray, obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class BenchMarkRead
|
||||||
Fury fury = Fury.builder().withLanguage(Language.JAVA)//
|
Fury fury = Fury.builder().withLanguage(Language.JAVA)//
|
||||||
.requireClassRegistration(false)//
|
.requireClassRegistration(false)//
|
||||||
.withRefTracking(true).build();
|
.withRefTracking(true).build();
|
||||||
JfireSE jfireSE = JfireSE.supportRefTracking(true).build();
|
JfireSE jfireSE = JfireSE.config().refTracking().build();
|
||||||
TestData data = new TestData().setTestDataSm(new TestDataSm()).setTestDataSm2(new TestDataSm2());
|
TestData data = new TestData().setTestDataSm(new TestDataSm()).setTestDataSm2(new TestDataSm2());
|
||||||
byte[] serialize = jfireSE.serialize(data);
|
byte[] serialize = jfireSE.serialize(data);
|
||||||
byte[] serialize2 = fury.serialize(data);
|
byte[] serialize2 = fury.serialize(data);
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class BenchMarkWrite
|
||||||
Fury fury = Fury.builder().withLanguage(Language.JAVA)//
|
Fury fury = Fury.builder().withLanguage(Language.JAVA)//
|
||||||
.requireClassRegistration(false)//
|
.requireClassRegistration(false)//
|
||||||
.withRefTracking(true).build();
|
.withRefTracking(true).build();
|
||||||
JfireSE jfireSE = JfireSE.supportRefTracking(true).build();
|
JfireSE jfireSE = JfireSE.config().refTracking().build();
|
||||||
|
|
||||||
public void testFSENoCompile()
|
public void testFSENoCompile()
|
||||||
{
|
{
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class FunctionTest
|
||||||
TestDataSm[] sms = new TestDataSm[2];
|
TestDataSm[] sms = new TestDataSm[2];
|
||||||
sms[0] = new TestDataSm().setC("xx");
|
sms[0] = new TestDataSm().setC("xx");
|
||||||
testData.setSms(sms);
|
testData.setSms(sms);
|
||||||
JfireSE jfireSE = JfireSE.build();
|
JfireSE jfireSE = JfireSE.config().build();
|
||||||
byte[] bytes = jfireSE.serialize(testData);
|
byte[] bytes = jfireSE.serialize(testData);
|
||||||
Assert.assertEquals(testData, jfireSE.deSerialize(bytes));
|
Assert.assertEquals(testData, jfireSE.deSerialize(bytes));
|
||||||
TestData read = (TestData) jfireSE.deSerialize(bytes);
|
TestData read = (TestData) jfireSE.deSerialize(bytes);
|
||||||
|
@ -53,7 +53,7 @@ public class FunctionTest
|
||||||
home.setPerson(person);
|
home.setPerson(person);
|
||||||
person.setHome(home);
|
person.setHome(home);
|
||||||
fury.serialize(home);
|
fury.serialize(home);
|
||||||
JfireSE jfireSE = JfireSE.supportRefTracking(true).build();
|
JfireSE jfireSE = JfireSE.config().refTracking().build();
|
||||||
jfireSE.serialize(home);
|
jfireSE.serialize(home);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.junit.Test;
|
||||||
|
|
||||||
public class Profile
|
public class Profile
|
||||||
{
|
{
|
||||||
JfireSE jfireSE = JfireSE.supportRefTracking(true).build();
|
JfireSE jfireSE = JfireSE.config().refTracking().build();
|
||||||
TestData data = new TestData().setTestDataSm(new TestDataSm()).setTestDataSm2(new TestDataSm2());
|
TestData data = new TestData().setTestDataSm(new TestDataSm()).setTestDataSm2(new TestDataSm2());
|
||||||
byte[] serialize = jfireSE.serialize(data);
|
byte[] serialize = jfireSE.serialize(data);
|
||||||
Object unuse = jfireSE.deSerialize(serialize);
|
Object unuse = jfireSE.deSerialize(serialize);
|
||||||
|
@ -15,7 +15,7 @@ public class Profile
|
||||||
@Test
|
@Test
|
||||||
public void test()
|
public void test()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 10000000; i++)
|
for (int i = 0; i < 30000000; i++)
|
||||||
{
|
{
|
||||||
jfireSE.deSerialize(serialize);
|
jfireSE.deSerialize(serialize);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ public class BaseTest
|
||||||
@Test
|
@Test
|
||||||
public void test()
|
public void test()
|
||||||
{
|
{
|
||||||
JfireSE jfireSE = JfireSE.supportRefTracking(true).build();
|
JfireSE jfireSE = JfireSE.config().refTracking().build();
|
||||||
User user = new User();
|
User user = new User();
|
||||||
user.setAge(123);
|
user.setAge(123);
|
||||||
user.setName("aaa");
|
user.setName("aaa");
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class LongTest
|
||||||
kryo.writeClassAndObject(output, new LongData());
|
kryo.writeClassAndObject(output, new LongData());
|
||||||
byte[] bb = output.toBytes();
|
byte[] bb = output.toBytes();
|
||||||
System.out.println("LongData序列化:kryo基础数据长度:" + bb.length);
|
System.out.println("LongData序列化:kryo基础数据长度:" + bb.length);
|
||||||
JfireSE jfireSE = JfireSE.supportRefTracking(true).build();
|
JfireSE jfireSE = JfireSE.config().refTracking().build();
|
||||||
byte[] serialize = jfireSE.serialize(new LongData());
|
byte[] serialize = jfireSE.serialize(new LongData());
|
||||||
System.out.println("LongData序列化:jfirese基础数据长度:" + serialize.length);
|
System.out.println("LongData序列化:jfirese基础数据长度:" + serialize.length);
|
||||||
System.out.println("序列化长度减少" + (bb.length - serialize.length));
|
System.out.println("序列化长度减少" + (bb.length - serialize.length));
|
||||||
|
@ -35,5 +35,4 @@ public class LongTest
|
||||||
log.info("basedata序列化:jfirese基础数据长度:" + serialize1.length);
|
log.info("basedata序列化:jfirese基础数据长度:" + serialize1.length);
|
||||||
log.info("序列化长度减少{}", (bb.length - serialize1.length));
|
log.info("序列化长度减少{}", (bb.length - serialize1.length));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ public class MapTest
|
||||||
{
|
{
|
||||||
MapDemo demo = new MapDemo();
|
MapDemo demo = new MapDemo();
|
||||||
demo.getMap().put(1, new BaseData());
|
demo.getMap().put(1, new BaseData());
|
||||||
JfireSE jfireSE = JfireSE.staticRegisterClass(MapDemo.class).refTracking().build();
|
JfireSE jfireSE = JfireSE.config().staticRegisterClass(MapDemo.class).refTracking().build();
|
||||||
byte[] serialize = jfireSE.serialize(demo);
|
byte[] serialize = jfireSE.serialize(demo);
|
||||||
jfireSE.deSerialize(serialize);
|
jfireSE.deSerialize(serialize);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ public class RightTest
|
||||||
{
|
{
|
||||||
// 创建需要序列化的对象
|
// 创建需要序列化的对象
|
||||||
BaseData baseData = new BaseData(1);
|
BaseData baseData = new BaseData(1);
|
||||||
JfireSE jfireSE = JfireSE.supportRefTracking(true).staticRegisterClass(baseData.getClass()).build();
|
JfireSE jfireSE = JfireSE.config().refTracking().staticRegisterClass(baseData.getClass()).build();
|
||||||
byte[] serialize = jfireSE.serialize(baseData);
|
byte[] serialize = jfireSE.serialize(baseData);
|
||||||
// 传入二进制buffer对象,读取其中的 数据并且反序列化成对象
|
// 传入二进制buffer对象,读取其中的 数据并且反序列化成对象
|
||||||
BaseData result = (BaseData) jfireSE.deSerialize(serialize);
|
BaseData result = (BaseData) jfireSE.deSerialize(serialize);
|
||||||
|
@ -76,7 +76,7 @@ public class RightTest
|
||||||
public void wrapTest() throws IllegalArgumentException, IllegalAccessException, UnsupportedEncodingException, ClassNotFoundException, InstantiationException
|
public void wrapTest() throws IllegalArgumentException, IllegalAccessException, UnsupportedEncodingException, ClassNotFoundException, InstantiationException
|
||||||
{
|
{
|
||||||
WrapData wrapData = new WrapData();
|
WrapData wrapData = new WrapData();
|
||||||
JfireSE jfireSE = JfireSE.supportRefTracking(true).staticRegisterClass(WrapData.class).build();
|
JfireSE jfireSE = JfireSE.config().refTracking().staticRegisterClass(WrapData.class).build();
|
||||||
byte[] serialize = jfireSE.serialize(wrapData);
|
byte[] serialize = jfireSE.serialize(wrapData);
|
||||||
WrapData result = (WrapData) jfireSE.deSerialize(serialize);
|
WrapData result = (WrapData) jfireSE.deSerialize(serialize);
|
||||||
assertEquals(result.getA(), wrapData.getA());
|
assertEquals(result.getA(), wrapData.getA());
|
||||||
|
@ -150,7 +150,7 @@ public class RightTest
|
||||||
Person tPerson = new Person("zhangshi[in", 30);
|
Person tPerson = new Person("zhangshi[in", 30);
|
||||||
person.setLeader(tPerson);
|
person.setLeader(tPerson);
|
||||||
tPerson.setLeader(person);
|
tPerson.setLeader(person);
|
||||||
JfireSE jfireSE = JfireSE.supportRefTracking(true).build();
|
JfireSE jfireSE = JfireSE.config().refTracking().build();
|
||||||
byte[] serialize = jfireSE.serialize(person);
|
byte[] serialize = jfireSE.serialize(person);
|
||||||
Person result = (Person) jfireSE.deSerialize(serialize);
|
Person result = (Person) jfireSE.deSerialize(serialize);
|
||||||
assertEquals("zhangshi[in", result.getLeader().getName());
|
assertEquals("zhangshi[in", result.getLeader().getName());
|
||||||
|
@ -159,7 +159,7 @@ public class RightTest
|
||||||
@Test
|
@Test
|
||||||
public void objectTest() throws IllegalArgumentException, IllegalAccessException, ClassNotFoundException, InstantiationException
|
public void objectTest() throws IllegalArgumentException, IllegalAccessException, ClassNotFoundException, InstantiationException
|
||||||
{
|
{
|
||||||
JfireSE jfireSE = JfireSE.supportRefTracking(true).build();
|
JfireSE jfireSE = JfireSE.config().refTracking().build();
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
byte[] serialize = jfireSE.serialize(calendar);
|
byte[] serialize = jfireSE.serialize(calendar);
|
||||||
Calendar reCalendar = (Calendar) jfireSE.deSerialize(serialize);
|
Calendar reCalendar = (Calendar) jfireSE.deSerialize(serialize);
|
||||||
|
@ -175,7 +175,7 @@ public class RightTest
|
||||||
{
|
{
|
||||||
list.add(new BaseData(i));
|
list.add(new BaseData(i));
|
||||||
}
|
}
|
||||||
JfireSE jfireSE = JfireSE.supportRefTracking(true).build();
|
JfireSE jfireSE = JfireSE.config().refTracking().build();
|
||||||
byte[] serialize = jfireSE.serialize(list);
|
byte[] serialize = jfireSE.serialize(list);
|
||||||
ArrayList<BaseData> result = (ArrayList<BaseData>) jfireSE.deSerialize(serialize);
|
ArrayList<BaseData> result = (ArrayList<BaseData>) jfireSE.deSerialize(serialize);
|
||||||
Assert.assertTrue(list.equals(result));
|
Assert.assertTrue(list.equals(result));
|
||||||
|
@ -184,7 +184,7 @@ public class RightTest
|
||||||
@Test
|
@Test
|
||||||
public void baseDataTest()
|
public void baseDataTest()
|
||||||
{
|
{
|
||||||
JfireSE jfireSE = JfireSE.supportRefTracking(true).build();
|
JfireSE jfireSE = JfireSE.config().refTracking().build();
|
||||||
BaseData baseData = new BaseData();
|
BaseData baseData = new BaseData();
|
||||||
byte[] serialize = jfireSE.serialize(baseData);
|
byte[] serialize = jfireSE.serialize(baseData);
|
||||||
BaseData result = (BaseData) jfireSE.deSerialize(serialize);
|
BaseData result = (BaseData) jfireSE.deSerialize(serialize);
|
||||||
|
@ -199,7 +199,7 @@ public class RightTest
|
||||||
array[1] = new BaseData();
|
array[1] = new BaseData();
|
||||||
array[2] = new LongData();
|
array[2] = new LongData();
|
||||||
array[3] = new WrapData();
|
array[3] = new WrapData();
|
||||||
JfireSE jfireSE = JfireSE.supportRefTracking(true).build();
|
JfireSE jfireSE = JfireSE.config().refTracking().build();
|
||||||
byte[] serialize = jfireSE.serialize(array);
|
byte[] serialize = jfireSE.serialize(array);
|
||||||
Object[] result = (Object[]) jfireSE.deSerialize(serialize);
|
Object[] result = (Object[]) jfireSE.deSerialize(serialize);
|
||||||
Assert.assertTrue(((Person) result[0]).equals(array[0]));
|
Assert.assertTrue(((Person) result[0]).equals(array[0]));
|
||||||
|
@ -209,7 +209,7 @@ public class RightTest
|
||||||
public void byteArrayTest()
|
public void byteArrayTest()
|
||||||
{
|
{
|
||||||
byte[] array = new byte[]{1, 2, 5, 6, 8, 9};
|
byte[] array = new byte[]{1, 2, 5, 6, 8, 9};
|
||||||
JfireSE jfireSE = JfireSE.supportRefTracking(true).build();
|
JfireSE jfireSE = JfireSE.config().refTracking().build();
|
||||||
byte[] serialize = jfireSE.serialize(array);
|
byte[] serialize = jfireSE.serialize(array);
|
||||||
byte[] result = (byte[]) jfireSE.deSerialize(serialize);
|
byte[] result = (byte[]) jfireSE.deSerialize(serialize);
|
||||||
for (int i = 0; i < array.length; i++)
|
for (int i = 0; i < array.length; i++)
|
||||||
|
@ -222,7 +222,7 @@ public class RightTest
|
||||||
public void booleanArrayTest()
|
public void booleanArrayTest()
|
||||||
{
|
{
|
||||||
boolean[] array = new boolean[]{true, false, false, true, true, true};
|
boolean[] array = new boolean[]{true, false, false, true, true, true};
|
||||||
JfireSE jfireSE = JfireSE.supportRefTracking(true).build();
|
JfireSE jfireSE = JfireSE.config().refTracking().build();
|
||||||
byte[] serialize = jfireSE.serialize(array);
|
byte[] serialize = jfireSE.serialize(array);
|
||||||
boolean[] result = (boolean[]) jfireSE.deSerialize(serialize);
|
boolean[] result = (boolean[]) jfireSE.deSerialize(serialize);
|
||||||
for (int i = 0; i < array.length; i++)
|
for (int i = 0; i < array.length; i++)
|
||||||
|
@ -234,7 +234,7 @@ public class RightTest
|
||||||
@Test
|
@Test
|
||||||
public void arrayDataTest()
|
public void arrayDataTest()
|
||||||
{
|
{
|
||||||
JfireSE jfireSE = JfireSE.supportRefTracking(true).build();
|
JfireSE jfireSE = JfireSE.config().refTracking().build();
|
||||||
byte[] serialize = jfireSE.serialize(new ArrayData());
|
byte[] serialize = jfireSE.serialize(new ArrayData());
|
||||||
jfireSE.deSerialize(serialize);
|
jfireSE.deSerialize(serialize);
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ public class RightTest
|
||||||
byte[] key = new byte[16];
|
byte[] key = new byte[16];
|
||||||
random.nextBytes(key);
|
random.nextBytes(key);
|
||||||
Object[] data = new Object[]{Integer.valueOf(14), new BaseData[]{new BaseData(), new BaseData()}};
|
Object[] data = new Object[]{Integer.valueOf(14), new BaseData[]{new BaseData(), new BaseData()}};
|
||||||
JfireSE jfireSE = JfireSE.supportRefTracking(true).build();
|
JfireSE jfireSE = JfireSE.config().refTracking().build();
|
||||||
byte[] serialize = jfireSE.serialize(data);
|
byte[] serialize = jfireSE.serialize(data);
|
||||||
Object[] result = (Object[]) jfireSE.deSerialize(serialize);
|
Object[] result = (Object[]) jfireSE.deSerialize(serialize);
|
||||||
assertEquals(14, result[0]);
|
assertEquals(14, result[0]);
|
||||||
|
@ -261,7 +261,7 @@ public class RightTest
|
||||||
public void arryaNotRegisterClassSeri()
|
public void arryaNotRegisterClassSeri()
|
||||||
{
|
{
|
||||||
ArrayRefenceHolder holder = new ArrayRefenceHolder();
|
ArrayRefenceHolder holder = new ArrayRefenceHolder();
|
||||||
JfireSE jfireSE = JfireSE.supportRefTracking(true).build();
|
JfireSE jfireSE = JfireSE.config().refTracking().build();
|
||||||
byte[] serialize = jfireSE.serialize(holder);
|
byte[] serialize = jfireSE.serialize(holder);
|
||||||
ArrayRefenceHolder result = (ArrayRefenceHolder) jfireSE.deSerialize(serialize);
|
ArrayRefenceHolder result = (ArrayRefenceHolder) jfireSE.deSerialize(serialize);
|
||||||
assertArrayEquals(new int[]{1, 2}, result.getA()[0]);
|
assertArrayEquals(new int[]{1, 2}, result.getA()[0]);
|
||||||
|
@ -274,7 +274,7 @@ public class RightTest
|
||||||
public void methodObjectTest() throws NoSuchMethodException
|
public void methodObjectTest() throws NoSuchMethodException
|
||||||
{
|
{
|
||||||
Method methodObjectTest = this.getClass().getDeclaredMethod("methodObjectTest");
|
Method methodObjectTest = this.getClass().getDeclaredMethod("methodObjectTest");
|
||||||
JfireSE jfireSE = JfireSE.supportRefTracking(true).build();
|
JfireSE jfireSE = JfireSE.config().refTracking().build();
|
||||||
byte[] serialize = jfireSE.serialize(methodObjectTest);
|
byte[] serialize = jfireSE.serialize(methodObjectTest);
|
||||||
Method method = (Method) jfireSE.deSerialize(serialize);
|
Method method = (Method) jfireSE.deSerialize(serialize);
|
||||||
System.out.println(method.equals(methodObjectTest));
|
System.out.println(method.equals(methodObjectTest));
|
||||||
|
|
Loading…
Reference in New Issue