use of java.io.ObjectStreamClass in project j2objc by google.
the class ObjectStreamClassTest method test_getFields.
/**
* java.io.ObjectStreamClass#getFields()
*/
public void test_getFields() {
ObjectStreamClass osc = ObjectStreamClass.lookup(DummyClass.class);
ObjectStreamField[] osfArray = osc.getFields();
assertTrue("Array of fields should be of length 2 but is instead of length: " + osfArray.length, osfArray.length == 2);
}
use of java.io.ObjectStreamClass in project j2objc by google.
the class ObjectStreamClassTest method test_getFieldLjava_lang_String.
/**
* java.io.ObjectStreamClass#getField(java.lang.String)
*/
public void test_getFieldLjava_lang_String() {
ObjectStreamClass osc = ObjectStreamClass.lookup(DummyClass.class);
assertEquals("getField did not return correct field", 'J', osc.getField("bam").getTypeCode());
assertNull("getField did not null for non-existent field", osc.getField("wham"));
}
use of java.io.ObjectStreamClass in project j2objc by google.
the class SerializationTest method testSerializeFieldMadeTransient.
// http://b/4471249
public void testSerializeFieldMadeTransient() throws Exception {
// Does ObjectStreamClass have the right idea?
ObjectStreamClass osc = ObjectStreamClass.lookup(FieldMadeTransient.class);
ObjectStreamField[] fields = osc.getFields();
assertEquals(1, fields.length);
assertEquals("nonTransientInt", fields[0].getName());
assertEquals(int.class, fields[0].getType());
// this was created by serializing a FieldMadeTransient with a non-0 transientInt
String s = "aced0005737200346c6962636f72652e6a6176612e696f2e53657269616c697a6174696f6e54657" + "374244669656c644d6164655472616e7369656e74000000000000000002000149000c7472616e736" + "9656e74496e747870abababab";
FieldMadeTransient deserialized = (FieldMadeTransient) SerializationTester.deserializeHex(s);
assertEquals(0, deserialized.transientInt);
}
use of java.io.ObjectStreamClass in project gradle by gradle.
the class PayloadSerializerObjectInputStream method readClassDescriptor.
@Override
protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
Class<?> aClass = readClass();
ObjectStreamClass descriptor = ObjectStreamClass.lookupAny(aClass);
if (descriptor == null) {
throw new ClassNotFoundException(aClass.getName());
}
return descriptor;
}
use of java.io.ObjectStreamClass in project neo4j by neo4j.
the class LenientObjectInputStream method readClassDescriptor.
@Override
protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException {
ObjectStreamClass wireClassDescriptor = super.readClassDescriptor();
if (!versionMapper.hasMappingFor(wireClassDescriptor.getName())) {
versionMapper.addMappingFor(wireClassDescriptor.getName(), wireClassDescriptor.getSerialVersionUID());
}
// the class in the local JVM that this descriptor represents.
Class localClass;
try {
localClass = Class.forName(wireClassDescriptor.getName());
} catch (ClassNotFoundException e) {
return wireClassDescriptor;
}
ObjectStreamClass localClassDescriptor = ObjectStreamClass.lookup(localClass);
if (localClassDescriptor != null) {
final long localSUID = localClassDescriptor.getSerialVersionUID();
final long wireSUID = wireClassDescriptor.getSerialVersionUID();
if (wireSUID != localSUID) {
wireClassDescriptor = localClassDescriptor;
}
}
return wireClassDescriptor;
}
Aggregations