From 5c6b8a7eb5fbf6cffa8da91ddf307902da692e04 Mon Sep 17 00:00:00 2001 From: jochen Date: Tue, 13 Apr 1999 10:47:06 +0000 Subject: [PATCH] ref.getClazz is now type sig git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@580 379699f6-c40d-0410-875b-85095c16579e --- jode/jode/expr/PutFieldOperator.java | 7 +++---- jode/jode/jvm/SimpleRuntimeEnvironment.java | 14 ++++++++++---- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/jode/jode/expr/PutFieldOperator.java b/jode/jode/expr/PutFieldOperator.java index 408f56f..c19cc7c 100644 --- a/jode/jode/expr/PutFieldOperator.java +++ b/jode/jode/expr/PutFieldOperator.java @@ -35,7 +35,7 @@ public class PutFieldOperator extends StoreInstruction { this.codeAnalyzer = codeAnalyzer; this.staticFlag = staticFlag; this.ref = ref; - this.classType = Type.tClass(ref.getClazz()); + this.classType = Type.tType(ref.getClazz()); if (staticFlag) classType.useType(); } @@ -50,8 +50,7 @@ public class PutFieldOperator extends StoreInstruction { * allow super class */ public boolean isThis() { - return (classType.equals(Type.tClass(codeAnalyzer.getClazz(). - getName()))); + return (classType.equals(Type.tClass(codeAnalyzer.getClazz()))); } public FieldAnalyzer getField() { @@ -92,7 +91,7 @@ public class PutFieldOperator extends StoreInstruction { public String getLValueString(String[] operands) { String fieldName = getFieldName(); return staticFlag - ? (classType.equals(Type.tClass(codeAnalyzer.getClazz().getName())) + ? (classType.equals(Type.tClass(codeAnalyzer.getClazz())) && codeAnalyzer.findLocal(fieldName) == null ? fieldName : classType.toString() + "." + fieldName) diff --git a/jode/jode/jvm/SimpleRuntimeEnvironment.java b/jode/jode/jvm/SimpleRuntimeEnvironment.java index 040af04..c4ad4a6 100644 --- a/jode/jode/jvm/SimpleRuntimeEnvironment.java +++ b/jode/jode/jvm/SimpleRuntimeEnvironment.java @@ -24,11 +24,17 @@ import java.lang.reflect.*; 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) throws InterpreterException { Field f; try { - Class clazz = Class.forName(ref.getClazz()); + Class clazz = findClazz(ref.getClazz()); try { f = clazz.getField(ref.getName()); } catch (NoSuchFieldException ex) { @@ -55,7 +61,7 @@ public class SimpleRuntimeEnvironment implements RuntimeEnvironment { throws InterpreterException { Field f; try { - Class clazz = Class.forName(ref.getClazz()); + Class clazz = findClazz(ref.getClazz()); try { f = clazz.getField(ref.getName()); } catch (NoSuchFieldException ex) { @@ -83,7 +89,7 @@ public class SimpleRuntimeEnvironment implements RuntimeEnvironment { throws InterpreterException, InvocationTargetException { Constructor c; try { - Class clazz = Class.forName(ref.getClazz()); + Class clazz = findClazz(ref.getClazz()); MethodType mt = (MethodType) Type.tType(ref.getType()); Class[] paramTypes = mt.getParameterClasses(); try { @@ -122,7 +128,7 @@ public class SimpleRuntimeEnvironment implements RuntimeEnvironment { ("Can't invoke nonvirtual Method " + ref + "."); MethodType mt = (MethodType) Type.tType(ref.getType()); try { - Class clazz = Class.forName(ref.getClazz()); + Class clazz = findClazz(ref.getClazz()); Class[] paramTypes = mt.getParameterClasses(); try { m = clazz.getMethod(ref.getName(), paramTypes);