|
|
@ -24,11 +24,17 @@ import java.lang.reflect.*; |
|
|
|
|
|
|
|
|
|
|
|
public class SimpleRuntimeEnvironment implements RuntimeEnvironment { |
|
|
|
public class SimpleRuntimeEnvironment implements RuntimeEnvironment { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Class findClazz(String clName) throws ClassNotFoundException { |
|
|
|
|
|
|
|
if (clName.charAt(0) == 'L') |
|
|
|
|
|
|
|
clName = clName.substring(1, clName.length()-1); |
|
|
|
|
|
|
|
return Class.forName(clName.replace('/','.')); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Object getField(Reference ref, Object obj) |
|
|
|
public Object getField(Reference ref, Object obj) |
|
|
|
throws InterpreterException { |
|
|
|
throws InterpreterException { |
|
|
|
Field f; |
|
|
|
Field f; |
|
|
|
try { |
|
|
|
try { |
|
|
|
Class clazz = Class.forName(ref.getClazz()); |
|
|
|
Class clazz = findClazz(ref.getClazz()); |
|
|
|
try { |
|
|
|
try { |
|
|
|
f = clazz.getField(ref.getName()); |
|
|
|
f = clazz.getField(ref.getName()); |
|
|
|
} catch (NoSuchFieldException ex) { |
|
|
|
} catch (NoSuchFieldException ex) { |
|
|
@ -55,7 +61,7 @@ public class SimpleRuntimeEnvironment implements RuntimeEnvironment { |
|
|
|
throws InterpreterException { |
|
|
|
throws InterpreterException { |
|
|
|
Field f; |
|
|
|
Field f; |
|
|
|
try { |
|
|
|
try { |
|
|
|
Class clazz = Class.forName(ref.getClazz()); |
|
|
|
Class clazz = findClazz(ref.getClazz()); |
|
|
|
try { |
|
|
|
try { |
|
|
|
f = clazz.getField(ref.getName()); |
|
|
|
f = clazz.getField(ref.getName()); |
|
|
|
} catch (NoSuchFieldException ex) { |
|
|
|
} catch (NoSuchFieldException ex) { |
|
|
@ -83,7 +89,7 @@ public class SimpleRuntimeEnvironment implements RuntimeEnvironment { |
|
|
|
throws InterpreterException, InvocationTargetException { |
|
|
|
throws InterpreterException, InvocationTargetException { |
|
|
|
Constructor c; |
|
|
|
Constructor c; |
|
|
|
try { |
|
|
|
try { |
|
|
|
Class clazz = Class.forName(ref.getClazz()); |
|
|
|
Class clazz = findClazz(ref.getClazz()); |
|
|
|
MethodType mt = (MethodType) Type.tType(ref.getType()); |
|
|
|
MethodType mt = (MethodType) Type.tType(ref.getType()); |
|
|
|
Class[] paramTypes = mt.getParameterClasses(); |
|
|
|
Class[] paramTypes = mt.getParameterClasses(); |
|
|
|
try { |
|
|
|
try { |
|
|
@ -122,7 +128,7 @@ public class SimpleRuntimeEnvironment implements RuntimeEnvironment { |
|
|
|
("Can't invoke nonvirtual Method " + ref + "."); |
|
|
|
("Can't invoke nonvirtual Method " + ref + "."); |
|
|
|
MethodType mt = (MethodType) Type.tType(ref.getType()); |
|
|
|
MethodType mt = (MethodType) Type.tType(ref.getType()); |
|
|
|
try { |
|
|
|
try { |
|
|
|
Class clazz = Class.forName(ref.getClazz()); |
|
|
|
Class clazz = findClazz(ref.getClazz()); |
|
|
|
Class[] paramTypes = mt.getParameterClasses(); |
|
|
|
Class[] paramTypes = mt.getParameterClasses(); |
|
|
|
try { |
|
|
|
try { |
|
|
|
m = clazz.getMethod(ref.getName(), paramTypes); |
|
|
|
m = clazz.getMethod(ref.getName(), paramTypes); |
|
|
|