Program: 59810
Project: 59810
Buggy source:
@SuppressWarnings("String_Node_Str") <T>T injectFromPlan(InjectionPlan<T> plan) throws InjectionException {
  if (!plan.isFeasible()) {
    throw new InjectionException("String_Node_Str" + plan.toPrettyString());
  }
  if (plan.isAmbiguous()) {
    throw new IllegalArgumentException("String_Node_Str" + plan.toPrettyString());
  }
  if (plan instanceof JavaInstance) {
    return ((JavaInstance<T>)plan).instance;
  }
 else   if (plan instanceof Constructor) {
    final Constructor<T> constructor=(Constructor<T>)plan;
    if (singletonInstances.containsKey(constructor.getNode())) {
      if (constructor.getNode().isUnit()) {
        return (T)singletonInstances.get(constructor.getNode());
      }
 else {
        throw new SingletonInjectionException("String_Node_Str" + constructor.getNode());
      }
    }
    Object[] args=new Object[constructor.getArgs().length];
    for (int i=0; i < constructor.getArgs().length; i++) {
      args[i]=injectFromPlan(constructor.getArgs()[i]);
    }
    if (!singletonInstances.containsKey(constructor.getNode())) {
      try {
        T ret=getConstructor((ConstructorDef<T>)constructor.getConstructorDef()).newInstance(args);
        if (c.isSingleton(constructor.getNode()) || constructor.getNode().isUnit()) {
          if (!singletonInstances.containsKey(constructor.getNode())) {
            singletonInstances.put(constructor.getNode(),ret);
          }
        }
        return ret;
      }
 catch (      ReflectiveOperationException e) {
        throw new InjectionException("String_Node_Str",e);
      }
    }
 else {
      return (T)singletonInstances.get(constructor.getNode());
    }
  }
 else   if (plan instanceof Subplan) {
    Subplan<T> ambiguous=(Subplan<T>)plan;
    if (ambiguous.isInjectable()) {
      Node ambigNode=ambiguous.getNode();
      boolean ambigIsUnit=ambigNode instanceof ClassNode && ((ClassNode<?>)ambigNode).isUnit();
      if (singletonInstances.containsKey(ambiguous.getNode())) {
        if (ambigIsUnit) {
          return (T)singletonInstances.get(ambiguous.getNode());
        }
 else {
          throw new SingletonInjectionException("String_Node_Str" + ambiguous.getNode());
        }
      }
      Object ret=injectFromPlan(ambiguous.getDelegatedPlan());
      if (c.isSingleton(ambiguous.getNode()) || ambigIsUnit) {
        singletonInstances.put((ClassNode<?>)ambiguous.getNode(),ret);
      }
      if (ret instanceof ExternalConstructor) {
        return ((ExternalConstructor<T>)ret).newInstance();
      }
 else {
        return (T)ret;
      }
    }
 else {
      if (ambiguous.getNumAlternatives() == 0) {
        throw new InjectionException("String_Node_Str" + plan.toPrettyString());
      }
 else {
        throw new InjectionException("String_Node_Str" + plan.toPrettyString());
      }
    }
  }
 else {
    throw new IllegalStateException("String_Node_Str" + plan);
  }
}

Fixed version (ground truth):
/** 
 * This gets really nasty now that constructors can invoke operations on us. The upshot is that we should check to see if singletons have been registered by callees after each recursive invocation of injectFromPlan or constructor invocations. The error handling currently bails if the thing we just instantiated should be discarded. This could happen if (for instance), a constructor did a bindVolatileInstance of its own class to an instance, or somehow triggered an injection of itself with a different plan (an injection of itself with the same plan would lead to an infinite recursion, so it's not really our problem).
 * @param plan
 * @return
 * @throws InjectionException
 */
@SuppressWarnings("String_Node_Str") <T>T injectFromPlan(InjectionPlan<T> plan) throws InjectionException {
  if (!plan.isFeasible()) {
    throw new InjectionException("String_Node_Str" + plan.toPrettyString());
  }
  if (plan.isAmbiguous()) {
    throw new IllegalArgumentException("String_Node_Str" + plan.toPrettyString());
  }
  if (plan instanceof JavaInstance) {
    return ((JavaInstance<T>)plan).instance;
  }
 else   if (plan instanceof Constructor) {
    final Constructor<T> constructor=(Constructor<T>)plan;
    if (singletonInstances.containsKey(constructor.getNode())) {
      return (T)singletonInstances.get(constructor.getNode());
    }
    Object[] args=new Object[constructor.getArgs().length];
    for (int i=0; i < constructor.getArgs().length; i++) {
      args[i]=injectFromPlan(constructor.getArgs()[i]);
    }
    if (!singletonInstances.containsKey(constructor.getNode())) {
      try {
        T ret=getConstructor((ConstructorDef<T>)constructor.getConstructorDef()).newInstance(args);
        if (c.isSingleton(constructor.getNode()) || constructor.getNode().isUnit()) {
          singletonInstances.put(constructor.getNode(),ret);
        }
        return ret;
      }
 catch (      ReflectiveOperationException e) {
        throw new InjectionException("String_Node_Str",e);
      }
    }
 else {
      return (T)singletonInstances.get(constructor.getNode());
    }
  }
 else   if (plan instanceof Subplan) {
    Subplan<T> ambiguous=(Subplan<T>)plan;
    if (ambiguous.isInjectable()) {
      Node ambigNode=ambiguous.getNode();
      boolean ambigIsUnit=ambigNode instanceof ClassNode && ((ClassNode<?>)ambigNode).isUnit();
      if (singletonInstances.containsKey(ambiguous.getNode())) {
        return (T)singletonInstances.get(ambiguous.getNode());
      }
      Object ret=injectFromPlan(ambiguous.getDelegatedPlan());
      if (c.isSingleton(ambiguous.getNode()) || ambigIsUnit) {
        singletonInstances.put((ClassNode<?>)ambiguous.getNode(),ret);
      }
      if (ret instanceof ExternalConstructor) {
        return ((ExternalConstructor<T>)ret).newInstance();
      }
 else {
        return (T)ret;
      }
    }
 else {
      if (ambiguous.getNumAlternatives() == 0) {
        throw new InjectionException("String_Node_Str" + plan.toPrettyString());
      }
 else {
        throw new InjectionException("String_Node_Str" + plan.toPrettyString());
      }
    }
  }
 else {
    throw new IllegalStateException("String_Node_Str" + plan);
  }
}