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

Heiko Wagner heiko.wagner at
Fri Nov 4 12:03:02 UTC 2011

Hi Tom, thanks for your reply. I am using JNI in a different,propably never
designed to be used that way, kind of scenario. I use JNI to bring Java to a
legacy Smalltalk based product[1].

The Smalltalk code does directly invoke the JNI calls from its own Smalltalk
VM main thread. So the Java VM is not aware of the calling thread and has no
call stack information. Currently, I am using
ClassLoader.getSystemClassLoader(), which perfectly works for me. I have no
idea if this makes sense in gerneal, but for me a
MissingResourceBundleException in my use case, would be what I propably
would have expected, instead of a ArrayIndexOutOfBoundsException, so maybe a
additional size check on the call stack array size would make sense.

Despite my hefty "abuse" of JNI, it overall still works very well.


[1] (Slide

>I'm not a JNI expert (you are calling from a thread known to the JVM,
>right?). However, getBundle is one of the magic methods listed in
>section 6 (6-4) of the Java Secure Coding Guidelines[1] that depend upon
>the immediate caller. If there isn't an immediate [Java] caller, that
>isn't going to work. Which ClassLoader would you want getBundle to use?

More information about the core-libs-dev mailing list