Refine search
private void markArraysHardCodedOrNot() { if (hasHardCodedStackItem(0) && hasHardCodedStackItem(1)) { if (isFirstArrayStore) { setHardCodedItem(2); } } else { // then array not hard coded stack.getStackItem(2).setUserValue(null); } }
private void processAStore(int seen) { if (stack.getStackDepth() > 0) { OpcodeStack.Item item = stack.getStackItem(0); Integer allocation = (Integer) item.getUserValue(); if (allocation != null) { Integer reg = Integer.valueOf(RegisterUtils.getAStoreReg(this, seen)); if (isFirstUse(reg.intValue())) { if (storedAllocations.values().contains(allocation)) { allocations.remove(allocation); storedAllocations.remove(reg); } else if (storedAllocations.containsKey(reg)) { allocations.remove(allocation); allocation = storedAllocations.remove(reg); allocations.remove(allocation); } else { storedAllocations.put(reg, allocation); } } else { item.setUserValue(null); allocations.remove(allocation); } } } }
private void processAStore(int seen) { if (stack.getStackDepth() > 0) { OpcodeStack.Item item = stack.getStackItem(0); Integer allocation = (Integer) item.getUserValue(); if (allocation != null) { Integer reg = Integer.valueOf(RegisterUtils.getAStoreReg(this, seen)); if (isFirstUse(reg.intValue())) { if (storedAllocations.values().contains(allocation)) { allocations.remove(allocation); storedAllocations.remove(reg); } else if (storedAllocations.containsKey(reg)) { allocations.remove(allocation); allocation = storedAllocations.remove(reg); allocations.remove(allocation); } else { storedAllocations.put(reg, allocation); } } else { item.setUserValue(null); allocations.remove(allocation); } } } }
/** * called after the execution of the parent OpcodeStack.sawOpcode, to restore the user values after the GOTO or GOTO_W's mergeJumps were processed * * @param stack * the OpcodeStack with the items containing user values * @param opcode * the opcode currently seen */ public static void post(OpcodeStack stack, int opcode) { if (!sawGOTO || (opcode == Const.GOTO) || (opcode == Const.GOTO_W)) { return; } int depth = stack.getStackDepth(); for (int i = 0; i < depth && i < userValues.size(); i++) { OpcodeStack.Item item = stack.getStackItem(i); if (item.getUserValue() == null) { item.setUserValue(userValues.get(i)); } } userValues.clear(); sawGOTO = false; } }
/** * called after the execution of the parent OpcodeStack.sawOpcode, to * restore the user values after the GOTO or GOTO_W's mergeJumps were * processed * * @param stack * the OpcodeStack with the items containing user values * @param opcode * the opcode currently seen */ public static void post(OpcodeStack stack, int opcode) { if (!sawGOTO || (opcode == Constants.GOTO) || (opcode == Constants.GOTO_W)) { return; } int depth = stack.getStackDepth(); for (int i = 0; i < depth && i < userValues.size(); i++) { OpcodeStack.Item item = stack.getStackItem(i); if (item.getUserValue() == null) { item.setUserValue(userValues.get(i)); } } userValues.clear(); sawGOTO = false; } }
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); } } } }
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); } } } }
Set<Object> values = fieldValues.get(fieldName); if (values != null) { OpcodeStack.Item item = stack.getStackItem(0); Object cons = item.getConstant(); if ((cons == null) && (item.getUserValue() == null)) { stack.sawOpcode(this, seen); if ((explicitNull) && (stack.getStackDepth() > 0)) { OpcodeStack.Item itm = stack.getStackItem(0); itm.setUserValue(Boolean.TRUE);
Set<Object> values = fieldValues.get(fieldName); if (values != null) { OpcodeStack.Item item = stack.getStackItem(0); Object cons = item.getConstant(); if ((cons == null) && (item.getUserValue() == null)) { stack.sawOpcode(this, seen); if ((explicitNull) && (stack.getStackDepth() > 0)) { OpcodeStack.Item itm = stack.getStackItem(0); itm.setUserValue(Boolean.TRUE);
@Override public void afterOpcode(int seen) { super.afterOpcode(seen); if (flag) { stack.getStackItem(0).setUserValue(Boolean.TRUE); flag = false; } }
@Override public void afterOpcode(int seen) { super.afterOpcode(seen); if (flag) { stack.getStackItem(0).setUserValue(Boolean.TRUE); flag = false; } }
private void memorizeResultOfGetClassMethod(int code) { Item caller = getStack().getStackItem(0); JavaType classOfCaller; try { classOfCaller = JavaType.from(caller.getJavaClass()); } catch (ClassNotFoundException e) { throw new AssertionError(e); } finally { super.afterOpcode(code); } Item returnedClass = getStack().getStackItem(0); returnedClass.setUserValue(classOfCaller); }
private void checkImmutableUsageOfStringBuilder(int reg) { if (stack.getStackDepth() > 0) { OpcodeStack.Item item = stack.getStackItem(0); SPPUserValue userValue = (SPPUserValue) item.getUserValue(); if (userValue != null) { if (userValue.getMethod() == SPPMethod.TRIM) { item.setUserValue(null); } else if (userValue.getMethod() == SPPMethod.APPEND) { Matcher m = APPEND_PATTERN.matcher(userValue.getDetails()); if (m.matches()) { int appendReg = Integer.parseInt(m.group(1)); if (reg == appendReg) { bugReporter.reportBug(new BugInstance(this, BugType.SPP_STRINGBUILDER_IS_MUTABLE.name(), NORMAL_PRIORITY).addClass(this) .addMethod(this).addSourceLine(this)); } } } } } }
private void checkImmutableUsageOfStringBuilder(int reg) { if (stack.getStackDepth() > 0) { OpcodeStack.Item item = stack.getStackItem(0); SPPUserValue userValue = (SPPUserValue) item.getUserValue(); if (userValue != null) { if (userValue.getMethod() == SPPMethod.TRIM) { item.setUserValue(null); } else if (userValue.getMethod() == SPPMethod.APPEND) { Matcher m = APPEND_PATTERN.matcher(userValue.getDetails()); if (m.matches()) { int appendReg = Integer.parseInt(m.group(1)); if (reg == appendReg) { bugReporter.reportBug(new BugInstance(this, BugType.SPP_STRINGBUILDER_IS_MUTABLE.name(), NORMAL_PRIORITY).addClass(this) .addMethod(this).addSourceLine(this)); } } } } } }
OpcodeStack.Item item = stack.getStackItem(0); Integer reg = Integer.valueOf(RegisterUtils.getAStoreReg(this, seen)); if (item.getUserValue() != null) { TernaryPatcher.post(stack, seen); if ((methodPackage != null) && (stack.getStackDepth() > 0)) { OpcodeStack.Item item = stack.getStackItem(0); item.setUserValue(methodPackage);
private void markArraysHardCodedOrNot() { if (hasHardCodedStackItem(0) && hasHardCodedStackItem(1)) { if (isFirstArrayStore) { setHardCodedItem(2); } } else { // then array not hard coded stack.getStackItem(2).setUserValue(null); } }
OpcodeStack.Item item = stack.getStackItem(0); Integer reg = Integer.valueOf(RegisterUtils.getAStoreReg(this, seen)); if (item.getUserValue() != null) { TernaryPatcher.post(stack, seen); if ((methodPackage != null) && (stack.getStackDepth() > 0)) { OpcodeStack.Item item = stack.getStackItem(0); item.setUserValue(methodPackage);
/** * determines whether this operation is storing the result of a trim() call, where the trimmed string was duplicated on the stack. If it was, it clears any * trim uservalue that was left behind in the dupped stack object */ private void checkTrimDupStore() { if ((stack.getStackDepth() >= 2) && (getPrevOpcode(1) == Const.DUP)) { OpcodeStack.Item item = stack.getStackItem(0); SPPUserValue uv = (SPPUserValue) item.getUserValue(); if ((uv == null) || (uv.getMethod() != SPPMethod.TRIM)) { return; } item = stack.getStackItem(1); uv = (SPPUserValue) item.getUserValue(); if ((uv == null) || (uv.getMethod() != SPPMethod.TRIM)) { return; } item.setUserValue(null); } }
/** * determines whether this operation is storing the result of a trim() call, where the trimmed string was duplicated on the stack. If it was, it clears any * trim uservalue that was left behind in the dupped stack object */ private void checkTrimDupStore() { if ((stack.getStackDepth() >= 2) && (getPrevOpcode(1) == Constants.DUP)) { OpcodeStack.Item item = stack.getStackItem(0); SPPUserValue uv = (SPPUserValue) item.getUserValue(); if ((uv == null) || (uv.getMethod() != SPPMethod.TRIM)) { return; } item = stack.getStackItem(1); uv = (SPPUserValue) item.getUserValue(); if ((uv == null) || (uv.getMethod() != SPPMethod.TRIM)) { return; } item.setUserValue(null); } }
OpcodeStack.Item itm = stack.getStackItem(0); String duppedSig = itm.getSignature(); if ("Ljava/lang/StringBuilder;".equals(duppedSig) || "Ljava/lang/StringBuffer;".equals(duppedSig)) { itm.setUserValue(UCPMUserValue.INLINE); OpcodeStack.Item itm = stack.getStackItem(0); itm.setUserValue(null); OpcodeStack.Item itm = stack.getStackItem(0); itm.setUserValue(uv);