Java Cup
Inside Java

News and views from members of the Java team at Oracle

JDK 20: java.net.URL parsing fix & behavior change - Quality Outreach Heads-up

The OpenJDK Quality Group promotes the testing of FOSS projects with OpenJDK early-access builds as a way to improve the overall quality of the release. This heads-up is part of a Quality Outreach update sent to the projects involved. To learn more about the program and how to join, please check the Quality Outreach wiki page.

JDK 20 - java.net.URL parsing fix & behavior change

Before JDK 20, some of the parsing/validation performed by the JDK built-in URLStreamHandler implementations were delayed until URL::openConnection or URLConnection::connect was called. Starting JDK 20, some of these parsing/validations are now performed early, i.e. within URL constructors.

An exception caused by a malformed URL that would have been delayed until the connection was opened or connected may starting JDK 20, throw a MalformedURLException at URL construction time.

Call to Action

We suggest testing your codebase against this change. And for those who want to rely on the old behavior, a new system property has been introduced to revert, on the command line, to the previous behavior.

More Information

~