1 package gov.nasa.jpf.jvm.bytecode; 20 21 import gov.nasa.jpf.jvm.ClassInfo; 22 import gov.nasa.jpf.jvm.KernelState; 23 import gov.nasa.jpf.jvm.SystemState; 24 import gov.nasa.jpf.jvm.ThreadInfo; 25 26 import org.apache.bcel.classfile.ConstantPool; 27 import gov.nasa.jpf.jvm.DynamicArea; 28 29 30 34 public class NEW extends Instruction { 35 protected String cname; 36 37 public void setPeer (org.apache.bcel.generic.Instruction i, ConstantPool cp) { 38 cname = cp.constantToString(cp.getConstant( 39 ((org.apache.bcel.generic.NEW) i).getIndex())); 40 } 41 42 public Instruction execute (SystemState ss, KernelState ks, ThreadInfo ti) { 43 ClassInfo ci = ClassInfo.getClassInfo(cname); 44 DynamicArea heap = DynamicArea.getHeap(); 45 46 if (heap.getOutOfMemory()) { return ti.createAndThrowException("java.lang.OutOfMemoryError", 48 "trying to allocate new " + cname); 49 } 50 51 int objRef = heap.newObject(ci, ti); 52 53 if (ci.instanceOf("java.lang.Thread")) { 54 ti.getVM().createThread(objRef); } 56 57 ti.push(objRef, true); 59 60 return getNext(ti); 61 } 62 63 public int getByteCode () { 64 return 0xBB; 65 } 66 } 67 | Popular Tags |