RFR: 8294241: Deprecate URL public constructors
Daniel Fuchs
dfuchs at openjdk.org
Wed Oct 26 17:57:40 UTC 2022
On Wed, 26 Oct 2022 17:39:56 GMT, Xue-Lei Andrew Fan <xuelei at openjdk.org> wrote:
>> `URLStreamHandler` really belongs to `java.net.URL`, and is an implementation detail of the infrastructure/SPI that makes it possible to eventually call `URL::openConnection`. I do not think it would be appropriate to have such a method in `java.net.URI`. Dealing with `URLStreamHandler` is advanced usage and is not something that a regular developer will need to do, and it is better if it isn't too prominent.
>
> I see your point. It may be more appropriate if URI.toURL was designed as URL.fromURL.
>
> I was wondering to have application developers a consistent way to get an URL instance. Now there are two methods in different classes URI.toURL and URL.fromURI. It might be easier to use the old URI.toURL form.
>
> Never mind, it is just my personal preference. It is fine to me to have a new URL.fromURI method.
One thing we might do is change the name of the method into `URL.of(URI, StreamHandler)`. It's named `fromURI` merely because there was a pre-existing package protected `fromURI` method. However since we're making it public now, it could be fair game to change its name. Possibly adding an overload `URL::of(URI)` method could be considered, but then there really would be two paths to do the same thing - so I'd rather not add such an overload - unless I get some more feedback on that from the CSR/PR review.
-------------
PR: https://git.openjdk.org/jdk/pull/10874
More information about the compiler-dev
mailing list