Skip to main content

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

Hi folks,

Java is not my strong suit so I was hoping someone could help me out.

I'm looking at an error report where an ArrayIndexOutOfBoundsException is thrown. Here is the relevant part of the stack trace:

java.lang.ArrayIndexOutOfBoundsException: null
    at java.util.ArrayList.toArray(
    at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPScopeMapper$NamespaceScopeWrapper.getUsingDirectives(

The code at the indicated line is:

			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.)

Any ideas as to how this exception can arise in this case?



Back to the top