private void sawInvokeInterfaceVirtual() { String sig = getSigConstantOperand(); int numParms = SignatureUtils.getNumParameters(sig); if (stack.getStackDepth() > numParms) { OpcodeStack.Item item = stack.getStackItem(numParms); Object uo = item.getUserValue(); if (uo != null) { String name = getNameConstantOperand(); if (isMethodThatShouldBeCalled(name)) { clearUserValue(item); } else if (!"clone".equals(name)) { if ((!Values.SIG_VOID.equals(SignatureUtils.getReturnSignature(sig))) && !nextOpIsPop()) { clearUserValue(item); } } } } processMethodParms(); }
private Object sawInvokeSpecial(Object userObject) { Object returnValue = userObject; String methodName = getNameConstantOperand(); if (Values.CONSTRUCTOR.equals(methodName)) { String clsName = getDottedClassConstantOperand(); if (doesObjectNeedToBeWatched(clsName)) { returnValue = Boolean.TRUE; } } processMethodParms(); return returnValue; }
private Object sawInvokeStatic(Object userObject) { if (doesStaticFactoryReturnNeedToBeWatched(getClassConstantOperand(), getNameConstantOperand(), getSigConstantOperand())) { return Boolean.TRUE; } return userObject; }
switch (seen) { case INVOKESPECIAL: userObject = sawInvokeSpecial(userObject); break; case INVOKEINTERFACE: case INVOKEVIRTUAL: sawInvokeInterfaceVirtual(); break; case INVOKESTATIC: userObject = sawInvokeStatic(userObject); processMethodParms(); break; case ARETURN: if (stack.getStackDepth() > 0) { OpcodeStack.Item item = stack.getStackItem(0); clearUserValue(item); } else { int prevOp = getPrevOpcode(1); if (OpcodeUtils.isALoad(prevOp)) { localSpecialObjects.clear(); case ASTORE_3: case ASTORE: sawAStore(seen); break; case ALOAD_3:
private void sawAStore(int seen) { int depth = stack.getStackDepth(); if (depth > 0) { OpcodeStack.Item item = stack.getStackItem(0); Object uo = item.getUserValue(); if (uo != null) { if (uo instanceof Boolean) { int reg = RegisterUtils.getAStoreReg(this, seen); localSpecialObjects.put(Integer.valueOf(reg), Integer.valueOf(getPC())); if (getPrevOpcode(1) == Const.DUP) { item = stack.getStackItem(1); item.setUserValue(Integer.valueOf(reg)); } } else { clearUserValue(item); } } } }
/** * Checks to see if any of the locals or fields that we are tracking are passed into another method. If they are, we clear out our tracking of them, because * we can't easily track their progress into the method. * * This can be overridden to check for exceptions to this rule, for example, being logged to the console not counting. */ protected void processMethodParms() { String sig = getSigConstantOperand(); int numParms = SignatureUtils.getNumParameters(sig); if ((numParms > 0) && (stack.getStackDepth() >= numParms)) { for (int i = 0; i < numParms; i++) { clearUserValue(stack.getStackItem(i)); } } }
private void sawPutStatic() { if (stack.getStackDepth() > 0) { OpcodeStack.Item item = stack.getStackItem(0); Object uo = item.getUserValue(); if ((uo != null) && !(uo instanceof Boolean)) { clearUserValue(item); } } }
@Override public void visitField(Field obj) { if (!isInnerClass && obj.isPrivate() && !obj.isSynthetic()) { String sig = obj.getSignature(); if (sig.startsWith(Values.SIG_QUALIFIED_CLASS_PREFIX)) { String type = SignatureUtils.stripSignature(sig); if (doesObjectNeedToBeWatched(type)) { fieldSpecialObjects.put(obj.getName(), obj.getSignature()); } } } }
switch (seen) { case Const.INVOKESPECIAL: userObject = sawInvokeSpecial(userObject); break; case Const.INVOKEINTERFACE: case Const.INVOKEVIRTUAL: sawInvokeInterfaceVirtual(); break; case Const.INVOKESTATIC: userObject = sawInvokeStatic(userObject); processMethodParms(); break; case Const.ARETURN: if (stack.getStackDepth() > 0) { OpcodeStack.Item item = stack.getStackItem(0); clearUserValue(item); } else { int prevOp = getPrevOpcode(1); if (OpcodeUtils.isALoad(prevOp)) { localSpecialObjects.clear(); case Const.ASTORE_3: case Const.ASTORE: sawAStore(seen); break; case Const.ALOAD_3:
private void sawAStore(int seen) { int depth = stack.getStackDepth(); if (depth > 0) { OpcodeStack.Item item = stack.getStackItem(0); Object uo = item.getUserValue(); if (uo != null) { if (uo instanceof Boolean) { int reg = RegisterUtils.getAStoreReg(this, seen); localSpecialObjects.put(Integer.valueOf(reg), Integer.valueOf(getPC())); if (getPrevOpcode(1) == DUP) { item = stack.getStackItem(1); item.setUserValue(Integer.valueOf(reg)); } } else { clearUserValue(item); } } } }
/** * Checks to see if any of the locals or fields that we are tracking are passed * into another method. If they are, we clear out our tracking of them, because * we can't easily track their progress into the method. * * This can be overridden to check for exceptions to this rule, for example, * being logged to the console not counting. */ protected void processMethodParms() { String sig = getSigConstantOperand(); int numParms = SignatureUtils.getNumParameters(sig); if ((numParms > 0) && (stack.getStackDepth() >= numParms)) { for (int i = 0; i < numParms; i++) { clearUserValue(stack.getStackItem(i)); } } }
private void sawPutField() { if (stack.getStackDepth() > 1) { OpcodeStack.Item item = stack.getStackItem(0); Object uo = item.getUserValue(); if ((uo != null) && !(uo instanceof Boolean)) { clearUserValue(item); } } }
@Override public void visitField(Field obj) { if (!isInnerClass && obj.isPrivate() && !obj.isSynthetic()) { String sig = obj.getSignature(); if (sig.startsWith(Values.SIG_QUALIFIED_CLASS_PREFIX)) { String type = SignatureUtils.stripSignature(sig); if (doesObjectNeedToBeWatched(type)) { fieldSpecialObjects.put(obj.getName(), obj.getSignature()); } } } }
private void sawInvokeInterfaceVirtual() { String sig = getSigConstantOperand(); int numParms = SignatureUtils.getNumParameters(sig); if (stack.getStackDepth() > numParms) { OpcodeStack.Item item = stack.getStackItem(numParms); Object uo = item.getUserValue(); if (uo != null) { String name = getNameConstantOperand(); if (isMethodThatShouldBeCalled(name)) { clearUserValue(item); } else if (!"clone".equals(name)) { if ((!Values.SIG_VOID.equals(SignatureUtils.getReturnSignature(sig))) && !nextOpIsPop()) { clearUserValue(item); } } } } processMethodParms(); }
private Object sawInvokeStatic(Object userObject) { if (doesStaticFactoryReturnNeedToBeWatched(getClassConstantOperand(), getNameConstantOperand(), getSigConstantOperand())) { return Boolean.TRUE; } return userObject; }
private Object sawInvokeSpecial(Object userObject) { Object returnValue = userObject; String methodName = getNameConstantOperand(); if (Values.CONSTRUCTOR.equals(methodName)) { String clsName = getDottedClassConstantOperand(); if (doesObjectNeedToBeWatched(clsName)) { returnValue = Boolean.TRUE; } } processMethodParms(); return returnValue; }
private void sawPutStatic() { if (stack.getStackDepth() > 0) { OpcodeStack.Item item = stack.getStackItem(0); Object uo = item.getUserValue(); if ((uo != null) && !(uo instanceof Boolean)) { clearUserValue(item); } } }
private void handleTernary(int seen) { if (((seen == GETFIELD) || (seen == ALOAD) || OpcodeUtils.isALoad(seen)) && (stack.getStackDepth() > 0)) { OpcodeStack.Item item = stack.getStackItem(0); clearUserValue(item); } /* * check ALOAD_0, as if it's a field the statement after a GOTO will be * loading 'this' */ if ((seen != GOTO) && (seen != IFNULL) && (seen != IFNONNULL) && (seen != ALOAD_0)) { sawTernary = false; } }