Search in sources :

Example 1 with ObjectStreamClass

use of java.io.ObjectStreamClass in project jdk8u_jdk by JetBrains.

the class ProxyClassDesc method run.

/**
     * Write and read proxy class descriptors to/from a stream.
     * Arguments: <# cycles>
     */
public long run(String[] args) throws Exception {
    int ncycles = Integer.parseInt(args[0]);
    StreamBuffer sbuf = new StreamBuffer();
    ObjectOutputStream oout = new ObjectOutputStream(sbuf.getOutputStream());
    ObjectInputStream oin = new ObjectInputStream(sbuf.getInputStream());
    ObjectStreamClass[] descs = genDescs();
    // warmup
    doReps(oout, oin, sbuf, descs, 1);
    long start = System.currentTimeMillis();
    doReps(oout, oin, sbuf, descs, ncycles);
    return System.currentTimeMillis() - start;
}
Also used : ObjectOutputStream(java.io.ObjectOutputStream) ObjectStreamClass(java.io.ObjectStreamClass) ObjectInputStream(java.io.ObjectInputStream)

Example 2 with ObjectStreamClass

use of java.io.ObjectStreamClass in project jdk8u_jdk by JetBrains.

the class ProxyClassDesc method genDescs.

/**
     * Generate proxy class descriptors.
     */
ObjectStreamClass[] genDescs() {
    ClassLoader ldr = ProxyClassDesc.class.getClassLoader();
    Class[] ifaces = new Class[3];
    Class[] a = new Class[] { A1.class, A2.class, A3.class, A4.class, A5.class };
    Class[] b = new Class[] { B1.class, B2.class, B3.class, B4.class, B5.class };
    Class[] c = new Class[] { C1.class, C2.class, C3.class, C4.class, C5.class };
    ObjectStreamClass[] descs = new ObjectStreamClass[a.length * b.length * c.length];
    int n = 0;
    for (int i = 0; i < a.length; i++) {
        ifaces[0] = a[i];
        for (int j = 0; j < b.length; j++) {
            ifaces[1] = b[j];
            for (int k = 0; k < c.length; k++) {
                ifaces[2] = c[k];
                Class proxyClass = Proxy.getProxyClass(ldr, ifaces);
                descs[n++] = ObjectStreamClass.lookup(proxyClass);
            }
        }
    }
    return descs;
}
Also used : ObjectStreamClass(java.io.ObjectStreamClass) ObjectStreamClass(java.io.ObjectStreamClass)

Example 3 with ObjectStreamClass

use of java.io.ObjectStreamClass in project robovm by robovm.

the class Test method test_readObject_replacedClassDescriptor.

// Regression test for HARMONY-4996
public void test_readObject_replacedClassDescriptor() throws Exception {
    ObjectStreamClass[] objs = new ObjectStreamClass[1000];
    PipedOutputStream pout = new PipedOutputStream();
    PipedInputStream pin = new PipedInputStream(pout);
    ObjectOutputStream oout = new TestObjectOutputStream(pout, objs);
    oout.writeObject(new TestExtObject());
    oout.writeObject("test");
    oout.close();
    ObjectInputStream oin = new TestObjectInputStream(pin, objs);
    oin.readObject();
    oin.readObject();
}
Also used : PipedOutputStream(java.io.PipedOutputStream) PipedInputStream(java.io.PipedInputStream) ObjectOutputStream(java.io.ObjectOutputStream) ObjectStreamClass(java.io.ObjectStreamClass) ObjectInputStream(java.io.ObjectInputStream)

Example 4 with ObjectStreamClass

use of java.io.ObjectStreamClass in project robovm by robovm.

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 5 with ObjectStreamClass

use of java.io.ObjectStreamClass in project robovm by robovm.

the class Test method test_readClassDescriptor.

public void test_readClassDescriptor() throws IOException, ClassNotFoundException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStreamWithWriteDesc1 oos = new ObjectOutputStreamWithWriteDesc1(baos);
    ObjectStreamClass desc = ObjectStreamClass.lookup(TestClassForSerialization.class);
    oos.writeClassDescriptor(desc);
    oos.close();
    byte[] bytes = baos.toByteArray();
    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
    ObjectIutputStreamWithReadDesc1 ois = new ObjectIutputStreamWithReadDesc1(bais);
    Object obj = ois.readClassDescriptor();
    ois.close();
    assertEquals(desc.getClass(), obj.getClass());
    //eof
    bais = new ByteArrayInputStream(bytes);
    ExceptionalBufferedInputStream bis = new ExceptionalBufferedInputStream(bais);
    ois = new ObjectIutputStreamWithReadDesc1(bis);
    bis.setEOF(true);
    try {
        obj = ois.readClassDescriptor();
    } catch (IOException e) {
    //e.printStackTrace();
    } finally {
        ois.close();
    }
    //throw exception
    bais = new ByteArrayInputStream(bytes);
    bis = new ExceptionalBufferedInputStream(bais);
    ois = new ObjectIutputStreamWithReadDesc1(bis);
    bis.setException(new IOException());
    try {
        obj = ois.readClassDescriptor();
    } catch (IOException e) {
    //e.printStackTrace();
    } finally {
        ois.close();
    }
    //corrupt
    bais = new ByteArrayInputStream(bytes);
    bis = new ExceptionalBufferedInputStream(bais);
    ois = new ObjectIutputStreamWithReadDesc1(bis);
    bis.setCorrupt(true);
    try {
        obj = ois.readClassDescriptor();
    } catch (IOException e) {
    //e.printStackTrace();
    } finally {
        ois.close();
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) ObjectStreamClass(java.io.ObjectStreamClass)

Aggregations

ObjectStreamClass (java.io.ObjectStreamClass)68 IOException (java.io.IOException)26 ObjectInputStream (java.io.ObjectInputStream)26 ByteArrayInputStream (java.io.ByteArrayInputStream)24 ObjectOutputStream (java.io.ObjectOutputStream)13 ObjectStreamField (java.io.ObjectStreamField)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 Serializable (java.io.Serializable)7 InvalidClassException (java.io.InvalidClassException)3 Field (java.lang.reflect.Field)3 ORecordBytes (com.orientechnologies.orient.core.record.impl.ORecordBytes)2 File (java.io.File)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 JavaCompiler (javax.tools.JavaCompiler)2 WicketRuntimeException (org.apache.wicket.WicketRuntimeException)2 Test (org.junit.Test)2 ParseException (org.locationtech.jts.io.ParseException)2 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)1 DefaultGeometryProperty (eu.esdihumboldt.hale.common.instance.geometry.DefaultGeometryProperty)1 OGroup (eu.esdihumboldt.hale.common.instance.orient.OGroup)1