openrewrite / openrewrite/rewrite-migrate-java
Forbidden method invocation: `java.net.URL#<init>(java.lang.String,java.lang.String,int,java.lang.String,java.net.URLStreamHandler)` [Deprecated in Java 21]
Open
Nobody has claimed this yet.
java 21+
recipe
- Dominant language
- Java
- Stars
- 156
- Forks
- 130
- Avg merge
- 20h 57m
- Merged PRs (30d)
- 21
Description
What version of OpenRewrite are you using?
I am using
- OpenRewrite v1.2.3
- Maven/Gradle plugin v1.2.3
- rewrite-module v1.2.3
How are you running OpenRewrite?
I am using the Maven plugin, and my project is a single module project.
<rewrite-migrate-java.version>3.17.0</rewrite-migrate-java.version>
What is the smallest, simplest way to reproduce the problem?
final URL url = new URL("test", null, 0, "", new URLStreamHandler() {
@Override
protected URLConnection openConnection(URL u) {
return urlConnection;
}
});
What did you expect to see?
final URL url = new URL("test", null, 0, "", new URLStreamHandler() {
@Override
protected URLConnection openConnection(URL u) {
return urlConnection;
}
});
What did you see instead?
final URL url = URL.of(new URI("test:///"), new URLStreamHandler() {
@Override
protected URLConnection openConnection(URL u) {
return urlConnection;
}
});
What is the full stack trace of any errors you encountered?
stacktrace output here
Are you interested in contributing a fix to OpenRewrite?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Java reproducer in the issue and compare the Maven migration result with the reported URL constructor and URL.of forms. Trace the recipe that handles the deprecated java.net.URL constructor, using the linked Checkstyle pull request for context. Done means the migration behavior for this constructor is correct and covered by a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100