RFR(xs): 8059361: Properties.stringPropertyNames() returns a set inconsistent with the assertions from the spec

Mandy Chung mandy.chung at oracle.com
Wed May 25 23:58:37 UTC 2016


Hi Stuart,

Have you considered fixing this method to return a unmodifiable set and make this spec in JDK 9?  It’s a small change.

Mandy

> On May 25, 2016, at 4:11 PM, Stuart Marks <stuart.marks at oracle.com> wrote:
> 
> Hi all,
> 
> Please review this small spec change. Properties.stringPropertyNames() seems to imply that the Set it returns is modifiable. It is, but only partially. Since it's a keySet() from a Hashtable, it supports removal but not addition. This change removes the implication that the returned set is fully modifiable.
> 
> Bug report:
> 
>    https://bugs.openjdk.java.net/browse/JDK-8059361
> 
> Diffs below.
> 
> Thanks,
> 
> s'marks
> 
> 
> 
> diff -r 4d9388b1ae27 src/java.base/share/classes/java/util/Properties.java
> --- a/src/java.base/share/classes/java/util/Properties.java	Wed May 25 13:38:35 2016 -0700
> +++ b/src/java.base/share/classes/java/util/Properties.java	Wed May 25 16:09:22 2016 -0700
> @@ -1044,9 +1044,10 @@
>      * properties list.  Properties whose key or value is not
>      * of type {@code String} are omitted.
>      * <p>
> -     * The returned set is not backed by the {@code Properties} object.
> -     * Changes to this {@code Properties} are not reflected in the set,
> -     * or vice versa.
> +     * The returned set is not backed by this {@code Properties} object.
> +     * Changes to this {@code Properties} object are not reflected in the
> +     * returned set. Any modifications that might be allowed on the
> +     * returned set are not reflected in this Properties object.
>      *
>      * @return  a set of keys in this property list where
>      *          the key and its corresponding value are strings,




More information about the core-libs-dev mailing list