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


Java MethodVisitor.visitFrame方法代码示例

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


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

示例1: insertCollectionStart

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
private void insertCollectionStart(MethodVisitor mv) {
    // collection.iterator()
    mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Collection", "iterator", "()Ljava/util/Iterator;", true);
    mv.visitVarInsn(ASTORE, varArray);

    mv.visitLabel(loopStart);

    // Append a new frame preserving the same locals from the last one
    mv.visitFrame(F_APPEND, 2, new Object[]{BUILDER.getInternalName(), "java/util/Iterator"}, 0, null);

    // if(iterator.hasNext()) break;
    mv.visitVarInsn(ALOAD, varArray);
    mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "hasNext", "()Z", true);
    mv.visitJumpInsn(IFEQ, loopEnd);

    // (String)iterator.next()
    mv.visitVarInsn(ALOAD, varArray);
    mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "next", "()Ljava/lang/Object;", true);
    mv.visitTypeInsn(CHECKCAST, Type.getInternalName(member.component));
    mv.visitVarInsn(ASTORE, varObject);
}
 
开发者ID:Guichaguri,项目名称:FastMustache,代码行数:22,代码来源:LoopSection.java

示例2: accept

import 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:ItzSomebody,项目名称:DirectLeaks-AntiReleak-Remover,代码行数:29,代码来源:FrameNode.java

示例3: addGetMetaClass

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
private void addGetMetaClass() {
    Label lookup = new Label();

    MethodVisitor methodVisitor = cv.visitMethod(Opcodes.ACC_PUBLIC | Opcodes.ACC_SYNTHETIC, "getMetaClass", RETURN_META_CLASS, null, null);
    methodVisitor.visitCode();

    // if (this.metaClass != null) { return this.metaClass; }
    methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
    methodVisitor.visitFieldInsn(Opcodes.GETFIELD, className, META_CLASS_FIELD, META_CLASS_TYPE.getDescriptor());
    methodVisitor.visitInsn(Opcodes.DUP);
    methodVisitor.visitJumpInsn(Opcodes.IFNULL, lookup);
    methodVisitor.visitInsn(Opcodes.ARETURN);

    methodVisitor.visitLabel(lookup);
    methodVisitor.visitFrame(Opcodes.F_NEW, 1, new Object[]{className}, 1, new Object[]{META_CLASS_TYPE.getInternalName()});
    methodVisitor.visitVarInsn(Opcodes.ALOAD, 0); // for storing to field

    // GroovySystem.getMetaClassRegistry()
    methodVisitor.visitMethodInsn(Opcodes.INVOKESTATIC, GROOVY_SYSTEM_TYPE.getInternalName(), "getMetaClassRegistry", RETURN_META_CLASS_REGISTRY, false);

    // this.getClass()
    methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
    methodVisitor.visitMethodInsn(Opcodes.INVOKEVIRTUAL, OBJECT_TYPE.getInternalName(), "getClass", RETURN_CLASS, false);

    // getMetaClass(..)
    methodVisitor.visitMethodInsn(Opcodes.INVOKEINTERFACE, META_CLASS_REGISTRY_TYPE.getInternalName(), "getMetaClass", RETURN_META_CLASS_FROM_CLASS, true);

    // this.metaClass = <value>
    methodVisitor.visitFieldInsn(Opcodes.PUTFIELD, className, META_CLASS_FIELD, META_CLASS_TYPE.getDescriptor());

    // return this.metaClass
    methodVisitor.visitVarInsn(Opcodes.ALOAD, 0);
    methodVisitor.visitFieldInsn(Opcodes.GETFIELD, className, META_CLASS_FIELD, META_CLASS_TYPE.getDescriptor());

    methodVisitor.visitInsn(Opcodes.ARETURN);
    methodVisitor.visitMaxs(4, 1);
    methodVisitor.visitEnd();
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:39,代码来源:MixInLegacyTypesClassLoader.java

示例4: insertArrayStart

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
private void insertArrayStart(MethodVisitor mv, BytecodeGenerator generator) {
    // Store the array in a local variable
    mv.visitVarInsn(ASTORE, varArray);

    // array.length
    mv.visitVarInsn(ALOAD, varArray);
    mv.visitInsn(ARRAYLENGTH);
    mv.visitVarInsn(ISTORE, varLength);

    // i = 0
    mv.visitInsn(ICONST_0);
    mv.visitVarInsn(ISTORE, varIndex);

    mv.visitLabel(loopStart);

    // Create a compressed frame
    mv.visitFrame(F_FULL, 6, new Object[]{generator.className,
            generator.data.getDataType().getInternalName(), BUILDER.getInternalName(),
            member.clazzType.getInternalName(), INTEGER, INTEGER}, 0, new Object[0]);

    // if(index >= length) break;
    mv.visitVarInsn(ILOAD, varIndex);
    mv.visitVarInsn(ILOAD, varLength);
    mv.visitJumpInsn(IF_ICMPGE, loopEnd);

    // array[i]
    mv.visitVarInsn(ALOAD, varArray);
    mv.visitVarInsn(ILOAD, varIndex);
    mv.visitInsn(AALOAD);
    mv.visitVarInsn(ASTORE, varObject);
}
 
开发者ID:Guichaguri,项目名称:FastMustache,代码行数:32,代码来源:LoopSection.java

示例5: insertArrayEnd

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
private void insertArrayEnd(MethodVisitor mv) {
    mv.visitInsn(POP);
    mv.visitIincInsn(varIndex, 1);
    mv.visitJumpInsn(GOTO, loopStart);
    mv.visitLabel(loopEnd);
    mv.visitFrame(F_CHOP, 3, null, 0, null);
}
 
开发者ID:Guichaguri,项目名称:FastMustache,代码行数:8,代码来源:LoopSection.java

示例6: visitBlockStructured

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
private static void visitBlockStructured(ClassWriter cw, boolean normalReturnError, boolean tooMany) {
    String name = (tooMany ? "tooMany" : "tooFew") + "Exits" + (normalReturnError ? "" : "Exceptional");
    // Generate too many or too few exits down the either the normal or exceptional return
    // paths
    int exceptionalExitCount = normalReturnError ? 1 : (tooMany ? 2 : 0);
    int normalExitCount = normalReturnError ? (tooMany ? 2 : 0) : 1;
    MethodVisitor mv;
    mv = cw.visitMethod(ACC_PUBLIC, name, "(Ljava/lang/Object;Ljava/lang/Object;)Z", null, null);
    mv.visitCode();
    Label l0 = new Label();
    Label l1 = new Label();
    Label l2 = new Label();
    mv.visitTryCatchBlock(l0, l1, l2, null);
    Label l3 = new Label();
    mv.visitTryCatchBlock(l2, l3, l2, null);
    Label l4 = new Label();
    Label l5 = new Label();
    Label l6 = new Label();
    mv.visitTryCatchBlock(l4, l5, l6, null);
    Label l7 = new Label();
    mv.visitTryCatchBlock(l2, l7, l6, null);
    Label l8 = new Label();
    mv.visitLabel(l8);
    mv.visitVarInsn(ALOAD, 1);
    mv.visitInsn(DUP);
    mv.visitVarInsn(ASTORE, 3);
    mv.visitInsn(MONITORENTER);
    mv.visitLabel(l4);
    mv.visitVarInsn(ALOAD, 2);
    mv.visitInsn(DUP);
    mv.visitVarInsn(ASTORE, 4);
    mv.visitInsn(MONITORENTER);
    mv.visitLabel(l0);
    mv.visitVarInsn(ALOAD, 2);
    mv.visitVarInsn(ALOAD, 1);
    mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Object", "equals", "(Ljava/lang/Object;)Z", false);
    mv.visitVarInsn(ALOAD, 4);
    mv.visitInsn(MONITOREXIT);
    mv.visitLabel(l1);
    for (int i = 0; i < normalExitCount; i++) {
        mv.visitVarInsn(ALOAD, 3);
        mv.visitInsn(MONITOREXIT);
    }
    mv.visitLabel(l5);
    mv.visitInsn(IRETURN);
    mv.visitLabel(l2);
    mv.visitFrame(Opcodes.F_FULL, 5, new Object[]{INNER_CLASS_NAME_INTERNAL, "java/lang/Object", "java/lang/Object", "java/lang/Object",
                    "java/lang/Object"}, 1, new Object[]{"java/lang/Throwable"});
    mv.visitVarInsn(ALOAD, 4);
    mv.visitInsn(MONITOREXIT);
    mv.visitLabel(l3);
    mv.visitInsn(ATHROW);
    mv.visitLabel(l6);
    mv.visitFrame(Opcodes.F_FULL, 4, new Object[]{INNER_CLASS_NAME_INTERNAL, "java/lang/Object", "java/lang/Object", "java/lang/Object"}, 1,
                    new Object[]{"java/lang/Throwable"});
    for (int i = 0; i < exceptionalExitCount; i++) {
        mv.visitVarInsn(ALOAD, 3);
        mv.visitInsn(MONITOREXIT);
    }
    mv.visitLabel(l7);
    mv.visitInsn(ATHROW);
    Label l9 = new Label();
    mv.visitLabel(l9);
    mv.visitMaxs(2, 5);
    mv.visitEnd();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:67,代码来源:UnbalancedMonitorsTest.java

示例7: insertSetObject

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
static private void insertSetObject(ClassWriter cw, String classNameInternal, ArrayList<Field> fields) {
	int maxStack = 6;
	MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "set", "(Ljava/lang/Object;ILjava/lang/Object;)V", null, null);
	mv.visitCode();
	mv.visitVarInsn(ILOAD, 2);

	if (!fields.isEmpty()) {
		maxStack--;
		Label[] labels = new Label[fields.size()];
		for (int i = 0, n = labels.length; i < n; i++)
			labels[i] = new Label();
		Label defaultLabel = new Label();
		mv.visitTableSwitchInsn(0, labels.length - 1, defaultLabel, labels);

		for (int i = 0, n = labels.length; i < n; i++) {
			Field field = fields.get(i);
			Type fieldType = Type.getType(field.getType());

			mv.visitLabel(labels[i]);
			mv.visitFrame(F_SAME, 0, null, 0, null);
			mv.visitVarInsn(ALOAD, 1);
			mv.visitTypeInsn(CHECKCAST, classNameInternal);
			mv.visitVarInsn(ALOAD, 3);

			switch (fieldType.getSort()) {
			case Type.BOOLEAN:
				mv.visitTypeInsn(CHECKCAST, "java/lang/Boolean");
				mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Boolean", "booleanValue", "()Z");
				break;
			case Type.BYTE:
				mv.visitTypeInsn(CHECKCAST, "java/lang/Byte");
				mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Byte", "byteValue", "()B");
				break;
			case Type.CHAR:
				mv.visitTypeInsn(CHECKCAST, "java/lang/Character");
				mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Character", "charValue", "()C");
				break;
			case Type.SHORT:
				mv.visitTypeInsn(CHECKCAST, "java/lang/Short");
				mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Short", "shortValue", "()S");
				break;
			case Type.INT:
				mv.visitTypeInsn(CHECKCAST, "java/lang/Integer");
				mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Integer", "intValue", "()I");
				break;
			case Type.FLOAT:
				mv.visitTypeInsn(CHECKCAST, "java/lang/Float");
				mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Float", "floatValue", "()F");
				break;
			case Type.LONG:
				mv.visitTypeInsn(CHECKCAST, "java/lang/Long");
				mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Long", "longValue", "()J");
				break;
			case Type.DOUBLE:
				mv.visitTypeInsn(CHECKCAST, "java/lang/Double");
				mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/Double", "doubleValue", "()D");
				break;
			case Type.ARRAY:
				mv.visitTypeInsn(CHECKCAST, fieldType.getDescriptor());
				break;
			case Type.OBJECT:
				mv.visitTypeInsn(CHECKCAST, fieldType.getInternalName());
				break;
			}

			mv.visitFieldInsn(PUTFIELD, classNameInternal, field.getName(), fieldType.getDescriptor());
			mv.visitInsn(RETURN);
		}

		mv.visitLabel(defaultLabel);
		mv.visitFrame(F_SAME, 0, null, 0, null);
	}
	mv = insertThrowExceptionForFieldNotFound(mv);
	mv.visitMaxs(maxStack, 4);
	mv.visitEnd();
}
 
开发者ID:HankXV,项目名称:Limitart,代码行数:78,代码来源:FieldAccess.java

示例8: insertGetObject

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
static private void insertGetObject(ClassWriter cw, String classNameInternal, ArrayList<Field> fields) {
	int maxStack = 6;
	MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "get", "(Ljava/lang/Object;I)Ljava/lang/Object;", null, null);
	mv.visitCode();
	mv.visitVarInsn(ILOAD, 2);

	if (!fields.isEmpty()) {
		maxStack--;
		Label[] labels = new Label[fields.size()];
		for (int i = 0, n = labels.length; i < n; i++)
			labels[i] = new Label();
		Label defaultLabel = new Label();
		mv.visitTableSwitchInsn(0, labels.length - 1, defaultLabel, labels);

		for (int i = 0, n = labels.length; i < n; i++) {
			Field field = fields.get(i);

			mv.visitLabel(labels[i]);
			mv.visitFrame(F_SAME, 0, null, 0, null);
			mv.visitVarInsn(ALOAD, 1);
			mv.visitTypeInsn(CHECKCAST, classNameInternal);
			mv.visitFieldInsn(GETFIELD, classNameInternal, field.getName(), Type.getDescriptor(field.getType()));

			Type fieldType = Type.getType(field.getType());
			switch (fieldType.getSort()) {
			case Type.BOOLEAN:
				mv.visitMethodInsn(INVOKESTATIC, "java/lang/Boolean", "valueOf", "(Z)Ljava/lang/Boolean;");
				break;
			case Type.BYTE:
				mv.visitMethodInsn(INVOKESTATIC, "java/lang/Byte", "valueOf", "(B)Ljava/lang/Byte;");
				break;
			case Type.CHAR:
				mv.visitMethodInsn(INVOKESTATIC, "java/lang/Character", "valueOf", "(C)Ljava/lang/Character;");
				break;
			case Type.SHORT:
				mv.visitMethodInsn(INVOKESTATIC, "java/lang/Short", "valueOf", "(S)Ljava/lang/Short;");
				break;
			case Type.INT:
				mv.visitMethodInsn(INVOKESTATIC, "java/lang/Integer", "valueOf", "(I)Ljava/lang/Integer;");
				break;
			case Type.FLOAT:
				mv.visitMethodInsn(INVOKESTATIC, "java/lang/Float", "valueOf", "(F)Ljava/lang/Float;");
				break;
			case Type.LONG:
				mv.visitMethodInsn(INVOKESTATIC, "java/lang/Long", "valueOf", "(J)Ljava/lang/Long;");
				break;
			case Type.DOUBLE:
				mv.visitMethodInsn(INVOKESTATIC, "java/lang/Double", "valueOf", "(D)Ljava/lang/Double;");
				break;
			}

			mv.visitInsn(ARETURN);
		}

		mv.visitLabel(defaultLabel);
		mv.visitFrame(F_SAME, 0, null, 0, null);
	}
	insertThrowExceptionForFieldNotFound(mv);
	mv.visitMaxs(maxStack, 3);
	mv.visitEnd();
}
 
开发者ID:HankXV,项目名称:Limitart,代码行数:63,代码来源:FieldAccess.java

示例9: insertGetString

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
static private void insertGetString(ClassWriter cw, String classNameInternal, ArrayList<Field> fields) {
	int maxStack = 6;
	MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "getString", "(Ljava/lang/Object;I)Ljava/lang/String;", null,
			null);
	mv.visitCode();
	mv.visitVarInsn(ILOAD, 2);

	if (!fields.isEmpty()) {
		maxStack--;
		Label[] labels = new Label[fields.size()];
		Label labelForInvalidTypes = new Label();
		boolean hasAnyBadTypeLabel = false;
		for (int i = 0, n = labels.length; i < n; i++) {
			if (fields.get(i).getType().equals(String.class))
				labels[i] = new Label();
			else {
				labels[i] = labelForInvalidTypes;
				hasAnyBadTypeLabel = true;
			}
		}
		Label defaultLabel = new Label();
		mv.visitTableSwitchInsn(0, labels.length - 1, defaultLabel, labels);

		for (int i = 0, n = labels.length; i < n; i++) {
			if (!labels[i].equals(labelForInvalidTypes)) {
				mv.visitLabel(labels[i]);
				mv.visitFrame(F_SAME, 0, null, 0, null);
				mv.visitVarInsn(ALOAD, 1);
				mv.visitTypeInsn(CHECKCAST, classNameInternal);
				mv.visitFieldInsn(GETFIELD, classNameInternal, fields.get(i).getName(), "Ljava/lang/String;");
				mv.visitInsn(ARETURN);
			}
		}
		// Rest of fields: different type
		if (hasAnyBadTypeLabel) {
			mv.visitLabel(labelForInvalidTypes);
			mv.visitFrame(F_SAME, 0, null, 0, null);
			insertThrowExceptionForFieldType(mv, "String");
		}
		// Default: field not found
		mv.visitLabel(defaultLabel);
		mv.visitFrame(F_SAME, 0, null, 0, null);
	}
	insertThrowExceptionForFieldNotFound(mv);
	mv.visitMaxs(maxStack, 3);
	mv.visitEnd();
}
 
开发者ID:HankXV,项目名称:Limitart,代码行数:48,代码来源:FieldAccess.java

示例10: insertCollectionEnd

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
private void insertCollectionEnd(MethodVisitor mv) {
    mv.visitInsn(POP);
    mv.visitJumpInsn(GOTO, loopStart);
    mv.visitLabel(loopEnd);
    mv.visitFrame(F_CHOP, 1, null, 0, null);
}
 
开发者ID:Guichaguri,项目名称:FastMustache,代码行数:7,代码来源:LoopSection.java

示例11: insertSectionEnd

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
@Override
public void insertSectionEnd(MethodVisitor mv, BytecodeGenerator generator) {
    mv.visitInsn(POP);
    mv.visitLabel(ifEnd);
    mv.visitFrame(F_APPEND, 1, new Object[]{BUILDER.getInternalName()}, 0, null);
}
 
开发者ID:Guichaguri,项目名称:FastMustache,代码行数:7,代码来源:ConditionSection.java

示例12: findClass

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
    if (name.equals(NAME)) {
        ClassWriter cw = new ClassWriter(0);
        MethodVisitor mv;
        cw.visit(52, ACC_PUBLIC + ACC_SUPER, NAME, null, "java/lang/Object", null);

        mv = cw.visitMethod(ACC_PUBLIC + ACC_FINAL + ACC_STATIC, "run", "(I)J", null, null);
        mv.visitCode();
        Label begin = new Label();
        mv.visitLabel(begin);
        mv.visitVarInsn(ILOAD, 0);
        Label[] labels = new Label[numberBlocks];
        int[] keys = new int[numberBlocks];
        for (int i = 0; i < labels.length; i++) {
            labels[i] = new Label();
            keys[i] = i;
        }
        Label defaultLabel = new Label();
        mv.visitLookupSwitchInsn(defaultLabel, keys, labels);
        for (int i = 0; i < labels.length; i++) {
            mv.visitLabel(labels[i]);
            mv.visitFrame(Opcodes.F_NEW, 1, new Object[]{Opcodes.INTEGER}, 0, new Object[]{});
            mv.visitLdcInsn(new Long(LARGE_CONSTANT + i));
            mv.visitInsn(LRETURN);
        }
        mv.visitLabel(defaultLabel);
        mv.visitFrame(Opcodes.F_NEW, 1, new Object[]{Opcodes.INTEGER}, 0, new Object[]{});
        mv.visitLdcInsn(new Long(3L));
        mv.visitInsn(LRETURN);
        Label end = new Label();
        mv.visitLabel(end);
        mv.visitLocalVariable("a", "I", null, begin, end, 0);
        mv.visitMaxs(2, 1);
        mv.visitEnd();
        byte[] bytes = cw.toByteArray();
        return defineClass(name, bytes, 0, bytes.length);
    } else {
        return super.findClass(name);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:42,代码来源:LargeConstantSectionTest.java

示例13: visitWrongOrder

import org.objectweb.asm.MethodVisitor; //导入方法依赖的package包/类
private static void visitWrongOrder(ClassWriter cw) {
    MethodVisitor mv;
    mv = cw.visitMethod(ACC_PUBLIC, "wrongOrder", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;", null, null);
    mv.visitCode();
    Label l0 = new Label();
    Label l1 = new Label();
    Label l2 = new Label();
    mv.visitTryCatchBlock(l0, l1, l2, null);
    Label l3 = new Label();
    mv.visitTryCatchBlock(l2, l3, l2, null);
    Label l4 = new Label();
    Label l5 = new Label();
    Label l6 = new Label();
    mv.visitTryCatchBlock(l4, l5, l6, null);
    Label l7 = new Label();
    mv.visitTryCatchBlock(l2, l7, l6, null);
    Label l8 = new Label();
    mv.visitLabel(l8);
    mv.visitVarInsn(ALOAD, 1);
    mv.visitInsn(DUP);
    mv.visitVarInsn(ASTORE, 3);
    mv.visitInsn(MONITORENTER);
    mv.visitLabel(l4);
    mv.visitVarInsn(ALOAD, 2);
    mv.visitInsn(DUP);
    mv.visitVarInsn(ASTORE, 4);
    mv.visitInsn(MONITORENTER);
    mv.visitLabel(l0);
    mv.visitVarInsn(ALOAD, 2);
    mv.visitVarInsn(ALOAD, 3);
    mv.visitInsn(MONITOREXIT);
    mv.visitLabel(l1);
    // Swapped exit order with exit above
    mv.visitVarInsn(ALOAD, 4);
    mv.visitInsn(MONITOREXIT);
    mv.visitLabel(l5);
    mv.visitInsn(ARETURN);
    mv.visitLabel(l2);
    mv.visitFrame(Opcodes.F_FULL, 5, new Object[]{INNER_CLASS_NAME_INTERNAL, "java/lang/Object", "java/lang/Object", "java/lang/Object",
                    "java/lang/Object"}, 1, new Object[]{"java/lang/Throwable"});
    mv.visitVarInsn(ALOAD, 4);
    mv.visitInsn(MONITOREXIT);
    mv.visitLabel(l3);
    mv.visitInsn(ATHROW);
    mv.visitLabel(l6);
    mv.visitFrame(Opcodes.F_FULL, 4, new Object[]{INNER_CLASS_NAME_INTERNAL, "java/lang/Object", "java/lang/Object", "java/lang/Object"}, 1,
                    new Object[]{"java/lang/Throwable"});
    mv.visitVarInsn(ALOAD, 3);
    mv.visitInsn(MONITOREXIT);
    mv.visitLabel(l7);
    mv.visitInsn(ATHROW);
    Label l9 = new Label();
    mv.visitLabel(l9);
    mv.visitMaxs(2, 5);
    mv.visitEnd();
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:57,代码来源:UnbalancedMonitorsTest.java


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