Merge pull request #264 from jentfoo/master

Fix package for LegacyObjectInputStream
This commit is contained in:
Joshua Warner 2014-05-20 13:12:44 -06:00
commit b28142a837

View File

@ -8,11 +8,17 @@
There is NO WARRANTY for this software. See license.txt for There is NO WARRANTY for this software. See license.txt for
details. */ details. */
package java.io; package avian;
import avian.VMClass; import avian.VMClass;
import java.util.HashMap; import java.util.HashMap;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PushbackReader;
import java.io.StreamCorruptedException;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
@ -39,7 +45,7 @@ public class LegacyObjectInputStream extends InputStream {
} }
public Object readObject() throws IOException, ClassNotFoundException { public Object readObject() throws IOException, ClassNotFoundException {
return readObject(new HashMap()); return readObject(new HashMap<Integer, Object>());
} }
public boolean readBoolean() throws IOException { public boolean readBoolean() throws IOException {
@ -188,9 +194,9 @@ public class LegacyObjectInputStream extends InputStream {
{ {
read('('); read('(');
int id = (int) readLongToken(); int id = (int) readLongToken();
Class c = Class.forName(readStringToken()); Class<?> c = Class.forName(readStringToken());
int length = (int) readLongToken(); int length = (int) readLongToken();
Class t = c.getComponentType(); Class<?> t = c.getComponentType();
Object o = Array.newInstance(t, length); Object o = Array.newInstance(t, length);
map.put(id, o); map.put(id, o);
@ -211,12 +217,12 @@ public class LegacyObjectInputStream extends InputStream {
{ {
read('('); read('(');
int id = (int) readLongToken(); int id = (int) readLongToken();
Class c = Class.forName(readStringToken()); Class<?> c = Class.forName(readStringToken());
Object o = makeInstance(c.vmClass); Object o = makeInstance(c.vmClass);
map.put(id, o); map.put(id, o);
for (Field f: c.getAllFields()) { for (Field<?> f: c.getAllFields()) {
int modifiers = f.getModifiers(); int modifiers = f.getModifiers();
if ((modifiers & (Modifier.TRANSIENT | Modifier.STATIC)) == 0) { if ((modifiers & (Modifier.TRANSIENT | Modifier.STATIC)) == 0) {
try { try {