This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new c383a5da19 minor refactor: future proofing by replacing constructor
deprecated in JDK20
c383a5da19 is described below
commit c383a5da1928593fb7e9188df1c436c801dddcd6
Author: Paul King <[email protected]>
AuthorDate: Sun Mar 8 12:19:44 2026 +1000
minor refactor: future proofing by replacing constructor deprecated in JDK20
---
.../org/codehaus/groovy/runtime/ResourceGroovyMethods.java | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git
a/src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java
b/src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java
index bf5c07858b..be5b8d97cb 100644
--- a/src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java
+++ b/src/main/java/org/codehaus/groovy/runtime/ResourceGroovyMethods.java
@@ -2685,7 +2685,11 @@ public class ResourceGroovyMethods extends
DefaultGroovyMethodsSupport {
* @since 1.8.2
*/
public static URL toURL(CharSequence self) throws MalformedURLException {
- return new URL(self.toString());
+ try {
+ return toURI(self.toString()).toURL();
+ } catch (URISyntaxException e) {
+ throw new RuntimeException(e);
+ }
}
/**
@@ -2697,7 +2701,11 @@ public class ResourceGroovyMethods extends
DefaultGroovyMethodsSupport {
* @since 1.0
*/
public static URL toURL(String self) throws MalformedURLException {
- return new URL(self);
+ try {
+ return toURI(self).toURL();
+ } catch (URISyntaxException e) {
+ throw new RuntimeException(e);
+ }
}
/**