Java Code Examples for org.objectweb.asm.Opcodes#MONITORENTER

The following examples show how to use org.objectweb.asm.Opcodes#MONITORENTER . 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: RejectionMethodVisitor.java    From AVM with MIT License 5 votes vote down vote up
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);
    }
}
 
Example 2
Source File: MonitorInstrument.java    From dacapobench with Apache License 2.0 5 votes vote down vote up
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);
	}
}
 
Example 3
Source File: ClassParserUsingASM.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
@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();
}
 
Example 4
Source File: MonitoringFrame.java    From tascalate-javaflow with Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example 5
Source File: MonitoringFrame.java    From tascalate-javaflow with Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example 6
Source File: MonitoringFrame.java    From tascalate-javaflow with Apache License 2.0 5 votes vote down vote up
@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);
    }
}