From: Anjo K. <an...@us...> - 2006-11-16 11:15:41
|
Update of /cvsroot/wonder/Wonder/Common/Frameworks/ERExtensions/Sources/com/webobjects/foundation In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv16661/Sources/com/webobjects/foundation Modified Files: NSMutableArray.java Log Message: fix for broken toArray method Index: NSMutableArray.java =================================================================== RCS file: /cvsroot/wonder/Wonder/Common/Frameworks/ERExtensions/Sources/com/webobjects/foundation/NSMutableArray.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** NSMutableArray.java 20 Sep 2006 22:15:52 -0000 1.4 --- NSMutableArray.java 16 Nov 2006 11:15:37 -0000 1.5 *************** *** 1,4 **** --- 1,5 ---- package com.webobjects.foundation; + import java.lang.reflect.Array; import java.util.Collection; import java.util.ConcurrentModificationException; *************** *** 388,391 **** --- 389,411 ---- } + /** + * Bugfix for the broken implementation in NSArray. + */ + public Object[] toArray(Object array[]) { + int i = size(); + if (array.length < i) { + array = (Object[]) (Object[]) Array.newInstance(((Object) (array)).getClass().getComponentType(), i); + } + Object result[] = array; + for (int j = 0; j < i; j++) { + result[j] = objectAtIndex(j); + } + + if (array.length > i) { + array[i] = null; + } + return array; + } + //AK: from here on only java.util.List stuff |