Program: 7501
Project: 7501
Buggy source:
/** 
 * Removes all JavaScript classes and replaces them with the corresponding Java objects. This method will use instances of Data replace native JavaScript objects and arrays. Also, it will replace both JavaScript "null" and "undefined" with null. Other objects will be returned as-is.
 * @param obj            the object to unwrap
 * @return the unwrapped object
 * @see org.rapidcontext.core.data.Array
 * @see org.rapidcontext.core.data.Dict
 */
public static Object unwrap(Object obj){
  if (obj instanceof DataWrapper) {
    return ((DataWrapper)obj).getData();
  }
 else   if (obj instanceof ConnectionWrapper) {
    return ((ConnectionWrapper)obj).getConnection();
  }
 else   if (obj instanceof NativeArray) {
    NativeArray nativeArr=(NativeArray)obj;
    int length=(int)nativeArr.getLength();
    Array arr=new Array(length);
    for (int i=0; i < length; i++) {
      arr.set(i,unwrap(nativeArr.get(i,nativeArr)));
    }
    return arr;
  }
 else   if (obj instanceof Scriptable) {
    Scriptable scr=(Scriptable)obj;
    Object[] keys=scr.getIds();
    Dict dict=new Dict(keys.length);
    for (int i=0; i < keys.length; i++) {
      String str=keys[i].toString();
      Object value=null;
      if (keys[i] instanceof Integer) {
        value=scr.get(((Integer)keys[i]).intValue(),scr);
      }
 else {
        value=scr.get(str,scr);
      }
      dict.set(str,unwrap(value));
    }
    return dict;
  }
 else   if (obj instanceof Undefined || obj == Scriptable.NOT_FOUND) {
    return null;
  }
 else {
    return obj;
  }
}

Fixed version (ground truth):
/** 
 * Removes all JavaScript classes and replaces them with the corresponding Java objects. This method will use instances of Dict and Array to replace native JavaScript objects and arrays. Also, it will replace both JavaScript "null" and "undefined" with null. Any Dict or Array object encountered will be traversed and modified in-place recursively. Other objects will be returned as-is.
 * @param obj            the object to unwrap
 * @return the unwrapped object
 * @see org.rapidcontext.core.data.Array
 * @see org.rapidcontext.core.data.Dict
 */
public static Object unwrap(Object obj){
  if (obj instanceof DataWrapper) {
    return ((DataWrapper)obj).getData();
  }
 else   if (obj instanceof ConnectionWrapper) {
    return ((ConnectionWrapper)obj).getConnection();
  }
 else   if (obj instanceof NativeArray) {
    NativeArray nativeArr=(NativeArray)obj;
    int length=(int)nativeArr.getLength();
    Array arr=new Array(length);
    for (int i=0; i < length; i++) {
      arr.set(i,unwrap(nativeArr.get(i,nativeArr)));
    }
    return arr;
  }
 else   if (obj instanceof Scriptable) {
    Scriptable scr=(Scriptable)obj;
    Object[] keys=scr.getIds();
    Dict dict=new Dict(keys.length);
    for (int i=0; i < keys.length; i++) {
      String str=keys[i].toString();
      Object value=null;
      if (keys[i] instanceof Integer) {
        value=scr.get(((Integer)keys[i]).intValue(),scr);
      }
 else {
        value=scr.get(str,scr);
      }
      dict.set(str,unwrap(value));
    }
    return dict;
  }
 else   if (obj instanceof Undefined || obj == Scriptable.NOT_FOUND) {
    return null;
  }
 else   if (obj instanceof Array) {
    Array arr=(Array)obj;
    for (int i=0; i < arr.size(); i++) {
      arr.set(i,unwrap(arr.get(i)));
    }
    return arr;
  }
 else   if (obj instanceof Dict) {
    Dict dict=(Dict)obj;
    String[] keys=dict.keys();
    for (int i=0; i < keys.length; i++) {
      String key=keys[i].toString();
      dict.set(key,unwrap(dict.get(key)));
    }
    return dict;
  }
 else {
    return obj;
  }
}