01: /*
02: * Bytecode analysis framework
03: * Copyright (C) 2005, University of Maryland
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
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.Set;
23: import java.util.SortedSet;
24:
25: import edu.umd.cs.findbugs.BugAnnotation;
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,
50: Location location, ValueNumber valueNumber,
51: IsNullValue refValue, ValueNumberFrame vnaFrame);
52:
53: /**
54: * Subclasses should override this method to capture locations where
55: * a redundant null comparision is performed.
56: *
57: * @param location the Location of the redundant null check
58: * @param redundantBranch the RedundantBranch
59: */
60: public void foundRedundantNullCheck(Location location,
61: RedundantBranch redundantBranch);
62:
63: /**
64: * Subclasses should override this method to capture values
65: * assigned null (or that become null through a comparison and branch)
66: * that are guaranteed to reach a dereference (ignoring
67: * implicit exception paths).
68: * @param assignedNullLocationSet set of locations where the value becomes null
69: * @param derefLocationSet set of locations where dereferences occur
70: * @param doomedLocations locations at which the value is doomed
71: * @param vna ValueNumberDataflow
72: * @param refValue the null value
73: * @param variableAnnotation TODO
74: * @param deref TODO
75: * @param npeIfStatementCovered true if doom location is a statement
76: */
77: public void foundGuaranteedNullDeref(
78: Set<Location> assignedNullLocationSet,
79: Set<Location> derefLocationSet,
80: SortedSet<Location> doomedLocations,
81: ValueNumberDataflow vna, ValueNumber refValue,
82: BugAnnotation variableAnnotation,
83: NullValueUnconditionalDeref deref,
84: boolean npeIfStatementCovered);
85: }
|