Package javassist.bytecode

Examples of javassist.bytecode.Bytecode.addInvokestatic()


        CtMethod method = new CtMethod(stringClass, "foo", new CtClass[0], clazz);
        MethodInfo info = method.getMethodInfo2();
        info.setAccessFlags(AccessFlag.PUBLIC | AccessFlag.STATIC);
        Bytecode code = new Bytecode(info.getConstPool(), 1, 2);
        /* 0 */ code.addIconst(1);
        /* 1 */ code.addInvokestatic(stringClass, "valueOf", stringClass, new CtClass[]{CtClass.intType});
        info.setCodeAttribute(code.toCodeAttribute());
        clazz.addMethod(method);

        return method;
    }
View Full Code Here


        /* 2 */ addJump(code, Opcode.JSR, 7);
        /* 5 */ code.addAload(0);
        /* 6 */ code.addOpcode(Opcode.ARETURN);
        /* 7 */ code.addAstore(1);
        /* 8 */ code.addIconst(3);
        /* 9 */ code.addInvokestatic(stringClass, "valueOf", stringClass, new CtClass[]{CtClass.intType});
        /* 12 */ code.addAstore(0);
        /* 12 */ code.addRet(1);
        info.setCodeAttribute(code.toCodeAttribute());
        clazz.addMethod(method);
        //System.out.println(clazz.toClass().getMethod("foo", new Class[0]).invoke(null, new Object[0]));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.