-
Bug
-
Resolution: Duplicate
-
P3
-
None
-
1.4.0
-
sparc
-
solaris_2.6
Name: auR10023 Date: 06/28/2001
ListResourceBundle.handleGetObject() does not throw NullPointerException
with null key.
The javadoc says:
...
public final Object handleGetObject(String key)
Description copied from class: ResourceBundle
Gets an object for the given key from this resource bundle. Returns
null if this resource bundle does not contain an object for the
given key.
Specified by:
handleGetObject in class ResourceBundle
Following copied from class: java.util.ResourceBundle
Parameters:
key - the key for the desired object
Returns:
the object for the given key, or null
Throws:
NullPointerException - if key is null
...
Here is the example:
----t.java---
import java.util.*;
public class t {
public static void main(String argv[]) {
String key = null;
Object[][] contents = new Object[][] {};
try {
PrimitiveBundle bundle = new PrimitiveBundle(contents);
Object result = bundle.handleGetObject(key);
System.out.println( "failed");
} catch(NullPointerException e) {
System.out.println( "OK");
}
}
}
class PrimitiveBundle extends ListResourceBundle {
Object[][] list;
PrimitiveBundle(Object[][] list) {
this.list = list;
setParent(null);
}
protected Object[][] getContents() {
return list;
}
}
#java -version
java version "1.4.0-beta_refresh"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta_refresh-b69)
Java HotSpot(TM) Client VM (build 1.4.0-beta_refresh-b69, mixed mode)
#java t
failed
======================================================================
- duplicates
-
JDK-4475051 List/PropertyResourceBundle.handleGetObject(null) do not throw NPE
- Closed