00001 package gov.nasa.arc.ase.jpf.jvm.bytecode; 00002 00003 import de.fub.bytecode.classfile.ConstantPool; 00004 import de.fub.bytecode.generic.ConstantPoolGen; 00005 import gov.nasa.arc.ase.jpf.jvm.SystemState; 00006 import gov.nasa.arc.ase.jpf.jvm.KernelState; 00007 import gov.nasa.arc.ase.jpf.jvm.ThreadInfo; 00008 import gov.nasa.arc.ase.jpf.jvm.ClassInfo; 00009 import gov.nasa.arc.ase.jpf.jvm.MethodInfo; 00010 import gov.nasa.arc.ase.jpf.jvm.Types; 00011 import gov.nasa.arc.ase.util.Debug; 00012 00013 public class INVOKEVIRTUAL extends InvokeInstruction { 00014 public boolean examine(SystemState ss, KernelState ks, ThreadInfo th) { 00015 int objref = th.getCalleeThis(Types.getArgumentsSize(signature) + 1); 00016 00017 if(objref == -1) 00018 return false; 00019 00020 ClassInfo ci = ks.da.get(objref).getClassInfo(); 00021 MethodInfo mi = ci.getDynamicMethod(mname); 00022 00023 return !mi.getClassInfo().isMethodDeterministic(th, mname); 00024 } 00025 public Instruction execute(SystemState ss, KernelState ks, ThreadInfo th) { 00026 int objref = th.getCalleeThis(Types.getArgumentsSize(signature) + 1); 00027 00028 if(objref == -1) 00029 return th.createAndThrowException("java.lang.NullPointerException"); 00030 00031 ClassInfo ci = ks.da.get(objref).getClassInfo(); 00032 MethodInfo mi = ci.getDynamicMethod(mname); 00033 00034 return mi.getClassInfo().executeMethod(th, mname); 00035 } 00036 public boolean isExecutable(SystemState ss, KernelState ks, ThreadInfo th) { 00037 int objref = th.getCalleeThis(Types.getArgumentsSize(signature) + 1); 00038 00039 if(objref == -1) 00040 return true; 00041 00042 ClassInfo ci = ks.da.get(objref).getClassInfo(); 00043 MethodInfo mi = ci.getDynamicMethod(mname); 00044 00045 return mi.getClassInfo().isMethodExecutable(th, mname); 00046 } 00047 public void setPeer(de.fub.bytecode.generic.Instruction i, ConstantPool cp) { 00048 cname = ((de.fub.bytecode.generic.INVOKEVIRTUAL)i).getClassName(new ConstantPoolGen(cp)); 00049 signature = ((de.fub.bytecode.generic.INVOKEVIRTUAL)i).getSignature(new ConstantPoolGen(cp)); 00050 mname = ((de.fub.bytecode.generic.INVOKEVIRTUAL)i).getMethodName(new ConstantPoolGen(cp)) + 00051 signature; 00052 } 00053 }