m_id = id;
m_category = category;
m_type = type;
- m_classes = null;
- m_methods = null;
- m_lines = null;
+
+ m_classes = new ArrayList<BugClass>();
+ m_methods = new ArrayList<BugMethod>();
+ m_lines = new ArrayList<SourceLine>();
+
m_locations = new ArrayList<Location>(Arrays.asList(locations));
m_locals = new ArrayList<LocalVariable>(Arrays.asList(variables));
}
bm.dump(pw, childIndent);
}
for (LocalVariable lv : m_locals) {
- lv.dump(pw, childIndent);
+ if (null != lv) {
+ lv.dump(pw, childIndent);
+ }
}
for (SourceLine sl : m_lines) {
sl.dump(pw, childIndent);
}
+ for (Location loc : m_locations) {
+ if (null != loc) {
+ loc.dump(pw, childIndent);
+ }
+ }
}
// Note that this is a heuristic, "fuzzy", equals.
}
}
else {
- if (! Util.objsAreEqual(thisLoc.getClassName(), thatLoc.getClassName())) {
+ if (! thisLoc.fuzzyEquals(thatLoc)) {
return false;
}
- if (! Util.objsAreEqual(thisLoc.getMethodName(), thatLoc.getMethodName())) {
- return false;
- }
- }
-
- if (! Util.objsAreEqual(this.getVariables(), that.getVariables())) {
- return false;
}
return true;
public int hashCode()
{
int code = Util.objHashCode(m_type)
- * Util.objHashCode(m_category)
- * Util.objHashCode(getPrincipalLocation())
- * Util.objHashCode(getVariables());
+ ^ Util.objHashCode(m_category)
+ ^ Util.objHashCode(getPrincipalLocation());
return code;
}
// This should be the place where the bug is reported.
Location getPrincipalLocation()
{
- if (null != m_locations && m_locations.size() > 0) {
- return m_locations.get(0);
+ if (null == m_locations) {
+ return null;
}
+
+ for (int idx = 0; idx < m_locations.size(); ++idx) {
+ Location loc = m_locations.get(idx);
+ if (Location.METHOD_CALLED.equals(loc.getMethodRole())) {
+ // METHOD_CALLED locations describe the method that is being called,
+ // but the bug is located in the caller, not in the callee.
+ // Thus, ignore this information about the callee.
+ continue;
+ }
+ return loc;
+ }
+
return null;
}