int priority = dynamicallyCreatedString ? NORMAL_PRIORITY : LOW_PRIORITY;  String sourceFile = jclass.getSourceFileName(); bugReporter.reportBug(new BugInstance("RC_REF_COMPARISON", priority) .addClassAndMethod(methodGen, sourceFile) .addSourceLine(methodGen, sourceFile, handle) .addClass(ot1.getClassName()).describe("CLASS_REFTYPE") );
int priority = LOW_PRIORITY; byte type1 = ot1.getType(); byte type2 = ot2.getType(); if (type1 == T_STATIC_STRING && type2 == T_STATIC_STRING) priority = LOW_PRIORITY + 1; else if (type1 == T_DYNAMIC_STRING || type2 == T_DYNAMIC_STRING) priority = HIGH_PRIORITY; else if (type1 == T_STATIC_STRING || type2 == T_STATIC_STRING) priority = NORMAL_PRIORITY;  if (priority <= LOW_PRIORITY) { String sourceFile = jclass.getSourceFileName(); bugReporter.reportBug(new BugInstance("RC_REF_COMPARISON", NORMAL_PRIORITY) .addClassAndMethod(methodGen, sourceFile) .addSourceLine(methodGen, sourceFile, handle) .addClass("java.lang.String").describe("CLASS_REFTYPE") ); }
	public void visitClassContext(ClassContext classContext) {		try {			final JavaClass jclass = classContext.getJavaClass();			Method[] methodList = jclass.getMethods();			for (int i = 0; i < methodList.length; ++i) {				Method method = methodList[i];				final MethodGen methodGen = classContext.getMethodGen(method);				if (methodGen == null)					continue;				// Prescreening - must have IF_ACMPEQ or IF_ACMPNE				BitSet bytecodeSet = classContext.getBytecodeSet(method);				if (!(bytecodeSet.get(Constants.IF_ACMPEQ) || bytecodeSet.get(Constants.IF_ACMPNE)))					continue;				if (DEBUG) System.out.println("FindRefComparison: analyzing " +					SignatureConverter.convertMethodSignature(methodGen));				callsIntern = dynamicallyCreatedString = false;				scanMethod(methodGen);				if (callsIntern)					continue;				final CFG cfg = classContext.getCFG(method);				final TypeDataflow typeDataflow = classContext.getTypeDataflow(method);				new LocationScanner(cfg).scan(new LocationScanner.Callback() {					public void visitLocation(Location location) {						try {							InstructionHandle handle = location.getHandle();							Instruction ins = handle.getInstruction();							short opcode = ins.getOpcode();							if (opcode == Constants.IF_ACMPEQ || opcode == Constants.IF_ACMPNE) {								TypeFrame frame = typeDataflow.getFactAtLocation(location);								if (frame.getStackDepth() < 2)									throw new AnalysisException("Stack underflow at " + handle);								int numSlots = frame.getNumSlots();								Type op1 = frame.getValue(numSlots - 1);								Type op2 = frame.getValue(numSlots - 2);									if (op1 instanceof ObjectType && op2 instanceof ObjectType) {									ObjectType ot1 = (ObjectType) op1;									ObjectType ot2 = (ObjectType) op2;										if (ot1.getClassName().equals("java.lang.String") &&										ot2.getClassName().equals("java.lang.String")) {										//System.out.println("String/String comparison!");										// Lower the priority if we didn't see a dynamically										// created String in the method.										int priority = dynamicallyCreatedString											? NORMAL_PRIORITY : LOW_PRIORITY;											String sourceFile = jclass.getSourceFileName();										bugReporter.reportBug(new BugInstance("RC_REF_COMPARISON", priority)											.addClassAndMethod(methodGen, sourceFile)											.addSourceLine(methodGen, sourceFile, handle)											.addClass(ot1.getClassName()).describe("CLASS_REFTYPE")										);										}								}							}						} catch (DataflowAnalysisException e) {							throw new AnalysisException("Caught exception: " + e.toString(), e);						}					}				});			}		} catch (DataflowAnalysisException e) {			throw new AnalysisException("Exception in FindRefComparison: " + e.getMessage(), e);		} catch (CFGBuilderException e) {			throw new AnalysisException("Exception in FindRefComparison: " + e.getMessage(), e);		}	}