OpcodeStack.Item item = stack.getItemMethodInvokedOn(this); BugInstance bug = new BugInstance(this, "LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE", priority) .addClassAndMethod(this).addValueSource(item, this);
String sig = getSigConstantOperand(); if ((name.startsWith("set") || name.startsWith("update")) || sig.endsWith(")V")) { Item invokedOn = stack.getItemMethodInvokedOn(this); if (invokedOn.isInitialParameter() && invokedOn.getRegisterNumber() == 0) { updates++;
OpcodeStack.Item invokedOn = stack.getItemMethodInvokedOn(this); if (invokedOn.getRegisterNumber() == 0 && !classOperand.equals(getClassName())) { sawInitializeSuper = true;
case Const.INVOKESPECIAL: if (!getMethod().isStatic() && Const.CONSTRUCTOR_NAME.equals(getNameConstantOperand()) && isSelfOperation()) { OpcodeStack.Item invokedOn = stack.getItemMethodInvokedOn(this); if (invokedOn.isInitialParameter() && invokedOn.getRegisterNumber() == 0) { secondaryConstructor = true;
if ("()V".equals(sig) || "(Ljava/lang/String;)V".equals(sig) || "(Ljava/lang/ThreadGroup;Ljava/lang/String;)V".equals(sig)) { OpcodeStack.Item invokedOn = stack.getItemMethodInvokedOn(this); if (!Const.CONSTRUCTOR_NAME.equals(getMethodName()) || invokedOn.getRegisterNumber() != 0) { accumulator.accumulateBug(
@Override public void sawOpcode(int seen) { if (seen == INVOKEVIRTUAL) { if ("getName".equals(getNameConstantOperand()) && SignatureBuilder.SIG_VOID_TO_STRING.equals(getSigConstantOperand()) && Values.SLASHED_JAVA_LANG_CLASS.equals(getClassConstantOperand())) { flag = true; } else if ("equals".equals(getNameConstantOperand()) && SignatureBuilder.SIG_OBJECT_TO_BOOLEAN.equals(getSigConstantOperand()) && Values.SLASHED_JAVA_LANG_STRING.equals(getClassConstantOperand())) { Item item = stack.getItemMethodInvokedOn(this); Object srcValue = item.getUserValue(); item = stack.getStackItem(0); Object dstValue = item.getUserValue(); if (Boolean.TRUE.equals(srcValue) && Boolean.TRUE.equals(dstValue)) { bugReporter.reportBug(new BugInstance(this, BugType.CCNE_COMPARE_CLASS_EQUALS_NAME.name(), NORMAL_PRIORITY).addClass(this).addMethod(this) .addSourceLine(this)); } } } } }
@Override public void sawOpcode(int seen) { if (seen == Const.INVOKEVIRTUAL) { if ("getName".equals(getNameConstantOperand()) && SignatureBuilder.SIG_VOID_TO_STRING.equals(getSigConstantOperand()) && Values.SLASHED_JAVA_LANG_CLASS.equals(getClassConstantOperand())) { flag = true; } else if ("equals".equals(getNameConstantOperand()) && SignatureBuilder.SIG_OBJECT_TO_BOOLEAN.equals(getSigConstantOperand()) && Values.SLASHED_JAVA_LANG_STRING.equals(getClassConstantOperand())) { Item item = stack.getItemMethodInvokedOn(this); Object srcValue = item.getUserValue(); item = stack.getStackItem(0); Object dstValue = item.getUserValue(); if (Boolean.TRUE.equals(srcValue) && Boolean.TRUE.equals(dstValue)) { bugReporter.reportBug(new BugInstance(this, BugType.CCNE_COMPARE_CLASS_EQUALS_NAME.name(), NORMAL_PRIORITY).addClass(this).addMethod(this) .addSourceLine(this)); } } } } }
OpcodeStack.Item item = stack.getItemMethodInvokedOn(this); BugInstance bug = new BugInstance(this, "LG_LOST_LOGGER_DUE_TO_WEAK_REFERENCE", priority) .addClassAndMethod(this).addValueSource(item, this);
String sig = getSigConstantOperand(); if ((name.startsWith("set") || name.startsWith("update")) || sig.endsWith(")V")) { Item invokedOn = stack.getItemMethodInvokedOn(this); if (invokedOn.isInitialParameter() && invokedOn.getRegisterNumber() == 0) { updates++;
case Constants.INVOKESPECIAL: if (!getMethod().isStatic() && "<init>".equals(getNameConstantOperand()) && isSelfOperation()) { OpcodeStack.Item invokedOn = stack.getItemMethodInvokedOn(this); if (invokedOn.isInitialParameter() && invokedOn.getRegisterNumber() == 0) { secondaryConstructor = true;
OpcodeStack.Item invokedOn = stack.getItemMethodInvokedOn(this); if (invokedOn.getRegisterNumber() == 0 && !classOperand.equals(getClassName())) { sawInitializeSuper = true;
if ("()V".equals(sig) || "(Ljava/lang/String;)V".equals(sig) || "(Ljava/lang/ThreadGroup;Ljava/lang/String;)V".equals(sig)) { OpcodeStack.Item invokedOn = stack.getItemMethodInvokedOn(this); if (!"<init>".equals(getMethodName()) || invokedOn.getRegisterNumber() != 0) { accumulator.accumulateBug(