Program: 186627
Project: 186627
Buggy source:
/** 
 * For a given non-empty callstring, find all implementations which might get called by the last invocation in the callstring, i.e. find all methods which might appear in the next entry of the callstring. <p> This is only a lookup in the callgraph, and does not check if the invocation is a special invoke, so if callstring length of the callgraph is zero, the results are not correct. Instead use  {@link AppInfo#findImplementations(CallString)} which handles all special cases and falls backto the default callgraph. </p>
 * @param cs callstring of the invocation, must contain at least one invokesite.
 * @return a list of all methods which might get invoked by the top invocation of the callstring,with their callstrings.
 */
public Set<ExecutionContext> findImplementationContexts(CallString cs){
  if (cs.length() == 0) {
    throw new AssertionError("String_Node_Str");
  }
  InvokeSite invoke=cs.top();
  Set<ExecutionContext> methods=new HashSet<ExecutionContext>();
  MethodRef invokeeRef=invoke.getInvokeeRef();
  Set<ExecutionContext> invoker=getNodes(invoke.getInvoker());
  for (  ExecutionContext invokeNode : invoker) {
    for (    ContextEdge outEdge : callGraph.outgoingEdgesOf(invokeNode)) {
      CallString cgString=outEdge.getTarget().getCallString();
      if (cgString.isEmpty()) {
        if (outEdge.getTarget().getMethodInfo().overrides(invokeeRef,true)) {
          methods.add(outEdge.getTarget());
        }
      }
 else {
        if (cs.matches(cgString)) {
          methods.add(outEdge.getTarget());
        }
      }
    }
  }
  return methods;
}

Fixed version (ground truth):
/** 
 * For a given non-empty callstring, find all implementations which might get called by the last invocation in the callstring, i.e. find all methods which might appear in the next entry of the callstring. <p> This is only a lookup in the callgraph, and does not check if the invocation is a special invoke, so if callstring length of the callgraph is zero, the results are not correct. Instead use  {@link AppInfo#findImplementations(CallString)} which handles all special cases and falls backto the default callgraph. </p>
 * @param cs callstring of the invocation, must contain at least one invokesite.
 * @return a list of all methods which might get invoked by the top invocation of the callstring,with their callstrings.
 */
public Set<ExecutionContext> findImplementationContexts(CallString cs){
  if (cs.length() == 0) {
    throw new AssertionError("String_Node_Str");
  }
  InvokeSite invoke=cs.top();
  Set<ExecutionContext> methods=new HashSet<ExecutionContext>();
  MethodRef invokeeRef=invoke.getInvokeeRef();
  Set<ExecutionContext> invoker=getNodes(invoke.getInvoker());
  for (  ExecutionContext invokeNode : invoker) {
    for (    ContextEdge outEdge : callGraph.outgoingEdgesOf(invokeNode)) {
      CallString cgString=outEdge.getTarget().getCallString();
      if (cgString.isEmpty()) {
        if (invokeeRef.isInterfaceMethod() == Ternary.TRUE) {
          if (outEdge.getTarget().getMethodInfo().implementsMethod(invokeeRef)) {
            methods.add(outEdge.getTarget());
          }
        }
 else {
          if (outEdge.getTarget().getMethodInfo().overrides(invokeeRef,true)) {
            methods.add(outEdge.getTarget());
          }
        }
      }
 else {
        if (cs.matches(cgString)) {
          methods.add(outEdge.getTarget());
        }
      }
    }
  }
  return methods;
}