/** * @return code exceptions for `Code' attribute */ private CodeException[] getCodeExceptions() { final int size = exception_vec.size(); final CodeException[] c_exc = new CodeException[size]; for (int i = 0; i < size; i++) { final CodeExceptionGen c = exception_vec.get(i); c_exc[i] = c.getCodeException(super.getConstantPool()); } return c_exc; }
/** @return deep copy of this method */ public MethodGen copy( final String class_name, final ConstantPoolGen cp ) { final Method m = ((MethodGen) clone()).getMethod(); final MethodGen mg = new MethodGen(m, class_name, super.getConstantPool()); if (super.getConstantPool() != cp) { mg.setConstantPool(cp); mg.getInstructionList().replaceConstantPool(super.getConstantPool(), cp); } return mg; }
/** * Computes max. stack size by performing control flow analysis. */ public void setMaxStack() { // TODO could be package-protected? (some tests would need repackaging) if (il != null) { max_stack = getMaxStack(super.getConstantPool(), il, getExceptionHandlers()); } else { max_stack = 0; } }
private int addConstant() { switch (super.getType().getType()) { // sic case Const.T_INT: case Const.T_CHAR: case Const.T_BYTE: case Const.T_BOOLEAN: case Const.T_SHORT: return super.getConstantPool().addInteger(((Integer) value).intValue()); case Const.T_FLOAT: return super.getConstantPool().addFloat(((Float) value).floatValue()); case Const.T_DOUBLE: return super.getConstantPool().addDouble(((Double) value).doubleValue()); case Const.T_LONG: return super.getConstantPool().addLong(((Long) value).longValue()); case Const.T_REFERENCE: return super.getConstantPool().addString((String) value); default: throw new RuntimeException("Oops: Unhandled : " + super.getType().getType()); // sic } }
private void setValue( final int index ) { final ConstantPool cp = super.getConstantPool().getConstantPool(); final Constant c = cp.getConstant(index); value = ((ConstantObject) c).getConstantValue(cp); }
/** * Get field object after having set up all necessary values. */ public Field getField() { final String signature = getSignature(); final int name_index = super.getConstantPool().addUtf8(super.getName()); final int signature_index = super.getConstantPool().addUtf8(signature); if (value != null) { checkType(super.getType()); final int index = addConstant(); addAttribute(new ConstantValue(super.getConstantPool().addUtf8("ConstantValue"), 2, index, super.getConstantPool().getConstantPool())); // sic } addAnnotationsAsAttribute(super.getConstantPool()); return new Field(super.getAccessFlags(), name_index, signature_index, getAttributes(), super.getConstantPool().getConstantPool()); // sic }
/** * Return string representation close to declaration format, * `public static void main(String[]) throws IOException', e.g. * * @return String representation of the method. */ @Override public final String toString() { final String access = Utility.accessToString(super.getAccessFlags()); String signature = Type.getMethodSignature(super.getType(), arg_types); signature = Utility.methodSignatureToString(signature, super.getName(), access, true, getLocalVariableTable(super.getConstantPool())); final StringBuilder buf = new StringBuilder(signature); for (final Attribute a : getAttributes()) { if (!((a instanceof Code) || (a instanceof ExceptionTable))) { buf.append(" [").append(a).append("]"); } } if (throws_vec.size() > 0) { for (final String throwsDescriptor : throws_vec) { buf.append("\n\t\tthrows ").append(throwsDescriptor); } } return buf.toString(); }
/** * Compute maximum number of local variables. */ public void setMaxLocals() { // TODO could be package-protected? (some tests would need repackaging) if (il != null) { int max = isStatic() ? 0 : 1; if (arg_types != null) { for (final Type arg_type : arg_types) { max += arg_type.getSize(); } } for (InstructionHandle ih = il.getStart(); ih != null; ih = ih.getNext()) { final Instruction ins = ih.getInstruction(); if ((ins instanceof LocalVariableInstruction) || (ins instanceof RET) || (ins instanceof IINC)) { final int index = ((IndexedInstruction) ins).getIndex() + ((TypedInstruction) ins).getType(super.getConstantPool()).getSize(); if (index > max) { max = index; } } } max_locals = max; } else { max_locals = 0; } }
+ last.getInstruction().getLength(); ConstantPoolGen cpg = getConstantPool();
+ last.getInstruction().getLength(); ConstantPoolGen cpg = getConstantPool();
final ConstantPoolGen _cp = super.getConstantPool(); final int name_index = _cp.addUtf8(super.getName()); final int signature_index = _cp.addUtf8(signature);