This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | Add FileUtil methods to get URLs for archives and folders | ||
---|---|---|---|
Product: | platform | Reporter: | Jesse Glick <jglick> |
Component: | Filesystems | Assignee: | apireviews <apireviews> |
Status: | RESOLVED FIXED | ||
Severity: | blocker | CC: | issues, issues, mkrauskopf, tzezula |
Priority: | P1 | Keywords: | API, API_REVIEW_FAST |
Version: | 5.x | ||
Hardware: | All | ||
OS: | All | ||
Issue Type: | ENHANCEMENT | Exception Reporter: | |
Attachments: | Proposed patch |
Description
Jesse Glick
2005-05-26 21:50:45 UTC
I vote for the FileUtil, there are already the getArchiveRoot and the getArchiveFile methods. Re. "convert classpaths between URL[] form and string form" - and/or convert between File (as used in -classpath) and URL. Examples: File("/tmp/dir") -> file:/tmp/dir/ File("/tmp/archive.jar") -> jar:file:/tmp/archive.jar!/ file:/tmp/dir/ -> File("/tmp/dir") jar:file:/tmp/archive.jar!/ -> File("/tmp/archive.jar") and the ones that people usually forget to check for, resulting in the occasional error: File("/tmp/nonexistent-dir") -> file:/tmp/nonexistent-dir/ [need final '/'] jar:file:/tmp/archive.jar -> null [missing JAR path; or assume "!/" anyway?] jar:file:/tmp/archive.jar!/subpath/ -> null [not a root] jar:jar:file:/tmp/archive.jar!/subjar.jar!/ -> null [nested not permitted] http://nowhere.net/ -> null [remote] jar:http://nowhere.net/archive.jar!/ -> null [remote] Converting String -> URL[] would require PropertyUtils.tokenizePath or its equivalent to correctly handle ':' as a drive letter marker on Windows rather than a path separator (assuming the method permitted either ':' or ';' on any platform, as Ant does). There should be probably a method on the ClassPathSupport creating the classpath from the string: ClassPathSupport.fromJVMPath (String path); and a method on the ClassPath creating the string representation of the classpath: ClassPath.toJVMPath() This is important. People don't know how to do it right and wind up doing it wrong. And similar but slightly different code is scattered all over the place. For the ClassPath -> String conversion I would suggest a mode parameter which would control behavior on untranslatable entries (e.g. jar:file:/tmp/src.zip!/src/): enum Mode { SKIP - such entries are silently dropped WARN - a log warning is issued FAIL - an IAE is thrown PRINT - the URL.toString is included (useful for debugging and unit tests) } I am working on a patch for this, will submit soon. Created attachment 58104 [details]
Proposed patch
Please review. Patch contains API changes, and usage from modules I suspected needed the new APIs. Both API (filesystems & java api) seems good. +1 from me, api looks fine. Also used it in java.freeform. #4c8b2e081042 |