Search in sources :

Example 6 with ObjectStreamClass

use of java.io.ObjectStreamClass in project j2objc by google.

the class SerializationTest method testArraySerialVersionUIDs.

// Verify that the serialVersionUID values for arrays are the same as the JVM returns.
public void testArraySerialVersionUIDs() throws Exception {
    ObjectStreamClass osc = ObjectStreamClass.lookupAny(new int[0].getClass());
    assertEquals(5600894804908749477L, osc.getSerialVersionUID());
    osc = ObjectStreamClass.lookupAny(new int[0][0].getClass());
    assertEquals(1727100010502261052L, osc.getSerialVersionUID());
    osc = ObjectStreamClass.lookupAny(new double[0].getClass());
    assertEquals(4514449696888150558L, osc.getSerialVersionUID());
    osc = ObjectStreamClass.lookupAny(new String[0].getClass());
    assertEquals(-5921575005990323385L, osc.getSerialVersionUID());
    osc = ObjectStreamClass.lookupAny(new Thread[0].getClass());
    assertEquals(-6192713741133905679L, osc.getSerialVersionUID());
}
Also used : ObjectStreamClass(java.io.ObjectStreamClass)

Example 7 with ObjectStreamClass

use of java.io.ObjectStreamClass in project j2objc by google.

the class PatternSyntaxExceptionTest method test_objectStreamField.

// Regression test for HARMONY-3787
public void test_objectStreamField() {
    ObjectStreamClass objectStreamClass = ObjectStreamClass.lookup(PatternSyntaxException.class);
    assertNotNull(objectStreamClass.getField("desc"));
}
Also used : ObjectStreamClass(java.io.ObjectStreamClass)

Example 8 with ObjectStreamClass

use of java.io.ObjectStreamClass in project j2objc by google.

the class MyObjectInputStream method test_getType_Deserialized.

/**
     * java.io.ObjectStreamField#getType()
     */
public void test_getType_Deserialized() throws IOException, ClassNotFoundException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    oos.writeObject(new SerializableObject());
    oos.close();
    baos.close();
    byte[] bytes = baos.toByteArray();
    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
    ObjectInputStream ois = new ObjectInputStream(bais);
    SerializableObject obj = (SerializableObject) ois.readObject();
    ObjectStreamClass oc = obj.getObjectStreamClass();
    ObjectStreamField field = oc.getField("i");
    assertEquals(Object.class, field.getType());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ObjectStreamField(java.io.ObjectStreamField) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) ObjectStreamClass(java.io.ObjectStreamClass) ObjectInputStream(java.io.ObjectInputStream)

Example 9 with ObjectStreamClass

use of java.io.ObjectStreamClass in project j2objc by google.

the class ObjectStreamClassTest method test_getSerialVersionUID.

/**
     * java.io.ObjectStreamClass#getSerialVersionUID()
     */
public void test_getSerialVersionUID() {
    ObjectStreamClass osc = ObjectStreamClass.lookup(DummyClass.class);
    assertTrue("getSerialversionUID returned incorrect uid: " + osc.getSerialVersionUID() + " instead of " + DummyClass.getUID(), osc.getSerialVersionUID() == DummyClass.getUID());
}
Also used : ObjectStreamClass(java.io.ObjectStreamClass)

Example 10 with ObjectStreamClass

use of java.io.ObjectStreamClass in project j2objc by google.

the class ObjectStreamClassTest method test_lookupLjava_lang_Class.

/**
     * java.io.ObjectStreamClass#lookup(java.lang.Class)
     */
public void test_lookupLjava_lang_Class() {
    ObjectStreamClass osc = ObjectStreamClass.lookup(DummyClass.class);
    assertEquals("lookup returned wrong class: " + osc.getName(), "org.apache.harmony.tests.java.io.ObjectStreamClassTest$DummyClass", osc.getName());
}
Also used : 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