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.

Bug 207294 - FileObject.toURI
Summary: FileObject.toURI
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Filesystems (show other bugs)
Version: 7.1
Hardware: All All
: P3 normal (vote)
Assignee: Jesse Glick
URL:
Keywords: API
Depends on: 207648 207690
Blocks: 207060
  Show dependency tree
 
Reported: 2012-01-13 18:21 UTC by Jesse Glick
Modified: 2012-02-09 09:39 UTC (History)
1 user (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
Patch in progress (72.00 KB, patch)
2012-01-13 19:56 UTC, Jesse Glick
Details | Diff
Updated patch (178.46 KB, patch)
2012-01-19 19:23 UTC, Jesse Glick
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2012-01-13 18:21:58 UTC
Lots of new APIs use URI rather than File or FileObject, and it is cumbersome to call fo.getURL().toURI(), not to mention catching two different checked exceptions.
Comment 1 Jesse Glick 2012-01-13 19:56:26 UTC
Created attachment 114895 [details]
Patch in progress

Fixed some sources which were catching FileStateInvalidException and no longer need to; would fix the rest (at least in cluster.config=stableuc) before commit.
Comment 2 Jesse Glick 2012-01-13 19:56:51 UTC
Please review.
Comment 3 Jesse Glick 2012-01-13 20:43:13 UTC
If reviewers are uncomfortable removing the throws clause from getURL(), which is binary compatible but not source compatible, an alternate approach would be:

/** @deprecated use {@link #toURL} */
public final URL getURL() throws FileStateInvalidException {
    return toURL();
}
/** @since 7.57 */
public final URL toURL() {
    return URLMapper.findURL(this, URLMapper.INTERNAL);
}

which also better matches the naming idiom established in java.io.File. (A URL is not so much a property of a FileObject as it is an alternative representation.)


By the way FileObject.getFileSystem() is documented to throw FileStateInvalidException yet this only actually happens after deserialization, i.e. essentially never. This could perhaps be fixed in a separate API review, which would save a lot more silly catch clauses. (There are a few other miscellaneous uses of FSIE in methods declared to throw IOE.)
Comment 4 Jesse Glick 2012-01-19 19:23:01 UTC
Created attachment 115094 [details]
Updated patch

Similar but leaves getURL signature unchanged and introduces toURL as a replacement, for source-level compatibility and naming consistency.

Also updates some more modules to use the new idioms. Inspect & Refactor is great here; still need to manually correct compilation errors caused by code no longer throwing FSIE, but only after applying refactoring, so can be done at any time.

Will commit tomorrow unless there are objections.
Comment 5 Jesse Glick 2012-01-20 14:32:10 UTC
core-main #4acf9d4318d6
Comment 6 Quality Engineering 2012-01-25 16:41:07 UTC
Integrated into 'main-golden', will be available in build *201201250600* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/4acf9d4318d6
User: Jesse Glick <jglick@netbeans.org>
Log: #207294: FileObject.toURI/toURL.