Bug 207294 - FileObject.toURI
FileObject.toURI
Status: RESOLVED FIXED
Product: platform
Classification: Unclassified
Component: Filesystems
7.1
All All
: P3 (vote)
: 7.2
Assigned To: Jesse Glick
issues@platform
: API
Depends on: 207648 207690
Blocks: 207060
  Show dependency treegraph
 
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
:


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.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo