RFR: 8231640: (prop) Canonical property storage [v15]

Daniel Fuchs dfuchs at openjdk.java.net
Tue Sep 14 20:43:40 UTC 2021


On Tue, 14 Sep 2021 18:53:27 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

>> Jaikiran Pai has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Introduce a test to make sure backslash character in the system property value doesn't cause unexpected output.
>>   Plus minor updates to tests to add additional checks.
>
> src/java.base/share/classes/java/util/Properties.java line 929:
> 
>> 927:             @SuppressWarnings("unchecked")
>> 928:             var entries = new ArrayList<>(((Map<String, String>) (Map) map).entrySet());
>> 929:             entries.sort(Map.Entry.comparingByKey());
> 
> Since Properties can be subclassed and the `entrySet()` method overridden, should the set of entries to be sorted be taken from this.entrySet() instead of bypassing the public API?

Hmm, so if someone has subclassed `Properties` and overridden `entrySet` for the purpose of ordering entries, that trick will no longer work with the new code. I wonder - should we sort entries only when the `java.util.Properties.storeDate` is also defined and not empty? Or should we simply state in the release notes that such tricks will no longer work?

-------------

PR: https://git.openjdk.java.net/jdk/pull/5372


More information about the core-libs-dev mailing list