private void examineNullValues ( ) throws CFGBuilderException , DataflowAnalysisException { Set < LocationWhereValueBecomesNull > locationWhereValueBecomesNullSet = invDataflow . getAnalysis ( ) . getLocationWhereValueBecomesNullSet ( ) ; if ( DEBUG_DEREFS ) { System . out . println ( "----------------------- examineNullValues " + locationWhereValueBecomesNullSet . size ( ) ) ; } Map < ValueNumber , SortedSet < Location > > bugStatementLocationMap = new HashMap <> ( ) ; // Inspect the method for locations where a null value is guaranteed to // be dereferenced. Add the dereference locations Map < ValueNumber , NullValueUnconditionalDeref > nullValueGuaranteedDerefMap = new HashMap <> ( ) ; // Check every location CFG cfg = classContext . getCFG ( method ) ; for ( Iterator < Location > i = cfg . locationIterator ( ) ; i . hasNext ( ) ; ) { Location location = i . next ( ) ; if ( DEBUG_DEREFS ) { System . out . println ( "At location " + location ) ; } checkForUnconditionallyDereferencedNullValues ( location , bugStatementLocationMap , nullValueGuaranteedDerefMap , vnaDataflow . getFactAtLocation ( location ) , invDataflow . getFactAtLocation ( location ) , uvdDataflow . getFactAfterLocation ( location ) , false ) ; } HashSet < ValueNumber > npeIfStatementCovered = new HashSet <> ( nullValueGuaranteedDerefMap . keySet ( ) ) ; Map < ValueNumber , SortedSet < Location > > bugEdgeLocationMap = new HashMap <> ( ) ; checkEdges ( cfg , nullValueGuaranteedDerefMap , bugEdgeLocationMap ) ; Map < ValueNumber , SortedSet < Location > > bugLocationMap = bugEdgeLocationMap ; bugLocationMap . putAll ( bugStatementLocationMap ) ; // For each value number that is null somewhere in the // method, collect the set of locations where it becomes null. // FIXME: we may see some locations that are not guaranteed to be // dereferenced (how to fix this?) Map < ValueNumber , Set < Location > > nullValueAssignmentMap = findNullAssignments ( locationWhereValueBecomesNullSet ) ; reportBugs ( nullValueGuaranteedDerefMap , npeIfStatementCovered , bugLocationMap , nullValueAssignmentMap ) ; }
Examine null values . Report any that are guaranteed to be dereferenced on non - implicit - exception paths .