org.objectweb.asm.commons.AdviceAdapter Java Examples

The following examples show how to use org.objectweb.asm.commons.AdviceAdapter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RouterInitGenerator.java    From MRouter with Apache License 2.0 6 votes vote down vote up
@Override
public MethodVisitor visitMethod(int access, final String name, final String desc, String signature, String[] exceptions) {
    MethodVisitor methodVisitor = cv.visitMethod(access, name, desc, signature, exceptions);
    return new AdviceAdapter(ASM5, methodVisitor, access, name, desc) {
        @Override
        protected void onMethodEnter() {
            super.onMethodEnter();

            if (name.equals(globalInfo.getRouterConfig().getRouterInitMethod())) {
                for (String clazz : globalInfo.getRouterComponents()) {
                    mv.visitMethodInsn(Opcodes.INVOKESTATIC,
                            clazz,
                            globalInfo.getRouterConfig().getRouterInitMethod(),
                            globalInfo.getRouterConfig().getRouterInitMethodDescriptor(),
                            false);
                }
            }
        }
    };

}
 
Example #2
Source File: AsmCodeLock.java    From jvm-sandbox with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 用ASM构建代码锁
 *
 * @param aa             ASM
 * @param beginCodeArray 代码块开始特征数组
 *                       字节码流要求不能破坏执行堆栈
 * @param endCodeArray   代码块结束特征数组
 *                       字节码流要求不能破坏执行堆栈
 */
public AsmCodeLock(AdviceAdapter aa, int[] beginCodeArray, int[] endCodeArray) {
    if (null == beginCodeArray
            || null == endCodeArray
            || beginCodeArray.length != endCodeArray.length) {
        throw new IllegalArgumentException();
    }

    this.aa = aa;
    this.beginCodeArray = beginCodeArray;
    this.endCodeArray = endCodeArray;

}
 
Example #3
Source File: EventWeaver.java    From jvm-sandbox with GNU Lesser General Public License v3.0 5 votes vote down vote up
CallAsmCodeLock(AdviceAdapter aa) {
    super(
            aa,
            new int[]{
                    ICONST_2, POP
            },
            new int[]{
                    ICONST_3, POP
            }
    );
}