public void visitIincInsn(int var, int increment) { // IINC counts as a read and a write but we need to regard it as a read, increment and then // write back // so we trigger AT READ, AFTER READ and AT WRITE before the IINC and AFTER WRITE after the // IINC boolean ruleIsAfterWrite = ((flags & Location.ACCESS_WRITE) != 0 && whenComplete); if (ruleIsAfterWrite) { // trigger comes after the IINC super.visitIincInsn(var, increment); } if (var == index) { // n.b. no need to check if we are in a Byteman trigegr as we never inject IINC into trigger // regions if ((count == 0 || (visitedCount < count))) { // a relevant invocation occurs in the called method visitedCount++; if (!latched && (count == 0 || visitedCount == count)) { injectTriggerPoint(); } } } if (!ruleIsAfterWrite) { // trigger comes before the IINC super.visitIincInsn(var, increment); } }
@Override public void visitVarInsn(int opcode, int var) { // this instruction can be called during trigger injection // if we in a trigger region then we don't want to re-enter // trigger injection or count this visit if (inBytemanTrigger()) { super.visitVarInsn(opcode, var); } else { if (whenComplete) { super.visitVarInsn(opcode, var); } if (var == index) { if ((count == 0 || (visitedCount < count)) && matchCall(opcode)) { // a relevant invocation occurs in the called method visitedCount++; if (!latched && (count == 0 || visitedCount == count)) { injectTriggerPoint(); } } } if (!whenComplete) { super.visitVarInsn(opcode, var); } } }