new Type[] {Type.OBJECT}, new String[] {"arg0"}, "<init>", "org.apache.geode.internal.util.bcel.SerializableImplWithValue", ctor, cp); ctorMethod.setMaxStack(2); MethodGen getterMethod = new MethodGen(Constants.ACC_PUBLIC, Type.OBJECT, null, null, GET_VALUE, CLASS_NAME_SERIALIZABLE_IMPL_WITH_VALUE, getter, cp); getterMethod.setMaxStack(1); new Type[] {Type.OBJECT}, new String[] {field.getName()}, SET_VALUE, CLASS_NAME_SERIALIZABLE_IMPL_WITH_VALUE, setter, cp); setterMethod.setMaxStack(2);
protected Method getThisMethod() { stripAttributes(true); setMaxLocals(); setMaxStack(); removeNOPs(); return getMethod(); } /**
protected Method getThisMethod() { stripAttributes(true); setMaxLocals(); setMaxStack(); removeNOPs(); return getMethod(); } /**
private void createMethod_2() { InstructionList il = new InstructionList(); MethodGen method = new MethodGen(ACC_STATIC | ACC_SYNTHETIC, Type.BOOLEAN, Type.NO_ARGS, new String[] { }, "access$0", "StopThread", il, _cp); InstructionHandle ih_0 = il.append(_factory.createFieldAccess("StopThread", "stopRequested", Type.BOOLEAN, Constants.GETSTATIC)); il.append(_factory.createReturn(Type.INT)); method.setMaxStack(); method.setMaxLocals(); _cg.addMethod(method.getMethod()); il.dispose(); }
public void fixStack() { for (ClassGen cg : cgs.values()) { for (Method method : cg.getMethods()) { MethodGen mg = new MethodGen(method, cg.getClassName(), cg.getConstantPool()); mg.removeNOPs(); mg.setMaxLocals(); mg.setMaxStack(); cg.replaceMethod(method, mg.getMethod()); logger.debug(String.format("Reset MaxStack and MaxLocals in %s.%s", cg.getClassName(), mg.getName())); } } }
/** * Convenience method. * * Add an empty constructor to this class that does nothing but calling super(). * @param access_flags rights for constructor */ public void addEmptyConstructor( final int access_flags ) { final InstructionList il = new InstructionList(); il.append(InstructionConst.THIS); // Push `this' il.append(new INVOKESPECIAL(cp.addMethodref(super_class_name, "<init>", "()V"))); il.append(InstructionConst.RETURN); final MethodGen mg = new MethodGen(access_flags, Type.VOID, Type.NO_ARGS, null, "<init>", class_name, il, cp); mg.setMaxStack(1); addMethod(mg.getMethod()); }
/** * Convenience method. * * Add an empty constructor to this class that does nothing but calling super(). * @param access rights for constructor */ public void addEmptyConstructor(int access_flags) { InstructionList il = new InstructionList(); il.append(InstructionConstants.THIS); // Push `this' il.append(new INVOKESPECIAL(cp.addMethodref(super_class_name, "<init>", "()V"))); il.append(InstructionConstants.RETURN); MethodGen mg = new MethodGen(access_flags, Type.VOID, Type.NO_ARGS, null, "<init>", class_name, il, cp); mg.setMaxStack(1); addMethod(mg.getMethod()); }
public void replaceCheckMethod() { ClassGen cg = cgs.get(AuthClass); Method method = cg.getMethods()[0]; MethodGen mg = new MethodGen(method, cg.getClassName(), cg.getConstantPool()); InstructionList list = new InstructionList(); list.append(new ICONST(1)); list.append(new IRETURN()); mg.removeExceptionHandlers(); mg.removeLineNumbers(); mg.removeLocalVariables(); mg.removeExceptions(); mg.setInstructionList(list); mg.setMaxLocals(); mg.setMaxStack(); cg.replaceMethod(method, mg.getMethod()); }
private void createMethod_getARGV() { InstructionList tmpIl = new InstructionList(); MethodGen method = new MethodGen(ACC_PUBLIC | ACC_FINAL, getObjectType(Object.class), new Type[] {}, new String[] {}, "getARGV", classname, tmpIl, cp); tmpIl.append(InstructionConstants.ALOAD_0); tmpIl.append(factory.createFieldAccess(classname, argv_field, getObjectType(Object.class), Constants.GETFIELD)); tmpIl.append(InstructionFactory.createReturn(getObjectType(Object.class))); method.setMaxStack(); method.setMaxLocals(); cg.addMethod(method.getMethod()); tmpIl.dispose(); }
private void createSetMethod(String method_name, String field_name, Class field_type) { InstructionList tmpIl = new InstructionList(); MethodGen method = new MethodGen(ACC_PUBLIC | ACC_FINAL, Type.VOID, buildArgs(new Class[] {field_type}), new String[] {"arg"}, method_name, classname, tmpIl, cp); tmpIl.append(InstructionConstants.ALOAD_0); tmpIl.append(InstructionConstants.ALOAD_1); tmpIl.append(factory.createFieldAccess(classname, field_name, getObjectType(Object.class), Constants.PUTFIELD)); tmpIl.append(InstructionFactory.createReturn(Type.VOID)); method.setMaxStack(); method.setMaxLocals(); cg.addMethod(method.getMethod()); tmpIl.dispose(); }
private void createResetMethod(String method_name, String field_name) { InstructionList tmpIl = new InstructionList(); // no-arg method MethodGen method = new MethodGen(ACC_PUBLIC | ACC_FINAL, Type.VOID, buildArgs(new Class[] {}), new String[] {}, method_name, classname, tmpIl, cp); // implement: setXX(ZERO) tmpIl.append(InstructionConstants.ALOAD_0); tmpIl.append(factory.createFieldAccess(classname, "ZERO", getObjectType(Integer.class), Constants.GETSTATIC)); tmpIl.append(factory.createFieldAccess(classname, field_name, getObjectType(Object.class), Constants.PUTFIELD)); tmpIl.append(InstructionFactory.createReturn(Type.VOID)); method.setMaxStack(); method.setMaxLocals(); cg.addMethod(method.getMethod()); tmpIl.dispose(); }
public Method injection(final JavaClass clazz, Method method, final ConstantPoolGen cp, final int firstStringOffset) { final MethodGen methodGen = new MethodGen(method, clazz.getClassName(), cp); final InstructionList instructionList = methodGen.getInstructionList(); instructionList.insert(instructionList.getStart(), makeWillBeAddedInstructionList(methodGen, firstStringOffset)); methodGen.setMaxStack(); methodGen.setMaxLocals(); method = methodGen.getMethod(); instructionList.dispose(); return method; }
private void createMethod_1() { final InstructionList il = new InstructionList(); final MethodGen method = new MethodGen(Const.ACC_PUBLIC | Const.ACC_STATIC, Type.INT, Type.NO_ARGS, new String[] { }, "test3", TEST_PACKAGE+".TestReturn03", il, _cp); final InstructionHandle ih_0 = il.append(InstructionConst.ACONST_NULL); Assert.assertNotNull(ih_0); // TODO why is this not used il.append(InstructionFactory.createReturn(Type.OBJECT)); method.setMaxStack(); method.setMaxLocals(); _cg.addMethod(method.getMethod()); il.dispose(); } }
private void generateEqualsMethod(String generatedClassName) { /* public boolean equals(Object o) { * return stubHelper.isEquals(this,o); * } */ InstructionList il = new InstructionList(); MethodGen method = new MethodGen(Constants.ACC_PUBLIC, Type.BOOLEAN, new Type[]{Type.OBJECT}, new String[]{"arg0"}, "equals", generatedClassName, il, constantsPool); il.append(InstructionFactory.createLoad(Type.OBJECT, 0)); il.append(factory.createFieldAccess(generatedClassName, "stubHelper", new ObjectType("org.codehaus.jremoting.client.StubHelper"), Constants.GETFIELD)); il.append(InstructionFactory.createLoad(Type.OBJECT, 0)); il.append(InstructionFactory.createLoad(Type.OBJECT, 1)); il.append(factory.createInvoke("org.codehaus.jremoting.client.StubHelper", "isEquals", Type.BOOLEAN, new Type[]{Type.OBJECT, Type.OBJECT}, Constants.INVOKEINTERFACE)); il.append(InstructionFactory.createReturn(Type.INT)); method.setMaxStack(); method.setMaxLocals(); classGen.addMethod(method.getMethod()); il.dispose(); }
private void createMethod_0() { final InstructionList il = new InstructionList(); final MethodGen method = new MethodGen(Const.ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "<init>", TEST_PACKAGE+".TestReturn03", il, _cp); final InstructionHandle ih_0 = il.append(InstructionFactory.createLoad(Type.OBJECT, 0)); Assert.assertNotNull(ih_0); // TODO why is this not used il.append(_factory.createInvoke("java.lang.Object", "<init>", Type.VOID, Type.NO_ARGS, Const.INVOKESPECIAL)); final InstructionHandle ih_4 = il.append(InstructionFactory.createReturn(Type.VOID)); Assert.assertNotNull(ih_4); // TODO why is this not used method.setMaxStack(); method.setMaxLocals(); _cg.addMethod(method.getMethod()); il.dispose(); }
private void createMethod_0() { final InstructionList il = new InstructionList(); final MethodGen method = new MethodGen(Const.ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "<init>", TEST_PACKAGE+".TestArrayAccess03", il, _cp); final InstructionHandle ih_0 = il.append(InstructionFactory.createLoad(Type.OBJECT, 0)); Assert.assertNotNull(ih_0); // TODO why is this not used il.append(_factory.createInvoke("java.lang.Object", "<init>", Type.VOID, Type.NO_ARGS, Const.INVOKESPECIAL)); final InstructionHandle ih_4 = il.append(InstructionFactory.createReturn(Type.VOID)); Assert.assertNotNull(ih_4); // TODO why is this not used method.setMaxStack(); method.setMaxLocals(); _cg.addMethod(method.getMethod()); il.dispose(); }
private void createMethod_0() { final InstructionList il = new InstructionList(); final MethodGen method = new MethodGen(Const.ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "<init>", TEST_PACKAGE+".TestReturn01", il, _cp); final InstructionHandle ih_0 = il.append(InstructionFactory.createLoad(Type.OBJECT, 0)); Assert.assertNotNull(ih_0); // TODO why is this not used il.append(_factory.createInvoke("java.lang.Object", "<init>", Type.VOID, Type.NO_ARGS, Const.INVOKESPECIAL)); final InstructionHandle ih_4 = il.append(InstructionFactory.createReturn(Type.VOID)); Assert.assertNotNull(ih_4); // TODO why is this not used method.setMaxStack(); method.setMaxLocals(); _cg.addMethod(method.getMethod()); il.dispose(); }
private void createMethod_0() { final InstructionList il = new InstructionList(); final MethodGen method = new MethodGen(Const.ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "<init>", TEST_PACKAGE+".TestArrayAccess04", il, _cp); final InstructionHandle ih_0 = il.append(InstructionFactory.createLoad(Type.OBJECT, 0)); Assert.assertNotNull(ih_0); // TODO why is this not used il.append(_factory.createInvoke("java.lang.Object", "<init>", Type.VOID, Type.NO_ARGS, Const.INVOKESPECIAL)); final InstructionHandle ih_4 = il.append(InstructionFactory.createReturn(Type.VOID)); Assert.assertNotNull(ih_4); // TODO why is this not used method.setMaxStack(); method.setMaxLocals(); _cg.addMethod(method.getMethod()); il.dispose(); }
private void createMethod_0() { final InstructionList il = new InstructionList(); final MethodGen method = new MethodGen(Const.ACC_PUBLIC, Type.VOID, Type.NO_ARGS, new String[] { }, "<init>", TEST_PACKAGE+".TestArrayAccess02", il, _cp); final InstructionHandle ih_0 = il.append(InstructionFactory.createLoad(Type.OBJECT, 0)); Assert.assertNotNull(ih_0); // TODO why is this not used il.append(_factory.createInvoke("java.lang.Object", "<init>", Type.VOID, Type.NO_ARGS, Const.INVOKESPECIAL)); final InstructionHandle ih_4 = il.append(InstructionFactory.createReturn(Type.VOID)); Assert.assertNotNull(ih_4); // TODO why is this not used method.setMaxStack(); method.setMaxLocals(); _cg.addMethod(method.getMethod()); il.dispose(); }
private void createMethod_1() { final InstructionList il = new InstructionList(); final MethodGen method = new MethodGen(Const.ACC_PUBLIC | Const.ACC_STATIC, Type.VOID, Type.NO_ARGS, new String[] { }, "foo", TEST_PACKAGE+".TestReturn01", il, _cp); final InstructionHandle ih_0 = il.append(_factory.createNew("java.lang.Object")); Assert.assertNotNull(ih_0); // TODO why is this not used il.append(InstructionConst.DUP); il.append(_factory.createInvoke("java.lang.Object", "<init>", Type.VOID, Type.NO_ARGS, Const.INVOKESPECIAL)); il.append(InstructionConst.NOP); final InstructionHandle ih_8 = il.append(InstructionFactory.createReturn(Type.OBJECT)); Assert.assertNotNull(ih_8); // TODO why is this not used method.setMaxStack(); method.setMaxLocals(); _cg.addMethod(method.getMethod()); il.dispose(); } }