Method method = testClass2.getMethod("setOtherPojo",new Class[]{Object.class});
method.invoke(rootObject,new Object[]{childObject});
ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
JBossObjectOutputStream objOut = new JBossObjectOutputStream(byteOut);
objOut.writeObject(rootObject);
objOut.flush();
forceCrossedClassLoaderRelease();
JBossObjectInputStream objInput = new JBossObjectInputStream(new ByteArrayInputStream(byteOut.toByteArray()),loader);
Object newObject = objInput.readObject();