diff options
author | Julien Gouesse <[email protected]> | 2023-04-09 15:24:34 +0200 |
---|---|---|
committer | Julien Gouesse <[email protected]> | 2023-04-09 15:24:34 +0200 |
commit | f9690cba75a6bbf352ef9eadf66931a89bc2baa2 (patch) | |
tree | 7ff8f45cab89d5d86599d681fa0aab7b5113a984 /ardor3d-core/src | |
parent | a4fcb3ec34929a2094f785504737227f23762f26 (diff) |
Prepares the removal of deprecated calls to URL constructors to improve the support of Java 20
Diffstat (limited to 'ardor3d-core/src')
3 files changed, 16 insertions, 2 deletions
diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/UrlUtils.java b/ardor3d-core/src/main/java/com/ardor3d/util/UrlUtils.java index 7690b35..02430ce 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/util/UrlUtils.java +++ b/ardor3d-core/src/main/java/com/ardor3d/util/UrlUtils.java @@ -11,6 +11,8 @@ package com.ardor3d.util; import java.net.MalformedURLException; +import java.net.URISyntaxException; +import java.net.URI; import java.net.URL; public class UrlUtils { @@ -28,7 +30,7 @@ public class UrlUtils { * @throws MalformedURLException * if we are unable to create the URL. */ - public static URL resolveRelativeURL(final URL primaryUrl, final String relativeLoc) throws MalformedURLException { + public static URL resolveRelativeURL(final URL primaryUrl, final String relativeLoc) throws MalformedURLException, URISyntaxException { // Because URL(base, string) does not handle correctly URLs that have %2F, we have to manually replace these. // So, we grab the URL as a string String url = primaryUrl.toString(); @@ -37,6 +39,8 @@ public class UrlUtils { url = url.replaceAll("\\%2[F,f]", "/"); // And make our new URL + //FIXME: the line below should get rid of a deprecated call but it throws java.lang.IllegalArgumentException: URI is not absolute + //return new URI(url).resolve(relativeLoc).toURL(); return new URL(new URL(url), relativeLoc); } diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/resource/SimpleResourceLocator.java b/ardor3d-core/src/main/java/com/ardor3d/util/resource/SimpleResourceLocator.java index b7a73c3..2505d61 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/util/resource/SimpleResourceLocator.java +++ b/ardor3d-core/src/main/java/com/ardor3d/util/resource/SimpleResourceLocator.java @@ -92,6 +92,8 @@ public class SimpleResourceLocator implements ResourceLocator { spec = spec.replaceAll("\\+", "%20"); final URL rVal = new URL(_baseDir.toURL(), spec); + //FIXME use this to get rid of a deprecated call: + //final URL rVal = _baseDir.resolve(spec).toURL(); // open a stream to see if this is a valid resource // XXX: Perhaps this is wasteful? Also, what info will determine validity? rVal.openStream().close(); diff --git a/ardor3d-core/src/main/java/com/ardor3d/util/resource/URLResourceSource.java b/ardor3d-core/src/main/java/com/ardor3d/util/resource/URLResourceSource.java index ae1885c..f6bf998 100644 --- a/ardor3d-core/src/main/java/com/ardor3d/util/resource/URLResourceSource.java +++ b/ardor3d-core/src/main/java/com/ardor3d/util/resource/URLResourceSource.java @@ -13,6 +13,8 @@ package com.ardor3d.util.resource; import java.io.IOException; import java.io.InputStream; import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.net.URLDecoder; import java.util.Objects; @@ -89,7 +91,7 @@ public class URLResourceSource implements ResourceSource { return new URLResourceSource(srcURL); } - } catch (final MalformedURLException ex) { + } catch (final MalformedURLException|URISyntaxException ex) { } catch (final IOException ex) { } if (logger.isLoggable(Level.FINEST)) { @@ -192,6 +194,12 @@ public class URLResourceSource implements ResourceSource { if (protocol != null && host != null && file != null) { setURL(new URL(protocol, host, file)); + //FIXME use this to get rid of a deprecated call +// try { +// setURL(new URI(protocol, host, file, null).toURL()); +// } catch (final URISyntaxException urise) { +// throw new IOException(urise); +// } } _type = capsule.readString("type", null); |