org.objectweb.asm.Opcodes# MONITORENTER 源码实例Demo

下面列出了org.objectweb.asm.Opcodes# MONITORENTER 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: AVM   文件: RejectionMethodVisitor.java

private void checkOpcode(int opcode) {
    if (false
            // We reject JSR and RET (although these haven't been generated in a long time, anyway, and aren't allowed in new class files).
            || (Opcodes.JSR == opcode)
            || (Opcodes.RET == opcode)
            
            // We also want to reject instructions which could interact with the thread state:  MONITORENTER, MONITOREXIT.
            || (Opcodes.MONITORENTER == opcode)
            || (Opcodes.MONITOREXIT == opcode)
    ) {
        RejectedClassException.blacklistedOpcode(opcode);
    }
}
 
源代码2 项目: dacapobench   文件: MonitorInstrument.java

public void visitInsn(int opcode) {
	if (opcode == Opcodes.MONITORENTER) {
		has_monitor_operation = true;
		super.dup();
		super.visitInsn(opcode);
		super.visitMethodInsn(Opcodes.INVOKESTATIC, className, LOG_INTERNAL_ENTER_METHOD, LOG_OBJECT_SIGNATURE);
	} else if (opcode == Opcodes.MONITOREXIT) {
		has_monitor_operation = true;
		super.dup();
		super.visitMethodInsn(Opcodes.INVOKESTATIC, className, LOG_INTERNAL_EXIT_METHOD, LOG_OBJECT_SIGNATURE);
		super.visitInsn(opcode);
	} else {
		super.visitInsn(opcode);
	}
}
 
源代码3 项目: spotbugs   文件: ClassParserUsingASM.java

@Override
public void visitInsn(int opcode) {
    switch (opcode) {
    case Opcodes.MONITORENTER:
        mBuilder.setUsesConcurrency();
        break;
    case Opcodes.ARETURN:
    case Opcodes.IRETURN:
    case Opcodes.LRETURN:
    case Opcodes.DRETURN:
    case Opcodes.FRETURN:
        if (identityState == IdentityMethodState.LOADED_PARAMETER) {
            mBuilder.setIsIdentity();
        }
        sawReturn = true;
        break;
    case Opcodes.RETURN:
        sawReturn = true;
        break;
    case Opcodes.ATHROW:
        if (stubState == StubState.INITIALIZE_RUNTIME) {
            sawStubThrow = true;
        } else if (justSawInitializationOfUnsupportedOperationException) {
            sawUnsupportedThrow = true;
        } else {
            sawNormalThrow = true;
        }
        break;
    default:
        break;
    }

    resetState();
}
 

@Override
public void execute(AbstractInsnNode insn, Interpreter interpreter) throws AnalyzerException {

    boolean never = false;
    if (never) {
        super.execute(insn, interpreter);
        return;
    }

    int insnOpcode = insn.getOpcode();

    if (insnOpcode == Opcodes.MONITORENTER || insnOpcode == Opcodes.MONITOREXIT) {
        Value pop = pop();
        interpreter.unaryOperation(insn, pop);

        int local = -1;
        for (int i = 0; i < getLocals(); i++) {
            if (getLocal(i) == pop) local = i;
        }

        if (local > -1) {
            if (insnOpcode == Opcodes.MONITORENTER) {
                monitorEnter(local);
            } else {
                monitorExit(local);
            }
        }

    } else {
        super.execute(insn, interpreter);
    }
}
 

@Override
public void execute(AbstractInsnNode insn, Interpreter interpreter) throws AnalyzerException {

    boolean never = false;
    if (never) {
        super.execute(insn, interpreter);
        return;
    }

    int insnOpcode = insn.getOpcode();

    if (insnOpcode == Opcodes.MONITORENTER || insnOpcode == Opcodes.MONITOREXIT) {
        Value pop = pop();
        interpreter.unaryOperation(insn, pop);

        int local = -1;
        for (int i = 0; i < getLocals(); i++) {
            if (getLocal(i) == pop) local = i;
        }

        if (local > -1) {
            if (insnOpcode == Opcodes.MONITORENTER) {
                monitorEnter(local);
            } else {
                monitorExit(local);
            }
        }

    } else {
        super.execute(insn, interpreter);
    }
}
 

@Override
public void execute(AbstractInsnNode insn, Interpreter interpreter) throws AnalyzerException {

    boolean never = false;
    if (never) {
        super.execute(insn, interpreter);
        return;
    }

    int insnOpcode = insn.getOpcode();

    if (insnOpcode == Opcodes.MONITORENTER || insnOpcode == Opcodes.MONITOREXIT) {
        Value pop = pop();
        interpreter.unaryOperation(insn, pop);

        int local = -1;
        for (int i = 0; i < getLocals(); i++) {
            if (getLocal(i) == pop) local = i;
        }

        if (local > -1) {
            if (insnOpcode == Opcodes.MONITORENTER) {
                monitorEnter(local);
            } else {
                monitorExit(local);
            }
        }

    } else {
        super.execute(insn, interpreter);
    }
}
 
 方法所在类
 同类方法