On Thu, Mar 27, 2025 at 3:03 PM Jaikiran Pai <jai.forums2...@gmail.com> wrote:
> Hello Eirik, > > The code in URLJarFile which does that check for "~" seems to have been > introduced for https://bugs.openjdk.org/browse/JDK-4447921. It doesn't > tell why the "~" was necessary. > > In any case, I don't think any kind of clean up or introducing tests for > "~" is worth it, given it's not clear what that usage signifies. > Hello Jaikiran, My intention is not to fix or improve the handling of "~" per se. It's just a discrepancy which makes it harder to consolidate the logic. I should have been clear about what I'm actually trying to improve: URLJarFile::isFileURL JarFileFactory::urlFor unix/s/n/w/p/file/Handler::openConnection windows/s/n/w/p/file/Handler::openConnection The above four methods all have copies of the "is local file" check. Other than JarFileFactory::urlFor not considering "~", the logic is identical or simply negated. We should be able to the primitive operations and reuse them as utility methods instead. The primitive operations here are "isLocalFileURL" and "isNonLocalFileURL". To illustrate this possible cleanup, here is a sketch where these two primitives are added to FileURLConnection, then reused from five call sites: https://github.com/openjdk/jdk/compare/master...eirbjo:file-url-local-file-cleanup Thanks, Eirik: