fix various ObjectOutputStream/ObjectInputStream bugs

This commit is contained in:
Anonymous
2011-07-01 08:43:43 -06:00
committed by Joel Dice
parent 9700b7def1
commit 794a45cb79
11 changed files with 63 additions and 26 deletions

View File

@ -10,6 +10,8 @@
package java.io;
import avian.VMClass;
import java.util.HashMap;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
@ -110,7 +112,7 @@ public class ObjectInputStream extends InputStream {
StringBuilder sb = new StringBuilder();
int c;
while ((c = r.read()) != -1 && ! Character.isWhitespace((char) c)) {
while ((c = r.read()) != -1 && ! Character.isWhitespace((char) c) && c != ')') {
sb.append((char) c);
}
if (c != -1) {
@ -149,7 +151,6 @@ public class ObjectInputStream extends InputStream {
throws IOException, ClassNotFoundException
{
skipSpace();
switch (r.read()) {
case 'a':
return deserializeArray(map);
@ -203,7 +204,7 @@ public class ObjectInputStream extends InputStream {
return o;
}
private static native Object makeInstance(Class c);
private static native Object makeInstance(VMClass c);
private Object deserializeObject(HashMap<Integer, Object> map)
throws IOException, ClassNotFoundException
@ -211,11 +212,11 @@ public class ObjectInputStream extends InputStream {
read('(');
int id = (int) readLongToken();
Class c = Class.forName(readStringToken());
Object o = makeInstance(c);
Object o = makeInstance(c.vmClass);
map.put(id, o);
for (Field f: c.getFields()) {
for (Field f: c.getAllFields()) {
int modifiers = f.getModifiers();
if ((modifiers & (Modifier.TRANSIENT | Modifier.STATIC)) == 0) {
try {