ref.getClazz is now type sig

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@580 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent 3ca944a9d5
commit 5c6b8a7eb5
  1. 7
      jode/jode/expr/PutFieldOperator.java
  2. 14
      jode/jode/jvm/SimpleRuntimeEnvironment.java

@ -35,7 +35,7 @@ public class PutFieldOperator extends StoreInstruction {
this.codeAnalyzer = codeAnalyzer; this.codeAnalyzer = codeAnalyzer;
this.staticFlag = staticFlag; this.staticFlag = staticFlag;
this.ref = ref; this.ref = ref;
this.classType = Type.tClass(ref.getClazz()); this.classType = Type.tType(ref.getClazz());
if (staticFlag) if (staticFlag)
classType.useType(); classType.useType();
} }
@ -50,8 +50,7 @@ public class PutFieldOperator extends StoreInstruction {
* allow super class * allow super class
*/ */
public boolean isThis() { public boolean isThis() {
return (classType.equals(Type.tClass(codeAnalyzer.getClazz(). return (classType.equals(Type.tClass(codeAnalyzer.getClazz())));
getName())));
} }
public FieldAnalyzer getField() { public FieldAnalyzer getField() {
@ -92,7 +91,7 @@ public class PutFieldOperator extends StoreInstruction {
public String getLValueString(String[] operands) { public String getLValueString(String[] operands) {
String fieldName = getFieldName(); String fieldName = getFieldName();
return staticFlag return staticFlag
? (classType.equals(Type.tClass(codeAnalyzer.getClazz().getName())) ? (classType.equals(Type.tClass(codeAnalyzer.getClazz()))
&& codeAnalyzer.findLocal(fieldName) == null && codeAnalyzer.findLocal(fieldName) == null
? fieldName ? fieldName
: classType.toString() + "." + fieldName) : classType.toString() + "." + fieldName)

@ -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);

Loading…
Cancel
Save