ArrayIndexOutOfBoundsException in ResourceBundle.getBundle(String) in JDK 6&7

Heiko Wagner heiko.wagner at
Fri Nov 4 09:58:10 UTC 2011

I hope this is the right list to post this. I encounter some behaviour, that
I am not sure whether this is correct. When invoking
ResourceBundle.getBundle("com.some.Bundle") I get a

This is caused by the fact that the ResourceBundle class tries to determine
the actual ClassLoader using the getLoader() method, via accessing the
hardcoded stack offset 2, which works when the getBundle() method is callen
from Java, but in my case I invoke this method using JNI and the stack
layout is different, so causing the exception.

I know this code has been this way a for a long time, but I still get a beed
feeling when the code relies on some hard code offsets in the call stack and
I see no reason why invoking the ResourceBundle methods via JNI should be
considered "illegal".

Despite the trivial workaround for this problem. i.e. explicitly specify the
ClassLoader with getBundle(String, Locale, ClassLoader), I would like to
hear your opinion on this.


More information about the core-libs-dev mailing list