-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.4.0
-
x86
-
windows_2000
Name: jl125535 Date: 01/09/2003
FULL PRODUCT VERSION :
java version "1.4.0_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0_01-b03)
Java HotSpot(TM) Client VM (build 1.4.0_01-b03, mixed mode)
FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]
Microsoft Windows 2000
5.00.2195
Service Pack 2
EXTRA RELEVANT SYSTEM CONFIGURATION :
Default locale is en_US or ja_JP
A DESCRIPTION OF THE PROBLEM :
When I try to use ResourceBundle.getBundle(String baseName)
to retrieve a class ResourceBundle with the name baseName,
it fails citing "java.util.MissingResourceException: Can't
find bundle for base name baseName, locale *"
* is my current locale (en_US or ja_JP).
If I create a subclass of baseName that contains no new code
of its own and name it baseName_en or baseName_en_US, it
will work fine (respectively with baseName_ja and
baseName_ja_JP).
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. create Dummy DummyResources (see source code)
2. compile both classes and run java Dummy
3. read the error message
4. create class DummyResources_** where ** is your default
language and/or country (in this example, ja_JP)
5. compile the new java class
6. run java Dummy again, and see "dummy" printed out.
EXPECTED VERSUS ACTUAL BEHAVIOR :
Dummy should work without the second resource class.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Resource file not found: java.util.MissingResourceException: Can't find bundle f
or base name DummyResources, locale ja_JP
java.util.MissingResourceException: Can't find bundle for base name DummyResourc
es, locale ja_JP
at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle
.java:804)
at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:773)
at java.util.ResourceBundle.getBundle(ResourceBundle.java:511)
at Dummy.<clinit>(Dummy.java:9)
ja_JP
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
// begin Dummy.java
import java.util.ResourceBundle;
import java.util.MissingResourceException;
public class Dummy extends Object {
private static DummyResources resources;
static {
try {
resources = (DummyResources) ResourceBundle.getBundle("DummyResources");
} catch(MissingResourceException mre) {
System.err.println("Resource file not found: " + mre);
mre.printStackTrace();
System.exit(1);
}
}
public static void main(String[] args) {
System.out.println(resources.getString("dummy"));
}
}
// end Dummy.java
// begin DummyResources.java
import java.util.Enumeration;
import java.util.ResourceBundle;
import java.util.StringTokenizer;
public class DummyResources extends ResourceBundle {
DummyResources() {
super();
}
public Object handleGetObject(String key) {
return null;
}
public Enumeration getKeys() {
return new StringTokenizer("");
}
}
// end DummyResources.java
// begin DummyResources_ja_JP.java
public class DummyResources_ja_JP extends DummyResources {
}
//end DummyResources_ja_JP.java
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
create a resource class for every language (which I don't
consider much of an option...)
(Review ID: 158379)
======================================================================