<div dir="ltr"><div><br></div><div>Hi,</div><div><br></div><div>Inspired by JDK-8341142, I noticed that the source code files for sun.net.protocol.www.file.Handler (unix/windows) are actually quite similar in program meaning, but have drifted apart in code style, variable names, comments and general organization. </div><div><br></div><div>This makes diffs between these files more noisy than necessary. By consolidating on style, comments and naming, we get a cleaner diff. This makes it easier to spot the semantic difference between the files for each platform. See draft PR: <a href="https://github.com/openjdk/jdk/pull/21359">https://github.com/openjdk/jdk/pull/21359</a></div><div><br></div><div>Would it be worthwhile doing such a consolidation/cleanup?</div><div><br></div><div>Here's a diff after the consolidation in the draft PR, clearly representing platform differences: </div><div><br></div><div><font face="monospace">--- src/java.base/unix/classes/sun/net/www/protocol/file/Handler.java        2024-10-04 16:18:02.000000000 +0200<br>+++ src/java.base/windows/classes/sun/net/www/protocol/file/Handler.java   2024-10-04 16:32:45.000000000 +0200<br>@@ -1,5 +1,5 @@<br> /*<br>- * Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved.<br>+ * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved.<br>  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.<br>  *<br>  * This code is free software; you can redistribute it and/or modify it<br>@@ -65,7 +65,7 @@<br>            throws IOException {<br> <br>         String file = url.getFile();<br>-        String path = ParseUtil.decode(url.getPath());<br>+        String path = ParseUtil.decode(file).replace('/', '\\').replace('|', ':');<br>         String host = url.getHost();<br> <br>         if (host == null || host.isEmpty() ||<br>@@ -76,6 +76,13 @@<br> <br>         URLConnection uc;<br> <br>+        // attempt to treat this as a UNC path. See 4180841<br>+        path = "\\\\" + host + path;<br>+        File f = new File(path);<br>+        if (f.exists()) {<br>+            return new UNCFileURLConnection(url, f, path);<br>+        }<br>+<br>         // If you reach here, it implies that you have a hostname<br>         // so attempt an ftp connection.</font><br></div></div>