Hei,

Properties is a handy lightweight key-value store that ships with the JDK,
but its store() output still cannot be made reproducible from the API.

Since JDK-8231640 the entries are sorted, and java.properties.date can
replace the timestamp comment. But that property is resolved through
StaticProperty, so it has to be set on the command line and affects the
entire VM, and an empty value falls back to the current date, so the
comment cannot be dropped at all. A library or build tool cannot make its
own store() calls deterministic without dictating how the process is
launched.

The second issue is the line separator. store0 ends lines with
BufferedWriter.newLine(), so the same properties differ byte for byte
between Windows and Linux.

An overload with options would cover both:

  store(Writer, String comments, Set<StoreOption> options)
  store(OutputStream, String comments, Set<StoreOption> options)

with values like NO_DATE_COMMENT and LF_LINE_SEPARATOR, current behaviour
as the default. The change to store0 is small.

While at it, preserving insertion order the way the SequencedMap additions
do would be nice for round-tripping hand-edited files, though I realise
Hashtable makes that a different discussion.

Would such a change be welcome? I am of course happy to file it and write
the patch.

Rafael

Reply via email to