/** * Set the name of the class to load. */ private void setClassName(String name, Class wrapper) { if (_invalid) throw new IllegalStateException(); // remember the position of the code iterator Instruction before = (_code.hasNext()) ? _code.next() : null; _code.before(_ins); _code.next(); if (wrapper != null) _code.getstatic().setField(wrapper, "TYPE", Class.class); else setObject(name); // move to the old position if (before != null) _code.before(before); else _code.afterLast(); _invalid = true; }
public void enterGetFieldInstruction(GetFieldInstruction obj) { _out.print(obj.getFieldIndex() + " <" + obj.getFieldTypeName() + " " + obj.getFieldDeclarerName() + "." + obj.getFieldName() + ">"); }
public int getStackChange() { String type = getFieldTypeName(); if (type == null) return 0; int stack = 0; if (long.class.getName().equals(type) || double.class.getName().equals(type)) stack++; if (getOpcode() == Constants.GETSTATIC) stack++; return stack; }
public int getLogicalStackChange() { if (getOpcode() == Constants.GETSTATIC) return 1; return 0; }
case Constants.GETSTATIC: case Constants.GETFIELD: return new GetFieldInstruction(this, opcode); case Constants.PUTSTATIC: case Constants.PUTFIELD:
public int getLogicalStackChange() { if (getOpcode() == Constants.GETSTATIC) return 1; return 0; }
case Constants.GETSTATIC: case Constants.GETFIELD: return new GetFieldInstruction(this, opcode); case Constants.PUTSTATIC: case Constants.PUTFIELD:
/** * Set the name of the class to load. */ private void setClassName(String name, Class wrapper) { if (_invalid) throw new IllegalStateException(); // remember the position of the code iterator Instruction before = (_code.hasNext()) ? _code.next() : null; _code.before(_ins); _code.next(); if (wrapper != null) _code.getstatic().setField(wrapper, "TYPE", Class.class); else setObject(name); // move to the old position if (before != null) _code.before(before); else _code.afterLast(); _invalid = true; }
public void enterGetFieldInstruction(GetFieldInstruction obj) { _out.print(obj.getFieldIndex() + " <" + obj.getFieldTypeName() + " " + obj.getFieldDeclarerName() + "." + obj.getFieldName() + ">"); }
public int getStackChange() { String type = getFieldTypeName(); if (type == null) return 0; int stack = 0; if (long.class.getName().equals(type) || double.class.getName().equals(type)) stack++; if (getOpcode() == Constants.GETSTATIC) stack++; return stack; }
/** * Adds fields and methods as necessary to load a class constant of * an object type. */ private void setObject(String name) { BCField field = addClassField(name); BCMethod method = addClassLoadMethod(); // copied from the way jikes loads classes _code.getstatic().setField(field); JumpInstruction ifnull = _code.ifnull(); _code.getstatic().setField(field); JumpInstruction go2 = _code.go2(); ifnull.setTarget(_code.constant().setValue(name)); _code.invokestatic().setMethod(method); _code.dup(); _code.putstatic().setField(field); go2.setTarget(_code.nop()); }
/** * Adds fields and methods as necessary to load a class constant of * an object type. */ private void setObject(String name) { BCField field = addClassField(name); BCMethod method = addClassLoadMethod(); // copied from the way jikes loads classes _code.getstatic().setField(field); JumpInstruction ifnull = _code.ifnull(); _code.getstatic().setField(field); JumpInstruction go2 = _code.go2(); ifnull.setTarget(_code.constant().setValue(name)); _code.invokestatic().setMethod(method); _code.dup(); _code.putstatic().setField(field); go2.setTarget(_code.nop()); }
/** * Adds a custom readObject method that delegates to the * {@link ObjectInputStream#readObject} method. */ private void modifyReadObjectMethod(BCMethod method, boolean full) { Code code = method.getCode(true); code.beforeFirst(); // if this instance uses synthetic detached state, note that it has // been deserialized if (ClassMetaData.SYNTHETIC.equals(_meta.getDetachedState())) { loadManagedInstance(code, false); code.getstatic().setField(PersistenceCapable.class, "DESERIALIZED", Object.class); code.invokevirtual().setMethod(PRE + "SetDetachedState", void.class, new Class[]{ Object.class }); } if (full) { // in.defaultReadObject (); code.aload().setParam(0); code.invokevirtual().setMethod(ObjectInputStream.class, "defaultReadObject", void.class, null); code.vreturn(); } code.calculateMaxStack(); code.calculateMaxLocals(); }