Hi, 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.
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: https://github.com/openjdk/jdk/pull/21359 Would it be worthwhile doing such a consolidation/cleanup? Here's a diff after the consolidation in the draft PR, clearly representing platform differences: --- src/java.base/unix/classes/sun/net/www/protocol/file/Handler.java 2024-10-04 16:18:02.000000000 +0200 +++ src/java.base/windows/classes/sun/net/www/protocol/file/Handler.java 2024-10-04 16:32:45.000000000 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -65,7 +65,7 @@ throws IOException { String file = url.getFile(); - String path = ParseUtil.decode(url.getPath()); + String path = ParseUtil.decode(file).replace('/', '\\').replace('|', ':'); String host = url.getHost(); if (host == null || host.isEmpty() || @@ -76,6 +76,13 @@ URLConnection uc; + // attempt to treat this as a UNC path. See 4180841 + path = "\\\\" + host + path; + File f = new File(path); + if (f.exists()) { + return new UNCFileURLConnection(url, f, path); + } + // If you reach here, it implies that you have a hostname // so attempt an ftp connection.