当前位置: 首页>>代码示例>>Java>>正文


Java MethodVisitor.visitFrame方法代码示例

本文整理汇总了Java中jdk.internal.org.objectweb.asm.MethodVisitor.visitFrame方法的典型用法代码示例。如果您正苦于以下问题:Java MethodVisitor.visitFrame方法的具体用法?Java MethodVisitor.visitFrame怎么用?Java MethodVisitor.visitFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在jdk.internal.org.objectweb.asm.MethodVisitor的用法示例。


在下文中一共展示了MethodVisitor.visitFrame方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: accept

import jdk.internal.org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
/**
 * Makes the given visitor visit this stack map frame.
 *
 * @param mv
 *            a method visitor.
 */
@Override
public void accept(final MethodVisitor mv) {
    switch (type) {
    case Opcodes.F_NEW:
    case Opcodes.F_FULL:
        mv.visitFrame(type, local.size(), asArray(local), stack.size(),
                asArray(stack));
        break;
    case Opcodes.F_APPEND:
        mv.visitFrame(type, local.size(), asArray(local), 0, null);
        break;
    case Opcodes.F_CHOP:
        mv.visitFrame(type, local.size(), null, 0, null);
        break;
    case Opcodes.F_SAME:
        mv.visitFrame(type, 0, null, 0, null);
        break;
    case Opcodes.F_SAME1:
        mv.visitFrame(type, 0, null, 1, asArray(stack));
        break;
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:29,代码来源:FrameNode.java

示例2: createMethodBody

import jdk.internal.org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
private static void createMethodBody(MethodVisitor mv) {
    Label classExists = new Label();

    // Cache resolution errors
    createLoadNonExistentClassCode(mv, classExists);

    // Redefine our own class and method
    mv.visitMethodInsn(INVOKESTATIC, "RedefineRunningMethodsWithResolutionErrors", "redefine", "()V");

    // Provoke the same error again to make sure the resolution error cache works
    createLoadNonExistentClassCode(mv, classExists);

    // Test passed
    mv.visitInsn(RETURN);

    mv.visitFrame(F_SAME, 0, new Object[0], 0, new Object[0]);
    mv.visitLabel(classExists);

    createThrowRuntimeExceptionCode(mv, "Loaded class that shouldn't exist (\"NonExistentClass\")");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:RedefineRunningMethodsWithResolutionErrors.java

示例3: createLoadNonExistentClassCode

import jdk.internal.org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
private static void createLoadNonExistentClassCode(MethodVisitor mv, Label classExists) {
    Label tryLoadBegin = new Label();
    Label tryLoadEnd = new Label();
    Label catchLoadBlock = new Label();
    mv.visitTryCatchBlock(tryLoadBegin, tryLoadEnd, catchLoadBlock, "java/lang/NoClassDefFoundError");

    // Try to load a class that does not exist to provoke resolution errors
    mv.visitLabel(tryLoadBegin);
    mv.visitMethodInsn(INVOKESTATIC, "NonExistentClass", "nonExistentMethod", "()V");
    mv.visitLabel(tryLoadEnd);

    // No NoClassDefFoundError means NonExistentClass existed, which shouldn't happen
    mv.visitJumpInsn(GOTO, classExists);

    mv.visitFrame(F_SAME1, 0, new Object[0], 1, new Object[] { "java/lang/NoClassDefFoundError" });
    mv.visitLabel(catchLoadBlock);

    // Ignore the expected NoClassDefFoundError
    mv.visitInsn(POP);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:RedefineRunningMethodsWithResolutionErrors.java


注:本文中的jdk.internal.org.objectweb.asm.MethodVisitor.visitFrame方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。