-
Sub-task
-
Resolution: Delivered
-
P4
-
20
The `java.net.URL` constructors are deprecated in this release.
Developers are encouraged to use `java.net.URI` to parse or construct a URL. In cases where an instance of `java.net.URL` is needed to open a connection, `java.net.URI` can be used to construct or parse the URL string, possibly calling `URI::parseServerAuthority()` to validate that the authority component can be parsed as a server-based authority, and then calling `URI::toURL()` to create the `URL` instance.
A new method, `URL::of(URI, URLStreamHandler)` is provided for the advanced usages where there is a need to construct a `URL` with a given custom stream handler.
See the `java.net.URL` API documentation [1] for more details [2].
[1] https://download.java.net/java/early_access/jdk20/docs/api/java.base/java/net/URL.html#constructor-summary
[2] https://download.java.net/java/early_access/jdk20/docs/api/java.base/java/net/URL.html#constructor-deprecation
Developers are encouraged to use `java.net.URI` to parse or construct a URL. In cases where an instance of `java.net.URL` is needed to open a connection, `java.net.URI` can be used to construct or parse the URL string, possibly calling `URI::parseServerAuthority()` to validate that the authority component can be parsed as a server-based authority, and then calling `URI::toURL()` to create the `URL` instance.
A new method, `URL::of(URI, URLStreamHandler)` is provided for the advanced usages where there is a need to construct a `URL` with a given custom stream handler.
See the `java.net.URL` API documentation [1] for more details [2].
[1] https://download.java.net/java/early_access/jdk20/docs/api/java.base/java/net/URL.html#constructor-summary
[2] https://download.java.net/java/early_access/jdk20/docs/api/java.base/java/net/URL.html#constructor-deprecation