Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8294241 Deprecate URL public constructors
  3. JDK-8296385

Release Note: java.net.URL Constructors Are Deprecated

    XMLWordPrintable

Details

    • b23
    • 20

    Description

      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

      Attachments

        Activity

          People

            dfuchs Daniel Fuchs
            dfuchs Daniel Fuchs
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: