src/java.prefs/share/classes/java/util/prefs/Preferences.java
Print this page
rev 11736 : 8075156: (prefs) remove() should disallow the use of the null control character '\u0000' as key
Summary: Extend disallowing null control character key to remove()
Reviewed-by: XXX
*** 487,497 ****
* @throws IllegalArgumentException if <tt>key.length()</tt> exceeds
* <tt>MAX_KEY_LENGTH</tt> or if <tt>value.length</tt> exceeds
* <tt>MAX_VALUE_LENGTH</tt>.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()} method.
! * @throws IllegalArgumentException if either the key or the value contain
* the null control character, code point U+0000.
*/
public abstract void put(String key, String value);
/**
--- 487,497 ----
* @throws IllegalArgumentException if <tt>key.length()</tt> exceeds
* <tt>MAX_KEY_LENGTH</tt> or if <tt>value.length</tt> exceeds
* <tt>MAX_VALUE_LENGTH</tt>.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()} method.
! * @throws IllegalArgumentException if either key or value contain
* the null control character, code point U+0000.
*/
public abstract void put(String key, String value);
/**
*** 512,521 ****
--- 512,523 ----
* store is inaccessible.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()} method.
* @throws NullPointerException if <tt>key</tt> is <tt>null</tt>. (A
* <tt>null</tt> value for <tt>def</tt> <i>is</i> permitted.)
+ * @throws IllegalArgumentException if key contains the null control
+ * character, code point U+0000.
*/
public abstract String get(String key, String def);
/**
* Removes the value associated with the specified key in this preference
*** 528,537 ****
--- 530,541 ----
*
* @param key key whose mapping is to be removed from the preference node.
* @throws NullPointerException if <tt>key</tt> is <tt>null</tt>.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()} method.
+ * @throws IllegalArgumentException if key contains the null control
+ * character, code point U+0000.
*/
public abstract void remove(String key);
/**
* Removes all of the preferences (key-value associations) in this
*** 564,573 ****
--- 568,579 ----
* @throws NullPointerException if <tt>key</tt> is <tt>null</tt>.
* @throws IllegalArgumentException if <tt>key.length()</tt> exceeds
* <tt>MAX_KEY_LENGTH</tt>.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()} method.
+ * @throws IllegalArgumentException if key contains
+ * the null control character, code point U+0000.
* @see #getInt(String,int)
*/
public abstract void putInt(String key, int value);
/**
*** 595,604 ****
--- 601,612 ----
* associated value does not exist or cannot be interpreted as
* an int.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()} method.
* @throws NullPointerException if <tt>key</tt> is <tt>null</tt>.
+ * @throws IllegalArgumentException if key contains the null control
+ * character, code point U+0000.
* @see #putInt(String,int)
* @see #get(String,String)
*/
public abstract int getInt(String key, int def);
*** 614,623 ****
--- 622,633 ----
* @throws NullPointerException if <tt>key</tt> is <tt>null</tt>.
* @throws IllegalArgumentException if <tt>key.length()</tt> exceeds
* <tt>MAX_KEY_LENGTH</tt>.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()} method.
+ * @throws IllegalArgumentException if key contains
+ * the null control character, code point U+0000.
* @see #getLong(String,long)
*/
public abstract void putLong(String key, long value);
/**
*** 645,654 ****
--- 655,666 ----
* associated value does not exist or cannot be interpreted as
* a long.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()} method.
* @throws NullPointerException if <tt>key</tt> is <tt>null</tt>.
+ * @throws IllegalArgumentException if key contains the null control
+ * character, code point U+0000.
* @see #putLong(String,long)
* @see #get(String,String)
*/
public abstract long getLong(String key, long def);
*** 664,673 ****
--- 676,687 ----
* @throws NullPointerException if <tt>key</tt> is <tt>null</tt>.
* @throws IllegalArgumentException if <tt>key.length()</tt> exceeds
* <tt>MAX_KEY_LENGTH</tt>.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()} method.
+ * @throws IllegalArgumentException if key contains
+ * the null control character, code point U+0000.
* @see #getBoolean(String,boolean)
* @see #get(String,String)
*/
public abstract void putBoolean(String key, boolean value);
*** 700,709 ****
--- 714,725 ----
* associated value does not exist or cannot be interpreted as
* a boolean.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()} method.
* @throws NullPointerException if <tt>key</tt> is <tt>null</tt>.
+ * @throws IllegalArgumentException if key contains the null control
+ * character, code point U+0000.
* @see #get(String,String)
* @see #putBoolean(String,boolean)
*/
public abstract boolean getBoolean(String key, boolean def);
*** 719,728 ****
--- 735,746 ----
* @throws NullPointerException if <tt>key</tt> is <tt>null</tt>.
* @throws IllegalArgumentException if <tt>key.length()</tt> exceeds
* <tt>MAX_KEY_LENGTH</tt>.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()} method.
+ * @throws IllegalArgumentException if key contains
+ * the null control character, code point U+0000.
* @see #getFloat(String,float)
*/
public abstract void putFloat(String key, float value);
/**
*** 749,758 ****
--- 767,778 ----
* associated value does not exist or cannot be interpreted as
* a float.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()} method.
* @throws NullPointerException if <tt>key</tt> is <tt>null</tt>.
+ * @throws IllegalArgumentException if key contains the null control
+ * character, code point U+0000.
* @see #putFloat(String,float)
* @see #get(String,String)
*/
public abstract float getFloat(String key, float def);
*** 768,777 ****
--- 788,799 ----
* @throws NullPointerException if <tt>key</tt> is <tt>null</tt>.
* @throws IllegalArgumentException if <tt>key.length()</tt> exceeds
* <tt>MAX_KEY_LENGTH</tt>.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()} method.
+ * @throws IllegalArgumentException if key contains
+ * the null control character, code point U+0000.
* @see #getDouble(String,double)
*/
public abstract void putDouble(String key, double value);
/**
*** 798,807 ****
--- 820,831 ----
* associated value does not exist or cannot be interpreted as
* a double.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()} method.
* @throws NullPointerException if <tt>key</tt> is <tt>null</tt>.
+ * @throws IllegalArgumentException if key contains the null control
+ * character, code point U+0000.
* @see #putDouble(String,double)
* @see #get(String,String)
*/
public abstract double getDouble(String key, double def);
*** 823,832 ****
--- 847,858 ----
* @throws NullPointerException if key or value is <tt>null</tt>.
* @throws IllegalArgumentException if key.length() exceeds MAX_KEY_LENGTH
* or if value.length exceeds MAX_VALUE_LENGTH*3/4.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()} method.
+ * @throws IllegalArgumentException if key contains
+ * the null control character, code point U+0000.
* @see #getByteArray(String,byte[])
* @see #get(String,String)
*/
public abstract void putByteArray(String key, byte[] value);
*** 862,871 ****
--- 888,899 ----
* a byte array.
* @throws IllegalStateException if this node (or an ancestor) has been
* removed with the {@link #removeNode()} method.
* @throws NullPointerException if <tt>key</tt> is <tt>null</tt>. (A
* <tt>null</tt> value for <tt>def</tt> <i>is</i> permitted.)
+ * @throws IllegalArgumentException if key contains the null control
+ * character, code point U+0000.
* @see #get(String,String)
* @see #putByteArray(String,byte[])
*/
public abstract byte[] getByteArray(String key, byte[] def);