Re: A behavior mismatch in AbstractCollection.toArray(T[] )

2011-12-14 Thread David Holmes
On 14/12/2011 10:27 PM, Sean Chou wrote: Thank you as well~ I'll work on it. I'm not sure it is worth fixing by changing the code. A change to the implementation note might be simpler and better. Although it is easy to detect when this behavioural mismatch occurs, I can not conceive

Re: A behavior mismatch in AbstractCollection.toArray(T[] )

2011-12-14 Thread Sean Chou
Thank you as well~ I'll work on it. On Wed, Dec 14, 2011 at 4:02 PM, David Holmes wrote: > On 14/12/2011 5:05 PM, Sean Chou wrote: > >> Hi Mike, David, >> >> I reported this as a bug: >> http://bugs.sun.com/**bugdatabase/view_bug.do?bug_**id=7121314

Re: A behavior mismatch in AbstractCollection.toArray(T[] )

2011-12-14 Thread David Holmes
On 14/12/2011 5:05 PM, Sean Chou wrote: Hi Mike, David, I reported this as a bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7121314 . Thanks - I've turned the initial incident report into a "real" bug report. David On Wed, Dec 14, 2011 at 1:03 PM, Mike Duigou mailto:mike.dui

Re: A behavior mismatch in AbstractCollection.toArray(T[] )

2011-12-13 Thread Sean Chou
Hi Mike, David, I reported this as a bug: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7121314 . On Wed, Dec 14, 2011 at 1:03 PM, Mike Duigou wrote: > I agree that most people probably won't check whether the array returned > is the array they provided. It is possible that they incor

Re: A behavior mismatch in AbstractCollection.toArray(T[] )

2011-12-13 Thread David Holmes
Sean, Ulf, I retract all my previous comments - they were completely wrong. AbstractCollection.toArray _does_ address concurrent modification: "This implementation returns an array containing all the elements returned by this collection's iterator in the same order, stored in consecutive ele

Re: A behavior mismatch in AbstractCollection.toArray(T[] )

2011-12-13 Thread Mike Duigou
I agree that most people probably won't check whether the array returned is the array they provided. It is possible that they incorrectly assume it is. ie. Collection collection; ... Integer[] foo = new Integer[collection.size()]; // of sufficient size for all elements // at this point collectio

Re: A behavior mismatch in AbstractCollection.toArray(T[] )

2011-12-13 Thread Sean Chou
Yeah, that is the reason I think a declaimer about "not designed for concurrent operation. " in the spec would be a proper choice. On Tue, Dec 13, 2011 at 10:20 PM, Ulf Zibis wrote: > IMO in 99.8 % this check would be superfluous overhead. > For those, who want 100 %, they can check and copy i

Re: A behavior mismatch in AbstractCollection.toArray(T[] )

2011-12-13 Thread Ulf Zibis
IMO in 99.8 % this check would be superfluous overhead. For those, who want 100 %, they can check and copy in their code. -Ulf Am 13.12.2011 14:30, schrieb Sean Chou: Sorry for the confuse. By "ok", I mean "compare the size of array which is going to be returned and the size of the specified ar

Re: A behavior mismatch in AbstractCollection.toArray(T[] )

2011-12-13 Thread Sean Chou
Sorry for the confuse. By "ok", I mean "compare the size of array which is going to be returned and the size of the specified array, and copy the elements into the specified array if it is larger and return the specified array." Nothing is causing problem for now, I just found a mismatch. I think

Re: A behavior mismatch in AbstractCollection.toArray(T[] )

2011-12-13 Thread Ulf Zibis
Am 13.12.2011 12:18, schrieb Sean Chou: Hi , Is it possible to change the spec ? I found it is defined in java.utils.Collection interface. It would be easy for AbstractCollection to state that it is not designed for concurrent operations, and its subclass should take care of them. +1 -U

Re: A behavior mismatch in AbstractCollection.toArray(T[] )

2011-12-13 Thread David Holmes
On 13/12/2011 9:18 PM, Sean Chou wrote: Hi , Is it possible to change the spec ? I found it is defined in java.utils.Collection interface. It would be easy for AbstractCollection to state that it is not designed for concurrent operations, and its subclass should take care of them. Such a discl

Re: A behavior mismatch in AbstractCollection.toArray(T[] )

2011-12-13 Thread David Holmes
On 13/12/2011 8:16 PM, Ulf Zibis wrote: Am 13.12.2011 08:41, schrieb David Holmes: Hi Sean, On 13/12/2011 5:21 PM, Sean Chou wrote: When I was reading the code of AbstractCollection.toArray(T[] ), I found its behavior maybe different from the spec in multithread environment. The spec says "If

Re: A behavior mismatch in AbstractCollection.toArray(T[] )

2011-12-13 Thread Sean Chou
Hi , Is it possible to change the spec ? I found it is defined in java.utils.Collection interface. It would be easy for AbstractCollection to state that it is not designed for concurrent operations, and its subclass should take care of them. However, I think the simplest way may be modify

Re: A behavior mismatch in AbstractCollection.toArray(T[] )

2011-12-13 Thread Ulf Zibis
Am 13.12.2011 08:41, schrieb David Holmes: Hi Sean, On 13/12/2011 5:21 PM, Sean Chou wrote: When I was reading the code of AbstractCollection.toArray(T[] ), I found its behavior maybe different from the spec in multithread environment. The spec says "If the collection fits in the specified arra

Re: A behavior mismatch in AbstractCollection.toArray(T[] )

2011-12-12 Thread David Holmes
Hi Sean, On 13/12/2011 5:21 PM, Sean Chou wrote: When I was reading the code of AbstractCollection.toArray(T[] ), I found its behavior maybe different from the spec in multithread environment. The spec says "If the collection fits in the specified array, it is returned therein. Otherwise, a new

A behavior mismatch in AbstractCollection.toArray(T[] )

2011-12-12 Thread Sean Chou
Hi all, When I was reading the code of AbstractCollection.toArray(T[] ), I found its behavior maybe different from the spec in multithread environment. The spec says "If the collection fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime typ