Program: 63491
Project: 63491
Buggy source:
protected JSValue function(JSValue[] args) throws JSException {
  Class<?>[] pType=method.getParameterTypes();
  Object[] passArgs=new Object[pType.length];
  for (int i=0; i < passArgs.length; i++) {
    if (i < args.length) {
      if (pType[i] == String.class)       passArgs[i]=args[i].toString();
 else       if (pType[i] == Double.class)       passArgs[i]=args[i].toNumber();
 else       if (pType[i] == Integer.class)       passArgs[i]=args[i].toNumber().intValue();
 else       if (pType[i] == Long.class)       passArgs[i]=args[i].toNumber().longValue();
 else       if (pType[i] == Boolean.class)       passArgs[i]=args[i].toBoolean();
 else       if (pType[i] == JSObject.class)       passArgs[i]=args[i].toObject();
 else       if (pType[i] == JSString.class)       passArgs[i]=args[i].toJSString();
 else       if (pType[i].isArray()) {
        JSObject arr=args[i].toObject();
        if (arr.property("String_Node_Str") == null) {
          throw (new JSException(context,"String_Node_Str"));
        }
        Integer length=arr.property("String_Node_Str").toNumber().intValue();
        ArrayList<Object> objList=new ArrayList<Object>();
        for (int j=0; j < length; j++) {
          if (pType[i] == Boolean[].class)           objList.add(arr.propertyAtIndex(j).toBoolean());
 else           if (pType[i] == Integer[].class)           objList.add(arr.propertyAtIndex(j).toNumber().intValue());
 else           if (pType[i] == String[].class)           objList.add(arr.propertyAtIndex(j).toString());
 else           if (pType[i] == Long[].class)           objList.add(arr.propertyAtIndex(j).toNumber().longValue());
 else           if (pType[i] == Double[].class)           objList.add(arr.propertyAtIndex(j).toNumber());
 else           if (pType[i] == JSValue[].class)           objList.add(arr.propertyAtIndex(j));
 else           if (pType[i] == JSObject[].class)           objList.add(arr.propertyAtIndex(j).toObject());
 else           if (pType[i] == JSString[].class)           objList.add(arr.propertyAtIndex(j).toJSString());
 else           objList.add(null);
        }
        passArgs[i]=objList.toArray(new Object[objList.size()]);
      }
 else       if (pType[i] == JSValue.class)       passArgs[i]=args[i];
 else       passArgs[i]=null;
    }
 else {
      passArgs[i]=null;
    }
  }
  try {
    Object ret=method.invoke(invokeObject,passArgs);
    if (method.getReturnType() == Void.class)     return null;
    if (ret instanceof JSValue)     return (JSValue)ret;
    return new JSValue(context,ret);
  }
 catch (  InvocationTargetException e) {
    e.printStackTrace();
    throw (new JSException(context,e.toString()));
  }
catch (  IllegalAccessException e) {
    throw (new JSException(context,e.toString()));
  }
}

Fixed version (ground truth):
protected JSValue function(JSValue[] args) throws JSException {
  Class<?>[] pType=method.getParameterTypes();
  Object[] passArgs=new Object[pType.length];
  for (int i=0; i < passArgs.length; i++) {
    if (i < args.length) {
      if (pType[i] == String.class)       passArgs[i]=args[i].toString();
 else       if (pType[i] == Double.class)       passArgs[i]=args[i].toNumber();
 else       if (pType[i] == Integer.class)       passArgs[i]=args[i].toNumber().intValue();
 else       if (pType[i] == Long.class)       passArgs[i]=args[i].toNumber().longValue();
 else       if (pType[i] == Boolean.class)       passArgs[i]=args[i].toBoolean();
 else       if (pType[i] == JSObject.class)       passArgs[i]=args[i].toObject();
 else       if (pType[i] == JSString.class)       passArgs[i]=args[i].toJSString();
 else       if (pType[i].isArray()) {
        JSObject arr=args[i].toObject();
        if (arr.property("String_Node_Str") == null) {
          throw (new JSException(context,"String_Node_Str"));
        }
        Integer length=arr.property("String_Node_Str").toNumber().intValue();
        ArrayList<Object> objList=new ArrayList<Object>();
        for (int j=0; j < length; j++) {
          if (pType[i] == Boolean[].class)           objList.add(arr.propertyAtIndex(j).toBoolean());
 else           if (pType[i] == Integer[].class)           objList.add(arr.propertyAtIndex(j).toNumber().intValue());
 else           if (pType[i] == String[].class)           objList.add(arr.propertyAtIndex(j).toString());
 else           if (pType[i] == Long[].class)           objList.add(arr.propertyAtIndex(j).toNumber().longValue());
 else           if (pType[i] == Double[].class)           objList.add(arr.propertyAtIndex(j).toNumber());
 else           if (pType[i] == JSValue[].class)           objList.add(arr.propertyAtIndex(j));
 else           if (pType[i] == JSObject[].class)           objList.add(arr.propertyAtIndex(j).toObject());
 else           if (pType[i] == JSString[].class)           objList.add(arr.propertyAtIndex(j).toJSString());
 else           objList.add(null);
        }
        if (pType[i] == Boolean[].class)         passArgs[i]=objList.toArray(new Boolean[objList.size()]);
 else         if (pType[i] == Integer[].class)         passArgs[i]=objList.toArray(new Integer[objList.size()]);
 else         if (pType[i] == String[].class)         passArgs[i]=objList.toArray(new String[objList.size()]);
 else         if (pType[i] == Long[].class)         passArgs[i]=objList.toArray(new Long[objList.size()]);
 else         if (pType[i] == Double[].class)         passArgs[i]=objList.toArray(new Double[objList.size()]);
 else         if (pType[i] == JSValue[].class)         passArgs[i]=objList.toArray(new JSValue[objList.size()]);
 else         if (pType[i] == JSObject[].class)         passArgs[i]=objList.toArray(new JSObject[objList.size()]);
 else         if (pType[i] == JSString[].class)         passArgs[i]=objList.toArray(new JSString[objList.size()]);
 else         passArgs[i]=objList.toArray(new Object[objList.size()]);
      }
 else       if (pType[i] == JSValue.class)       passArgs[i]=args[i];
 else       passArgs[i]=null;
    }
 else {
      passArgs[i]=null;
    }
  }
  try {
    Object ret=method.invoke(invokeObject,passArgs);
    if (method.getReturnType() == Void.class)     return null;
    if (ret instanceof JSValue)     return (JSValue)ret;
    return new JSValue(context,ret);
  }
 catch (  InvocationTargetException e) {
    e.printStackTrace();
    throw (new JSException(context,e.toString()));
  }
catch (  IllegalAccessException e) {
    throw (new JSException(context,e.toString()));
  }
}