Program: 46824
Project: 46824
Buggy source:
/** 
 * Converts an string to its java counterpart
 * @param loader for custom types
 * @throws ClassNotFoundException if custom type could not be found
 * @throws SecurityException
 * @throws NoSuchMethodException
 * @throws InvocationTargetException
 * @throws IllegalArgumentException
 * @throws IllegalAccessException
 * @throws InstantiationException
 */
public Object string2type(String string,final ClassLoader loader) throws ClassNotFoundException, NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
  if (string == null || string.length() == 0)   return null;
  Matcher match;
  string=string.trim();
  match=PT_ARRAY_STRING.matcher(string);
  if (match.matches())   return match.group(1).split(ARRAY_DELIMITER);
  match=PT_ARRAY_BYTE.matcher(string);
  if (match.matches()) {
    final String[] vals=match.group(1).split(ARRAY_DELIMITER);
    final byte[] res=new byte[vals.length];
    for (int i=0; i < res.length; i++)     res[i]=Byte.valueOf(vals[i].trim());
    return res;
  }
  match=PT_ARRAY_SHORT.matcher(string);
  if (match.matches()) {
    final String[] vals=match.group(1).split(ARRAY_DELIMITER);
    final short[] res=new short[vals.length];
    for (int i=0; i < res.length; i++)     res[i]=Short.valueOf(vals[i].trim());
    return res;
  }
  match=PT_ARRAY_INT.matcher(string);
  if (match.matches()) {
    final String[] vals=match.group(1).split(ARRAY_DELIMITER);
    final int[] res=new int[vals.length];
    for (int i=0; i < res.length; i++)     res[i]=Integer.valueOf(vals[i].trim());
    return res;
  }
  match=PT_ARRAY_LONG.matcher(string);
  if (match.matches()) {
    final String[] vals=match.group(1).split(ARRAY_DELIMITER);
    final long[] res=new long[vals.length];
    for (int i=0; i < res.length; i++)     res[i]=Long.valueOf(vals[i].trim());
    return res;
  }
  match=PT_ARRAY_FLOAT.matcher(string);
  if (match.matches()) {
    final String[] vals=match.group(1).split(ARRAY_DELIMITER);
    final float[] res=new float[vals.length];
    for (int i=0; i < res.length; i++)     res[i]=Float.valueOf(vals[i].trim());
    return res;
  }
  match=PT_ARRAY_DOUBLE.matcher(string);
  if (match.matches()) {
    final String[] vals=match.group(1).split(ARRAY_DELIMITER);
    final double[] res=new double[vals.length];
    for (int i=0; i < res.length; i++)     res[i]=Double.valueOf(vals[i].trim());
    return res;
  }
  match=PT_ARRAY_BOOL.matcher(string);
  if (match.matches()) {
    final String[] vals=match.group(1).split(ARRAY_DELIMITER);
    final boolean[] res=new boolean[vals.length];
    for (int i=0; i < res.length; i++)     res[i]=Boolean.valueOf(vals[i].trim());
    return res;
  }
  match=PT_STRICT_STRING.matcher(string);
  if (match.matches())   return match.group(1);
  match=PT_STRICT_BYTE.matcher(string);
  if (match.matches())   return Byte.valueOf(match.group(1));
  match=PT_STRICT_SHORT.matcher(string);
  if (match.matches())   return Short.valueOf(match.group(1));
  match=PT_STRICT_INT.matcher(string);
  if (match.matches())   return Integer.valueOf(match.group(1));
  match=PT_STRICT_LONG.matcher(string);
  if (match.matches())   return Long.valueOf(match.group(1));
  match=PT_STRICT_FLOAT.matcher(string);
  if (match.matches())   return Float.valueOf(match.group(1).replace(ARRAY_DELIMITER,"String_Node_Str").replace("String_Node_Str","String_Node_Str"));
  match=PT_STRICT_DOUBLE.matcher(string);
  if (match.matches())   return Double.valueOf(match.group(1).replace(ARRAY_DELIMITER,"String_Node_Str"));
  match=PT_STRICT_BOOL.matcher(string);
  if (match.matches())   return Boolean.valueOf(match.group(1));
  match=PT_STRICT_CHAR.matcher(string);
  if (match.matches())   return Character.valueOf(match.group(1).charAt(0));
  match=PT_CUSTOM.matcher(string);
  if (customFConverters != null && match.matches()) {
    final ITypeConverter<?> conv=customFConverters.get(match.group(2));
    if (conv != null)     return conv.parse(match.group(1));
  }
  match=PT_CONVERTER.matcher(string);
  if (match.matches()) {
    final Class<?> clazz=loader.loadClass(match.group(2));
    final Constructor<?> con=clazz.getConstructor(String.class);
    return con.newInstance(match.group(1));
  }
  if (!STRICT) {
    match=PT_STRING.matcher(string);
    if (match.matches())     return match.group(1);
    match=PT_BYTE.matcher(string);
    if (match.matches())     return Byte.valueOf(match.group(1));
    match=PT_SHORT.matcher(string);
    if (match.matches())     return Short.valueOf(match.group(1));
    match=PT_INT.matcher(string);
    if (match.matches())     return Integer.valueOf(match.group(1));
    match=PT_LONG.matcher(string);
    if (match.matches())     return Long.valueOf(match.group(1).substring(0,match.group(1).length() - 1));
    match=PT_FLOAT.matcher(string);
    if (match.matches())     return Float.valueOf(match.group(1).replace(ARRAY_DELIMITER,"String_Node_Str").replace("String_Node_Str","String_Node_Str"));
    match=PT_DOUBLE.matcher(string);
    if (match.matches())     return Double.valueOf(match.group(1).replace(ARRAY_DELIMITER,"String_Node_Str"));
    match=PT_BOOL.matcher(string);
    if (match.matches())     return Boolean.valueOf(match.group(1));
    match=PT_CHAR.matcher(string);
    if (match.matches())     return Character.valueOf(match.group(1).charAt(0));
    match=PT_ARRAY_STRING_SIMPLE.matcher(string);
    if (match.matches())     return Arrays.asList(match.group(1).split(ARRAY_DELIMITER));
  }
  return string;
}

Fixed version (ground truth):
/** 
 * Converts an string to its java counterpart
 * @param loader for custom types
 * @throws ClassNotFoundException if custom type could not be found
 * @throws SecurityException
 * @throws NoSuchMethodException
 * @throws InvocationTargetException
 * @throws IllegalArgumentException
 * @throws IllegalAccessException
 * @throws InstantiationException
 */
public Object string2type(String string,final ClassLoader loader) throws ClassNotFoundException, NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
  if (string == null || string.length() == 0)   return null;
  Matcher match;
  string=string.trim();
  match=PT_ARRAY_STRING.matcher(string);
  if (match.matches())   return match.group(1).split(ARRAY_DELIMITER);
  match=PT_ARRAY_BYTE.matcher(string);
  if (match.matches()) {
    final String[] vals=match.group(1).split(ARRAY_DELIMITER);
    final byte[] res=new byte[vals.length];
    for (int i=0; i < res.length; i++)     res[i]=Byte.valueOf(vals[i].trim());
    return res;
  }
  match=PT_ARRAY_SHORT.matcher(string);
  if (match.matches()) {
    final String[] vals=match.group(1).split(ARRAY_DELIMITER);
    final short[] res=new short[vals.length];
    for (int i=0; i < res.length; i++)     res[i]=Short.valueOf(vals[i].trim());
    return res;
  }
  match=PT_ARRAY_INT.matcher(string);
  if (match.matches()) {
    final String[] vals=match.group(1).split(ARRAY_DELIMITER);
    final int[] res=new int[vals.length];
    for (int i=0; i < res.length; i++)     res[i]=Integer.valueOf(vals[i].trim());
    return res;
  }
  match=PT_ARRAY_LONG.matcher(string);
  if (match.matches()) {
    final String[] vals=match.group(1).split(ARRAY_DELIMITER);
    final long[] res=new long[vals.length];
    for (int i=0; i < res.length; i++)     res[i]=Long.valueOf(vals[i].trim());
    return res;
  }
  match=PT_ARRAY_FLOAT.matcher(string);
  if (match.matches()) {
    final String[] vals=match.group(1).split(ARRAY_DELIMITER);
    final float[] res=new float[vals.length];
    for (int i=0; i < res.length; i++)     res[i]=Float.valueOf(vals[i].trim());
    return res;
  }
  match=PT_ARRAY_DOUBLE.matcher(string);
  if (match.matches()) {
    final String[] vals=match.group(1).split(ARRAY_DELIMITER);
    final double[] res=new double[vals.length];
    for (int i=0; i < res.length; i++)     res[i]=Double.valueOf(vals[i].trim());
    return res;
  }
  match=PT_ARRAY_BOOL.matcher(string);
  if (match.matches()) {
    final String[] vals=match.group(1).split(ARRAY_DELIMITER);
    final boolean[] res=new boolean[vals.length];
    for (int i=0; i < res.length; i++)     res[i]=Boolean.valueOf(vals[i].trim());
    return res;
  }
  match=PT_STRICT_STRING.matcher(string);
  if (match.matches())   return match.group(1);
  match=PT_STRICT_BYTE.matcher(string);
  if (match.matches())   return Byte.valueOf(match.group(1));
  match=PT_STRICT_SHORT.matcher(string);
  if (match.matches())   return Short.valueOf(match.group(1));
  match=PT_STRICT_INT.matcher(string);
  if (match.matches())   return Integer.valueOf(match.group(1));
  match=PT_STRICT_LONG.matcher(string);
  if (match.matches())   return Long.valueOf(match.group(1));
  match=PT_STRICT_FLOAT.matcher(string);
  if (match.matches())   return Float.valueOf(match.group(1).replace(ARRAY_DELIMITER,"String_Node_Str").replace("String_Node_Str","String_Node_Str"));
  match=PT_STRICT_DOUBLE.matcher(string);
  if (match.matches())   return Double.valueOf(match.group(1).replace(ARRAY_DELIMITER,"String_Node_Str"));
  match=PT_STRICT_BOOL.matcher(string);
  if (match.matches())   return Boolean.valueOf(match.group(1));
  match=PT_STRICT_CHAR.matcher(string);
  if (match.matches())   return Character.valueOf(match.group(1).charAt(0));
  match=PT_CUSTOM.matcher(string);
  if (customFConverters != null && match.matches()) {
    final ITypeConverter<?> conv=customFConverters.get(match.group(2));
    if (conv != null)     return conv.parse(match.group(1));
  }
  match=PT_CONVERTER.matcher(string);
  if (match.matches()) {
    final Class<?> clazz=loader.loadClass(match.group(2));
    final Constructor<?> con=clazz.getConstructor(String.class);
    return con.newInstance(match.group(1));
  }
  if (!STRICT) {
    match=PT_STRING.matcher(string);
    if (match.matches())     return match.group(1);
    match=PT_BYTE.matcher(string);
    if (match.matches())     return Byte.valueOf(match.group(1));
    match=PT_SHORT.matcher(string);
    if (match.matches())     return Short.valueOf(match.group(1));
    match=PT_INT.matcher(string);
    if (match.matches())     return Integer.valueOf(match.group(1));
    match=PT_HEXINT.matcher(string);
    if (match.matches())     return Integer.decode(match.group(1));
    match=PT_LONG.matcher(string);
    if (match.matches())     return Long.valueOf(match.group(1).substring(0,match.group(1).length() - 1));
    match=PT_FLOAT.matcher(string);
    if (match.matches())     return Float.valueOf(match.group(1).replace(ARRAY_DELIMITER,"String_Node_Str").replace("String_Node_Str","String_Node_Str"));
    match=PT_DOUBLE.matcher(string);
    if (match.matches())     return Double.valueOf(match.group(1).replace(ARRAY_DELIMITER,"String_Node_Str"));
    match=PT_BOOL.matcher(string);
    if (match.matches())     return Boolean.valueOf(match.group(1));
    match=PT_CHAR.matcher(string);
    if (match.matches())     return Character.valueOf(match.group(1).charAt(0));
    match=PT_ARRAY_STRING_SIMPLE.matcher(string);
    if (match.matches())     return Arrays.asList(match.group(1).split(ARRAY_DELIMITER));
  }
  return string;
}