本文整理汇总了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;
}
}
示例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\")");
}
示例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);
}