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(ArrayList.java:408)
    at org.eclipse.cdt.internal.core.dom.parser.cpp.CPPScopeMapper$NamespaceScopeWrapper.getUsingDirectives(CPPScopeMapper.java:168)

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?

Thanks,
Nate

[1] https://dev.eclipse.org/recommenders/committers/aeri/v2/#!/incidents/58a59438e4b05548a19b679b

Back to the top