else {
else if (isCast) {
	private void analyzeMethod(ClassContext classContext, Method method) throws CFGBuilderException, DataflowAnalysisException {		CFG cfg = classContext.getCFG(method);		TypeDataflow typeDataflow = classContext.getTypeDataflow(method);		ValueNumberDataflow vnaDataflow = classContext.getValueNumberDataflow(method);		 // get the ValueNumberFrame at entry to a method:		 ValueNumberFrame vnaFrameAtEntry 			= vnaDataflow.getStartFact(cfg.getEntry());		// get Set of parameter values		 Set<ValueNumber> paramValueNumberSet = new HashSet<ValueNumber>();		 int firstParam = method.isStatic() ? 0 : 1;		 for (int i = firstParam; i < vnaFrameAtEntry.getNumLocals(); ++i) {		   paramValueNumberSet.add(vnaFrameAtEntry.getValue(i));		 }		 					ConstantPoolGen cpg = classContext.getConstantPoolGen();		MethodGen methodGen = classContext.getMethodGen(method);		String methodName = methodGen.getClassName() + "." +					methodGen.getName();                String sourceFile = classContext.getJavaClass().getSourceFileName();		 if (DEBUG) {			System.out.println("Checking " + methodName);			}				for (Iterator<Location> i = cfg.locationIterator(); i.hasNext(); ) {			Location location = i.next();			InstructionHandle handle = location.getHandle();			int pc = handle.getPosition();			Instruction ins = handle.getInstruction();			if (!(ins instanceof CHECKCAST) && !(ins instanceof INSTANCEOF))				continue;			boolean isCast = ins instanceof CHECKCAST;			String kind = isCast ? "checkedCast" : "instanceof";			int occurrences = cfg.getLocationsContainingInstructionWithOffset(pc).size();			boolean split = occurrences > 1;			if (DEBUG) {				System.out.println(kind + " at pc: " + pc + " in " + methodName);				System.out.println(" occurrences: " + occurrences);				}			if (split && !isCast)  {				// don't report this case; it might be infeasible due to inlining				continue;				}						TypeFrame frame = typeDataflow.getFactAtLocation(location);			if (!frame.isValid()) {				// This basic block is probably dead				continue;			}						Type operandType = frame.getTopValue();			if (operandType.equals(TopType.instance()))  {				// unreachable				continue;			}			if (!(operandType instanceof ReferenceType)) {				// Shouldn't happen - illegal bytecode				continue;			}			ReferenceType refType = (ReferenceType) operandType;			Type castType = ((TypedInstruction) ins) .getType(cpg);			if (!(castType instanceof ReferenceType)) {				// This shouldn't happen either				continue;			}			if (refType.equals(castType)) {				// System.out.println("self-cast to " + castType.getSignature());				continue;				}			if (refType.equals(NullType.instance())) {				// Value is a literal null				System.out.println("cast of null value to " + castType.getSignature() + " in " + methodName);				continue;				}			String castSig = castType.getSignature();			String refSig = refType.getSignature();			String castSig2 = castSig;			String refSig2 = refSig;			while (castSig2.charAt(0) == '[' && refSig2.charAt(0) == '[') {				castSig2 = castSig2.substring(1);				refSig2 = refSig2.substring(1);				}							if (refSig2.equals("Ljava/lang/Object;")) {				// System.out.println("cast of object value to " + castType.getSignature());				continue;				}			if (refSig2.charAt(0) != 'L'			    || castSig2.charAt(0) != 'L') {				// cast involving primative arrays				continue;				}			String castName = castSig2.substring(1,castSig2.length()-1)				.replace('/','.');			String refName = refSig2.substring(1,refSig2.length()-1)				.replace('/','.');			ValueNumberFrame vFrame = vnaDataflow.getFactAtLocation(location);			boolean isParameter = paramValueNumberSet.contains(vFrame.getTopValue());			try {				JavaClass castJavaClass = Repository.lookupClass(castName);			JavaClass refJavaClass = Repository.lookupClass(refName);			boolean upcast = Repository.instanceOf( refJavaClass, castJavaClass);			if (!upcast) {			boolean downcast = 				Repository.instanceOf( castJavaClass, refJavaClass);			boolean completeInformation = 			    (!castJavaClass.isInterface() && !refJavaClass.isInterface())						 || refJavaClass.isFinal()						 || castJavaClass.isFinal();			if (DEBUG) {				System.out.println("cast from " + refName + " to " + castName);				System.out.println("  is downcast: " + downcast);				System.out.println("  complete information: " +completeInformation);				System.out.println("  isParameter: " + vFrame.getTopValue());				}			if (!downcast && completeInformation) 			  bugReporter.reportBug(new BugInstance(this,                                isCast  ? "BC_IMPOSSIBLE_CAST"  : "BC_IMPOSSIBLE_INSTANCEOF",                                isCast  ? HIGH_PRIORITY : NORMAL_PRIORITY)				  .addClassAndMethod(methodGen, sourceFile)				  .addSourceLine(methodGen, sourceFile, location.getHandle())					.addClass(refName.replace("/","."))					.addClass(castName.replace("/","."))					);			else {			int priority = NORMAL_PRIORITY;						 if (downcast)                                priority+=2;                        if (DEBUG)                                System.out.println(" priority a: " + priority);                        if (methodGen.getClassName().equals(refName)                              || methodGen.getClassName().equals(castName))                                priority+=1;                        if (DEBUG)                                System.out.println(" priority b: " + priority);                        if (castJavaClass.isInterface()) priority++;                        if (DEBUG)                                System.out.println(" priority c: " + priority);                        if (priority <= LOW_PRIORITY && (refJavaClass.isInterface()                                || refJavaClass.isAbstract())) priority++;                        if (DEBUG)                                System.out.println(" priority d: " + priority);                        if (DEBUG)                                System.out.println(" ref name: " + refName);                        if (concreteCollectionClasses.contains(refName)                            || abstractCollectionClasses.contains(refName))                                priority--;                        if (DEBUG)                                System.out.println(" priority e: " + priority);                        if (concreteCollectionClasses.contains(castName)                            || abstractCollectionClasses.contains(castName))                                priority--;                        if (DEBUG)                                System.out.println(" priority f: " + priority);			 if (methodGen.getName().equals("compareTo"))                                priority++;                        if (DEBUG)                                System.out.println(" priority g: " + priority);			 if (methodGen.isPublic() && isParameter)                                priority--;                        if (DEBUG)                                System.out.println(" priority h: " + priority);			if (priority < HIGH_PRIORITY)                                priority = HIGH_PRIORITY;                        if (priority <= LOW_PRIORITY) {                                String bug =  "BC_UNCONFIRMED_CAST";                                if (concreteCollectionClasses.contains(castName))                                  bug =  "BC_BAD_CAST_TO_CONCRETE_COLLECTION";                                else if (abstractCollectionClasses.contains(castName)                                        && (refName.equals("java/util/Collection")                                           ||  refName.equals("java/lang/Iterable") ))                                  bug = "BC_BAD_CAST_TO_ABSTRACT_COLLECTION";                                  bugReporter.reportBug(new BugInstance(this, bug, priority)				  .addClassAndMethod(methodGen, sourceFile)				  .addSourceLine(methodGen, sourceFile, location.getHandle())					.addClass(refName.replace("/","."))					.addClass(castName.replace("/","."))					);				}                   			}					}} catch (ClassNotFoundException e) {}		}	}