byte[] bytes = bout.toByteArray();
/*
* Read in handler (should succeed).
*/
MarshalInputStream in =
new MarshalInputStream(new ByteArrayInputStream(bytes),
ClassLoader.getSystemClassLoader(),
false, null, new HashSet());
ActivatableInvocationHandler aihRead =
(ActivatableInvocationHandler) in.readObject();
System.err.println("Test 1 passed: handler read successfully");
/*
* Set constraints on underlying proxy to make
* them inconsistent with handler's constraints, then
* serialize handler.
*/
uproxy.setConstraints(new Constraints());
bout.reset();
out = new MarshalOutputStream(bout, new HashSet());
out.writeObject(aih);
out.flush();
bytes = bout.toByteArray();
/*
* Read in handler (should fail with InvalidObjectException);
*/
try {
in =
new MarshalInputStream(new ByteArrayInputStream(bytes),
ClassLoader.getSystemClassLoader(),
false, null, new HashSet());
aihRead = (ActivatableInvocationHandler) in.readObject();
System.err.println("Test 2 failed: no InvalidObjectException");
throw new RuntimeException(
"Test 2 failed: no InvalidObjectException");
} catch (InvalidObjectException e) {
System.err.println(