-
Bug
-
Resolution: Fixed
-
P2
-
8
Specification for the method (spec it is the same for SE8)
http://docs.oracle.com/javase/7/docs/api/java/util/prefs/AbstractPreferences.html#remove%28java.lang.String%29
says:
Implements the remove(String) method as per the specification in Preferences.remove(String).
While this is not true as
http://docs.oracle.com/javase/7/docs/api/java/util/prefs/Preferences.html#remove%28java.lang.String%29
Specifies assertion
Throws:
NullPointerException - if key is null.
Which is not satisfied by java.util.prefs.AbstractPreferences.remove(String)
The specification or the implementation should be updated.
Please see below a code sample illustrating the problem:
---------------------------------------------------------
import java.util.prefs.AbstractPreferences;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
public class AbstrPrefNoNPE {
public static void main(String[] args) {
ABSTR_PREFS.remove(null);
System.out.println("Test failure: No NPE was thrown");
}
static Preferences ABSTR_PREFS = new AbstractPreferences(null, "") {
@Override
protected void putSpi(String key, String value) {
}
@Override
protected String getSpi(String key) {
return null;
}
@Override
protected void removeSpi(String key) {
}
@Override
protected void removeNodeSpi() throws BackingStoreException {
}
@Override
protected String[] keysSpi() throws BackingStoreException {
return new String[0];
}
@Override
protected String[] childrenNamesSpi() throws BackingStoreException {
return new String[0];
}
@Override
protected AbstractPreferences childSpi(String name) {
return null;
}
@Override
protected void syncSpi() throws BackingStoreException {
}
@Override
protected void flushSpi() throws BackingStoreException {
}
};
}
---------------------------------------------------------
The following conformance test will fail due to this problem:
api/java_util/prefs/Preferences/index.html#NPETests[remove]
http://docs.oracle.com/javase/7/docs/api/java/util/prefs/AbstractPreferences.html#remove%28java.lang.String%29
says:
Implements the remove(String) method as per the specification in Preferences.remove(String).
While this is not true as
http://docs.oracle.com/javase/7/docs/api/java/util/prefs/Preferences.html#remove%28java.lang.String%29
Specifies assertion
Throws:
NullPointerException - if key is null.
Which is not satisfied by java.util.prefs.AbstractPreferences.remove(String)
The specification or the implementation should be updated.
Please see below a code sample illustrating the problem:
---------------------------------------------------------
import java.util.prefs.AbstractPreferences;
import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
public class AbstrPrefNoNPE {
public static void main(String[] args) {
ABSTR_PREFS.remove(null);
System.out.println("Test failure: No NPE was thrown");
}
static Preferences ABSTR_PREFS = new AbstractPreferences(null, "") {
@Override
protected void putSpi(String key, String value) {
}
@Override
protected String getSpi(String key) {
return null;
}
@Override
protected void removeSpi(String key) {
}
@Override
protected void removeNodeSpi() throws BackingStoreException {
}
@Override
protected String[] keysSpi() throws BackingStoreException {
return new String[0];
}
@Override
protected String[] childrenNamesSpi() throws BackingStoreException {
return new String[0];
}
@Override
protected AbstractPreferences childSpi(String name) {
return null;
}
@Override
protected void syncSpi() throws BackingStoreException {
}
@Override
protected void flushSpi() throws BackingStoreException {
}
};
}
---------------------------------------------------------
The following conformance test will fail due to this problem:
api/java_util/prefs/Preferences/index.html#NPETests[remove]