Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [cdt-dev] Help for the Java challenged: how can ArrayIndexOutOfBoundsException be thrown here?

Hi Nate,

I suspect Christian is right about the cause. There are a few
(potential) race conditions in that class. Between the call to size()
and toArray() a new item could be added in addUsingDirective,
additionally, between the call to size and toArray you could have
fUsingDirectives being reinit if two threads are calling
initUsingDirectives at the same time.

As for the source of toArray, you can get it by configuring your JRE
to have the source:
https://dzone.com/articles/attaching-java-source-eclipse However in
this error report the exception is being raised from the native
System.arraycopy code (called by toArray).

Jonah
~~~
Jonah Graham
Kichwa Coders Ltd.
www.kichwacoders.com


On 21 February 2017 at 06:58, Christian Walther <walther@xxxxxxxx> wrote:
> Nathan Ridge wrote:
>>                       return fUsingDirectives.toArray(new ICPPUsingDirective[fUsingDirectives.size()]);
>>
>> The previous line ensures that fUsingDirectives is not null.
>>
>> I don't see how an ArrayIndexOutOfBoundsException can be thrown in this case. (But I also can't see the source of the ArrayList.toArray() method to see what exactly it's trying to do.)
>
> I imagine this could happen if some other thread is concurrently adding items to fUsingDirectives.
>
>  -Christian
>
> _______________________________________________
> cdt-dev mailing list
> cdt-dev@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or unsubscribe from this list, visit
> https://dev.eclipse.org/mailman/listinfo/cdt-dev


Back to the top