Program: 75140
Project: 75140
Buggy source:
/** 
 * Search for a class with a partial name in the current scope. It is called in   {@link #loadClass(String,boolean)}. <p> It takes the following steps in this name resolving: <ol> <li>Check if the name represents an array. An array type is treated as a special class in Java. The name of an array is either like "<tt>char[]</tt>" (source representation) or like "<tt>[C</tt>" (JVM internal representation). If this is the case, it recursively calls itself with the type of the elements in the array (if not primitive), and then loads the array class and return. </li> <li>Check if the name corresponds to a nested class in the current class. In JVM representation, nested class names are separated with "$" from their containers. If so, the nested class is returned. </li> <li>Check if the name is already a full class name, e.g., "<tt>java.lang.Class</tt>". If so, the class is loaded with   {@link URLClassLoader#loadClass(String,boolean)}and returned. Nested classes (case 2) take precedence over this full name resolution. </li> <li>For every class explicitly imported with   {@link #importClass(String)}, check if its simple class name (the last part) is the same as the first part of the class name to be searched for. If so, the imported class is loaded, and if necessary, its nested classes are searched. </li> <li>Check if the partial name is relative to the current package. </li> <li>Check if the partial name is relative to any package explicitly imported with   {@link #importPackage(String)}. The implicitly imported package "<tt>java.lang</tt>" is also searched. </li> </ol>
 * @param name The partial name of the class to be loaded.
 * @param resolve Whether {@link #resolveClass(Class)} should becalled.
 * @param currentClass The current class.
 * @return The class loaded with the given name in the scope.
 * @throws ClassNotFoundException If the class cannot be found.
 * @see #importClass(String)
 * @see #importPackage(String)
 * @see #loadClass(String,boolean)
 */
protected Class searchForClass(StringBuffer name,boolean resolve,Class currentClass) throws ClassNotFoundException {
  StringBuffer dollarName=new StringBuffer(name.toString().replace('.','$'));
  Class c=_checkArrayClass(name,resolve);
  if (c == null)   c=_checkNestedClass(dollarName,resolve,currentClass);
  if (c == null)   c=_checkFullClassName(name,resolve);
  if (c == null) {
    Iterator importedClassesIter=_importedClasses.iterator();
    while (c == null && importedClassesIter.hasNext())     c=_checkClassNameWithImportClass(dollarName,resolve,(ClassImport)importedClassesIter.next());
  }
  if (c == null && _packageName != null)   c=_checkClassNameWithImportPackage(dollarName,resolve,_packageName);
  if (c == null) {
    Iterator importedPackagesIter=_importedPackages.iterator();
    while (c == null && importedPackagesIter.hasNext())     c=_checkClassNameWithImportPackage(dollarName,resolve,(String)importedPackagesIter.next());
  }
  if (c == null)   c=_checkClassNameWithImportPackage(dollarName,resolve,"String_Node_Str");
  if (c == null) {
    int lastDotPos=name.length();
    while (c == null && lastDotPos != -1) {
      lastDotPos=name.lastIndexOf("String_Node_Str",lastDotPos);
      if (lastDotPos >= 0) {
        name.setCharAt(lastDotPos,'$');
        try {
          c=super.loadClass(name.toString(),resolve);
        }
 catch (        ClassNotFoundException e) {
        }
      }
    }
  }
  if (c == null)   throw new ClassNotFoundException(name.toString());
 else   return c;
}

Fixed version (ground truth):
/** 
 * Search for a class with a partial name in the current scope. It is called in   {@link #loadClass(String,boolean)}. <p> It takes the following steps in this name resolving: <ol> <li>Check if the name represents an array. An array type is treated as a special class in Java. The name of an array is either like "<tt>char[]</tt>" (source representation) or like "<tt>[C</tt>" (JVM internal representation). If this is the case, it recursively calls itself with the type of the elements in the array (if not primitive), and then loads the array class and return. </li> <li>Check if the name corresponds to a nested class in the current class. In JVM representation, nested class names are separated with "$" from their containers. If so, the nested class is returned. </li> <li>Check if the name is already a full class name, e.g., "<tt>java.lang.Class</tt>". If so, the class is loaded with   {@link URLClassLoader#loadClass(String,boolean)}and returned. Nested classes (case 2) take precedence over this full name resolution. </li> <li>For every class explicitly imported with   {@link #importClass(String)}, check if its simple class name (the last part) is the same as the first part of the class name to be searched for. If so, the imported class is loaded, and if necessary, its nested classes are searched. </li> <li>Check if the partial name is relative to the current package. </li> <li>Check if the partial name is relative to any package explicitly imported with   {@link #importPackage(String)}. The implicitly imported package "<tt>java.lang</tt>" is also searched. </li> </ol>
 * @param name The partial name of the class to be loaded.
 * @param resolve Whether {@link #resolveClass(Class)} should becalled.
 * @param currentClass The current class.
 * @return The class loaded with the given name in the scope.
 * @throws ClassNotFoundException If the class cannot be found.
 * @see #importClass(String)
 * @see #importPackage(String)
 * @see #loadClass(String,boolean)
 */
protected Class searchForClass(StringBuffer name,boolean resolve,Class currentClass) throws ClassNotFoundException {
  if (name.toString().equals("String_Node_Str")) {
    int i=0;
  }
  StringBuffer dollarName=new StringBuffer(name.toString().replace('.','$'));
  Class c=_checkArrayClass(name,resolve);
  if (c == null)   c=_checkNestedClass(dollarName,resolve,currentClass);
  if (c == null)   c=_checkFullClassName(name,resolve);
  if (c == null) {
    Iterator importedClassesIter=_importedClasses.iterator();
    while (c == null && importedClassesIter.hasNext())     c=_checkClassNameWithImportClass(dollarName,resolve,(ClassImport)importedClassesIter.next());
  }
  if (c == null && _packageName != null)   c=_checkClassNameWithImportPackage(dollarName,resolve,_packageName);
  if (c == null) {
    Iterator importedPackagesIter=_importedPackages.iterator();
    while (c == null && importedPackagesIter.hasNext())     c=_checkClassNameWithImportPackage(dollarName,resolve,(String)importedPackagesIter.next());
  }
  if (c == null)   c=_checkClassNameWithImportPackage(dollarName,resolve,"String_Node_Str");
  if (c == null) {
    int lastDotPos=name.length();
    while (c == null && lastDotPos != -1) {
      lastDotPos=name.lastIndexOf("String_Node_Str",lastDotPos);
      if (lastDotPos >= 0) {
        name.setCharAt(lastDotPos,'$');
        try {
          c=super.loadClass(name.toString(),resolve);
        }
 catch (        ClassNotFoundException e) {
        }
catch (        NoClassDefFoundError e) {
        }
      }
    }
  }
  if (c == null)   throw new ClassNotFoundException(name.toString());
 else   return c;
}