What steps will reproduce the problem?
1. Define a standard java class in script, and load by interpreter.
2. Save all states by serialization
3. Deserialize, and try to create a new instance of the defined class.
What is the expected output? What do you see instead?
Should be the same as before. But can not retrieve the class anymore.
Please use labels and text to provide additional information.
What I want to achieve is to save the parse result, and reuse it in the future
repeatedly. I *assume* that this will save some parsing effort in the long run
(not so sure, but trying).
I have tried several ways, by serializing the interpreter, or serializing the
defined class, or serializing the created class instance (from the class
defined in the script). But it seems none of them can achieve my goal, either
with exceptions (seems defined class can not be loaded), or the de-serialized
interpreter can not retrieve the defined class.
One example:
Interpreter i = new Interpreter();
Object clazz = i.eval("class A{}");
Object o = i.get("A"); //o is ClassIdentifier A
o = i.getNameSpace().getClass("A"); //o is class A
o = i.getClassManager().classForName("A"); //o is class A
ByteArrayOutputStream buf = new ByteArrayOutputStream();
ObjectOutputStream out = new ObjectOutputStream(buf);
out.writeObject(i);
out.close();
ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(buf.toByteArray()));
i = (Interpreter) in.readObject();
o = i.get("A"); //o is null, losing state?
o = i.getNameSpace().getClass("A"); //o is null, losing state?
o = i.getClassManager().classForName("A"); //o is null, losing state?
Original issue reported on code.google.com by verilo...@gmail.com on 11 Oct 2012 at 7:25
Original issue reported on code.google.com by
verilo...@gmail.com
on 11 Oct 2012 at 7:25