KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > edu > umd > cs > findbugs > ba > npe > NullDerefAndRedundantComparisonCollector


1 /*
2  * Bytecode analysis framework
3  * Copyright (C) 2005, University of Maryland
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19
20 package edu.umd.cs.findbugs.ba.npe;
21
22 import java.util.BitSet JavaDoc;
23 import java.util.Set JavaDoc;
24 import java.util.SortedSet JavaDoc;
25
26 import edu.umd.cs.findbugs.ba.ClassContext;
27 import edu.umd.cs.findbugs.ba.Location;
28 import edu.umd.cs.findbugs.ba.vna.ValueNumber;
29 import edu.umd.cs.findbugs.ba.vna.ValueNumberDataflow;
30 import edu.umd.cs.findbugs.ba.vna.ValueNumberFrame;
31
32 /**
33  * Callback interface for collecting null pointer derefs and
34  * redundant null comparisons.
35  *
36  * @see edu.umd.cs.findbugs.ba.npe.NullDerefAndRedundantComparisonFinder
37  * @author David Hovemeyer
38  */

39 public interface NullDerefAndRedundantComparisonCollector {
40     /**
41      * Subclasses should override this method to capture locations where
42      * a null pointer is dereferenced.
43      * @param classContext TODO
44      * @param location the Location of the null dereference
45      * @param valueNumber the ValueNumber of the possibly-null value
46      * @param refValue the kind of possibly-null value dereferenced
47      * @param vnaFrame The ValueNumber Frame at the point where the dereference occurred
48      */

49     public void foundNullDeref(ClassContext classContext, Location location, ValueNumber valueNumber, IsNullValue refValue, ValueNumberFrame vnaFrame);
50
51     /**
52      * Subclasses should override this method to capture locations where
53      * a redundant null comparision is performed.
54      *
55      * @param location the Location of the redundant null check
56      * @param redundantBranch the RedundantBranch
57      */

58     public void foundRedundantNullCheck(Location location, RedundantBranch redundantBranch);
59     
60     /**
61      * Subclasses should override this method to capture values
62      * assigned null (or that become null through a comparison and branch)
63      * that are guaranteed to reach a dereference (ignoring
64      * implicit exception paths).
65      * @param derefLocationSet set of locations where dereferences occur
66      * @param doomedLocations TODO
67      * @param vna TODO
68      * @param refValue the null value
69      * @param alwaysOnExceptionPath true if the location(s) where the value was observed
70      * to be null and unconditionally dereferenced were
71      * all on exception paths
72      * @param npeIfStatementCovered TODO
73      * @param assignedNullLocationSet set of locations where the value becomes null
74      */

75     public void foundGuaranteedNullDeref(
76             Set JavaDoc<Location> assignedNullLocationSet,
77             Set JavaDoc<Location> derefLocationSet,
78             SortedSet JavaDoc<Location> doomedLocations,
79             ValueNumberDataflow vna,
80             ValueNumber refValue,
81             boolean alwaysOnExceptionPath,
82             boolean npeIfStatementCovered);
83 }
84
Popular Tags