Hi Alan,

The maximum line length is actually slightly reduced by the proposed patch:

--- a/src/java.base/share/classes/java/nio/file/FileSystems.java Tue Apr 30 16:11:42 2019 -0700 +++ b/src/java.base/share/classes/java/nio/file/FileSystems.java Wed May 01 00:12:25 2019 -0700
@@ -252,10 +252,9 @@
      * Suppose there is a provider identified by the scheme {@code "memory"}
      * installed:
      * <pre>
-     *   Map&lt;String,String&gt; env = new HashMap&lt;&gt;();
-     *   env.put("capacity", "16G");
-     *   env.put("blockSize", "4k");
-     *   FileSystem fs = FileSystems.newFileSystem(URI.create("memory:///?name=logfs"), env); +     *   FileSystem fs = FileSystems.newFileSystem(URI.create("memory:///?name=logfs"),
+ * Map.of("capacity", "16G",
+ * "blockSize", "4k"));
      * </pre>
      *
      * @param   uri

Keeping env to one line also gives a comparably long line length:

--- a/src/java.base/share/classes/java/nio/file/FileSystems.java Tue Apr 30 16:11:42 2019 -0700 +++ b/src/java.base/share/classes/java/nio/file/FileSystems.java Wed May 01 09:50:15 2019 -0700
@@ -252,9 +252,7 @@
      * Suppose there is a provider identified by the scheme {@code "memory"}
      * installed:
      * <pre>
-     *   Map&lt;String,String&gt; env = new HashMap&lt;&gt;();
-     *   env.put("capacity", "16G");
-     *   env.put("blockSize", "4k");
+     *   Map&lt;String,String&gt; env = Map.of("capacity", "16G", "blockSize", "4k");       *   FileSystem fs = FileSystems.newFileSystem(URI.create("memory:///?name=logfs"), env);
      * </pre>
      *
The {"capacity", "16G"} and {"blockSize", "4k"} can be put on different lines to provide a stronger visual hint of grouping.

Which of these alternatives do you prefer?

Thanks,

-Joe

On 4/30/2019 11:16 PM, Alan Bateman wrote:
On 01/05/2019 02:59, Joe Darcy wrote:
:

--- a/src/java.base/share/classes/java/nio/file/FileSystems.java Tue Apr 30 16:11:42 2019 -0700 +++ b/src/java.base/share/classes/java/nio/file/FileSystems.java Tue Apr 30 18:52:11 2019 -0700
@@ -252,10 +252,9 @@
      * Suppose there is a provider identified by the scheme {@code "memory"}
      * installed:
      * <pre>
-     *   Map&lt;String,String&gt; env = new HashMap&lt;&gt;();
-     *   env.put("capacity", "16G");
-     *   env.put("blockSize", "4k");
-     *   FileSystem fs = FileSystems.newFileSystem(URI.create("memory:///?name=logfs"), env); +     *   FileSystem fs = FileSystems.newFileSystem(URI.create("memory:///?name=logfs"),
+ * Map.of("capacity", "16G",
+ * "blockSize", "4k"));
Changing it to use an unmodifable map is good. One nit the really long line in the source will be annoying with future side-by-side diffs. It wouldn't take much from the readability to keep env.

-Alan

Reply via email to