On 07/11/2011 00:19, David Holmes wrote:

There are a handful of places in the JDK where this kind of stack-based check is used and the assumption is always that there is a "client" Java caller in the stack. Given this kind of code is unaware of the context in which it is called in general, what exception would you throw if you find there is no Java client caller? In the current case the specs for getBundle state that it is the equivalent of calling the classloader-taking form with the expression this.getClass().getClassLoader(). But in the current case there is no this, no current class and no current classloader - so what exception do you throw? "new RuntimeException("Expected Java caller not found")?

I don't think throwing MissingResourceBundleException is the right way to go here because it hides the mis-use of this API.
For this specific case it probably has to be treated as if the caller's loader is the boot class loader. In that case, MissingResourceException may be thrown (I can't tell from the original mail if the resource bundle is found when the loader is specified as null, I assume not).

-Alan.

Reply via email to