ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/Collections.java
(Generate patch)

Comparing jsr166/src/main/java/util/Collections.java (file contents):
Revision 1.9 by jsr166, Fri May 27 03:44:18 2005 UTC vs.
Revision 1.10 by jsr166, Fri Jun 10 16:04:31 2005 UTC

# Line 6 | Line 6
6   */
7  
8   package java.util;
9 + import java.util.*; // for javadoc
10   import java.io.Serializable;
11   import java.io.ObjectOutputStream;
12   import java.io.IOException;
# Line 1365 | Line 1366 | public class Collections {
1366                  // We don't pass a to c.toArray, to avoid window of
1367                  // vulnerability wherein an unscrupulous multithreaded client
1368                  // could get his hands on raw (unwrapped) Entries from c.
1369 <                Object[] arr =
1369 <                    c.toArray(
1370 <                        a.length==0 ? a :
1371 <                        (T[])java.lang.reflect.Array.newInstance(a.getClass().getComponentType(), 0));
1369 >                Object[] arr = c.toArray(a.length==0 ? a : Arrays.copyOf(a, 0));
1370  
1371                  for (int i=0; i<arr.length; i++)
1372                      arr[i] = new UnmodifiableEntry<K,V>((Map.Entry<K,V>)arr[i]);
# Line 2702 | Line 2700 | public class Collections {
2700                  // We don't pass a to s.toArray, to avoid window of
2701                  // vulnerability wherein an unscrupulous multithreaded client
2702                  // could get his hands on raw (unwrapped) Entries from s.
2703 <                Object[] arr = s.toArray(a.length==0 ? a :
2706 <                   (T[])Array.newInstance(a.getClass().getComponentType(), 0));
2703 >                Object[] arr = s.toArray(a.length==0 ? a : Arrays.copyOf(a, 0));
2704  
2705                  for (int i=0; i<arr.length; i++)
2706                      arr[i] = new CheckedEntry<K,V>((Map.Entry<K,V>)arr[i],

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines