Search in sources :

Example 21 with ObjectStreamClass

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);
}
Also used : ObjectStreamField(java.io.ObjectStreamField) ObjectStreamClass(java.io.ObjectStreamClass)

Example 22 with ObjectStreamClass

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"));
}
Also used : ObjectStreamClass(java.io.ObjectStreamClass)

Example 23 with ObjectStreamClass

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);
}
Also used : ObjectStreamField(java.io.ObjectStreamField) ObjectStreamClass(java.io.ObjectStreamClass)

Example 24 with ObjectStreamClass

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;
}
Also used : ObjectStreamClass(java.io.ObjectStreamClass)

Example 25 with ObjectStreamClass

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;
}
Also used : ObjectStreamClass(java.io.ObjectStreamClass) ObjectStreamClass(java.io.ObjectStreamClass)

Aggregations

ObjectStreamClass (java.io.ObjectStreamClass)40 ObjectInputStream (java.io.ObjectInputStream)14 ByteArrayInputStream (java.io.ByteArrayInputStream)13 IOException (java.io.IOException)11 ObjectOutputStream (java.io.ObjectOutputStream)8 ObjectStreamField (java.io.ObjectStreamField)6 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 Serializable (java.io.Serializable)5 DataInputStream (java.io.DataInputStream)1 EOFException (java.io.EOFException)1 InputStream (java.io.InputStream)1 PipedInputStream (java.io.PipedInputStream)1 PipedOutputStream (java.io.PipedOutputStream)1 StreamCorruptedException (java.io.StreamCorruptedException)1 BufferUnderflowException (java.nio.BufferUnderflowException)1 SerializationException (krati.io.SerializationException)1 FSDataInputStream (org.apache.hadoop.fs.FSDataInputStream)1 FSDataOutputStream (org.apache.hadoop.fs.FSDataOutputStream)1 FileContext (org.apache.hadoop.fs.FileContext)1 Path (org.apache.hadoop.fs.Path)1