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;
}
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;
}
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();
}
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"));
}
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();
}
}
Aggregations