Program: 78488
Project: 78488
Buggy source:
/** 
 * Returns true if this <code>SubjectCodeSource</code> object "implies" the specified <code>CodeSource</code>. More specifically, this method makes the following checks. If any fail, it returns false.  If they all succeed, it returns true. <p> <ol> <li> The provided codesource must not be <code>null</code>. <li> codesource must be an instance of <code>SubjectCodeSource</code>. <li> super.implies(codesource) must return true. <li> for each principal in this codesource's principal list: <ol> <li>     if the principal is an instanceof <code>Principal</code>, then the principal must imply the provided codesource's <code>Subject</code>. <li>     if the principal is not an instanceof <code>Principal</code>, then the provided codesource's <code>Subject</code> must have an associated <code>Principal</code>, <i>P</i>, where P.getClass().getName equals principal.principalClass, and P.getName() equals principal.principalName. </ol> </ol> <p>
 * @param codesource the <code>CodeSource</code> to compare against.
 * @return true if this <code>SubjectCodeSource</code> implies thethe specified <code>CodeSource</code>.
 */
public boolean implies(CodeSource codesource){
  LinkedList<PrincipalEntry> subjectList=null;
  if (codesource == null || !(codesource instanceof SubjectCodeSource) || !(super.implies(codesource))) {
    if (debug != null)     debug.println("String_Node_Str");
    return false;
  }
  SubjectCodeSource that=(SubjectCodeSource)codesource;
  if (this.principals == null) {
    if (debug != null)     debug.println("String_Node_Str");
    return true;
  }
  if (that.getSubject() == null || that.getSubject().getPrincipals().size() == 0) {
    if (debug != null)     debug.println("String_Node_Str");
    return false;
  }
  ListIterator<PrincipalEntry> li=this.principals.listIterator(0);
  while (li.hasNext()) {
    PrincipalEntry pppe=li.next();
    try {
      Class<?> pClass=Class.forName(pppe.principalClass,true,sysClassLoader);
      if (!Principal.class.isAssignableFrom(pClass)) {
        throw new ClassCastException(pppe.principalClass + "String_Node_Str");
      }
      Constructor<?> c=pClass.getConstructor(PARAMS);
      Principal p=(Principal)c.newInstance(new Object[]{pppe.principalName});
      if (!p.implies(that.getSubject())) {
        if (debug != null)         debug.println("String_Node_Str");
        return false;
      }
 else {
        if (debug != null)         debug.println("String_Node_Str");
        return true;
      }
    }
 catch (    Exception e) {
      if (subjectList == null) {
        if (that.getSubject() == null) {
          if (debug != null)           debug.println("String_Node_Str" + "String_Node_Str");
          return false;
        }
        Iterator<Principal> i=that.getSubject().getPrincipals().iterator();
        subjectList=new LinkedList<PrincipalEntry>();
        while (i.hasNext()) {
          Principal p=i.next();
          PrincipalEntry spppe=new PrincipalEntry(p.getClass().getName(),p.getName());
          subjectList.add(spppe);
        }
      }
      if (!subjectListImpliesPrincipalEntry(subjectList,pppe)) {
        if (debug != null)         debug.println("String_Node_Str");
        return false;
      }
    }
  }
  if (debug != null)   debug.println("String_Node_Str");
  return true;
}

Fixed version (ground truth):
/** 
 * Returns true if this <code>SubjectCodeSource</code> object "implies" the specified <code>CodeSource</code>. More specifically, this method makes the following checks. If any fail, it returns false.  If they all succeed, it returns true. <p> <ol> <li> The provided codesource must not be <code>null</code>. <li> codesource must be an instance of <code>SubjectCodeSource</code>. <li> super.implies(codesource) must return true. <li> for each principal in this codesource's principal list: <ol> <li>     if the principal is an instanceof <code>Principal</code>, then the principal must imply the provided codesource's <code>Subject</code>. <li>     if the principal is not an instanceof <code>Principal</code>, then the provided codesource's <code>Subject</code> must have an associated <code>Principal</code>, <i>P</i>, where P.getClass().getName equals principal.principalClass, and P.getName() equals principal.principalName. </ol> </ol> <p>
 * @param codesource the <code>CodeSource</code> to compare against.
 * @return true if this <code>SubjectCodeSource</code> impliesthe specified <code>CodeSource</code>.
 */
public boolean implies(CodeSource codesource){
  LinkedList<PrincipalEntry> subjectList=null;
  if (codesource == null || !(codesource instanceof SubjectCodeSource) || !(super.implies(codesource))) {
    if (debug != null)     debug.println("String_Node_Str");
    return false;
  }
  SubjectCodeSource that=(SubjectCodeSource)codesource;
  if (this.principals == null) {
    if (debug != null)     debug.println("String_Node_Str");
    return true;
  }
  if (that.getSubject() == null || that.getSubject().getPrincipals().size() == 0) {
    if (debug != null)     debug.println("String_Node_Str");
    return false;
  }
  ListIterator<PrincipalEntry> li=this.principals.listIterator(0);
  while (li.hasNext()) {
    PrincipalEntry pppe=li.next();
    try {
      Class<?> pClass=Class.forName(pppe.principalClass,true,sysClassLoader);
      if (!Principal.class.isAssignableFrom(pClass)) {
        throw new ClassCastException(pppe.principalClass + "String_Node_Str");
      }
      Constructor<?> c=pClass.getConstructor(PARAMS);
      Principal p=(Principal)c.newInstance(new Object[]{pppe.principalName});
      if (!p.implies(that.getSubject())) {
        if (debug != null)         debug.println("String_Node_Str");
        return false;
      }
 else {
        if (debug != null)         debug.println("String_Node_Str");
        return true;
      }
    }
 catch (    Exception e) {
      if (subjectList == null) {
        if (that.getSubject() == null) {
          if (debug != null)           debug.println("String_Node_Str" + "String_Node_Str");
          return false;
        }
        Iterator<Principal> i=that.getSubject().getPrincipals().iterator();
        subjectList=new LinkedList<PrincipalEntry>();
        while (i.hasNext()) {
          Principal p=i.next();
          PrincipalEntry spppe=new PrincipalEntry(p.getClass().getName(),p.getName());
          subjectList.add(spppe);
        }
      }
      if (!subjectListImpliesPrincipalEntry(subjectList,pppe)) {
        if (debug != null)         debug.println("String_Node_Str");
        return false;
      }
    }
  }
  if (debug != null)   debug.println("String_Node_Str");
  return true;
}