<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Right, as you say using a relative path like that does not work
for URL. It is possible to create relative URLs with the URL class
(which is non-standard, unspecified behavior and one of the
reasons why URI is better). So, I think we'd need to see the
actual URL string being used.</p>
<p>- Michael.<br>
</p>
<div class="moz-cite-prefix">On 16/12/2022 10:06, Daniel Fuchs
wrote:<br>
</div>
<blockquote type="cite" cite="mid:7f963f7f-9cf3-2c3f-8198-b2ce5b9bd042@oracle.com">Hi
Rick,
<br>
<br>
new URL("extinout/mybackup") throws a MalformedURLException too,
so
<br>
I wouldn't expect new URI("extinout/mybackup").toURL() to work.
<br>
<br>
In that case I would recommend resolving the relative URI against
<br>
its absolute base before translating to URL.
<br>
<br>
My recommendation would be to use URL only at the point where
<br>
you call openConnection().
<br>
<br>
<br>
best regards,
<br>
<br>
-- daniel
<br>
<br>
<br>
On 15/12/2022 23:53, Rick Hillegas wrote:
<br>
<blockquote type="cite">Thanks for the quick response, Alan. One
comment inline...
<br>
<br>
On 12/15/22 12:24 PM, Alan Bateman wrote:
<br>
<blockquote type="cite">On 15/12/2022 19:14, Rick Hillegas
wrote:
<br>
<blockquote type="cite">
<br>
I see many warnings when I build Apache Derby's code and
javadoc with Open JDK build 20-ea+27-2213. In particular, I
see a number of warnings introduced by the following change:
<br>
<br>
- JDK-8294241: Deprecate URL public constructors
<br>
<br>
I naively tried to fix these warnings by changing instances
of
<br>
<br>
new URL(urlString)
<br>
<br>
<br>
to
<br>
<br>
(new URI(urlString)).toURL() >>>
<br>
<br>
Unfortunately, this breaks the Derby code. When I test
Derby, I see errors like the following:
<br>
<br>
java.lang.IllegalArgumentException: URI is not absolute
<br>
at java.base/java.net.URL.of(URL.java:854)
<br>
at java.base/java.net.URI.toURL(URI.java:1144)
<br>
at
org.apache.derby.impl.store.raw.RawStore.backup(RawStore.java:641)
<br>
<br>
Can you give me advice about the best way to workaround the
deprecation of the public URL constructors? I am looking for
a solution which handles relative URL strings.
<br>
<br>
</blockquote>
URL::toURL is specified to throw if the URI is not absolute
although the IAE may be a bit surprising as there isn't any
arguments.
<br>
<br>
Can you give an example of the "relative URL strings" so we
can at least see which URI scheme this is.
<br>
</blockquote>
<br>
This happens when urlString is a directory spec relative to the
working directory of the JVM. E.g.,
<br>
<br>
extinout/mybackup
<br>
</blockquote>
<br>
</blockquote>
</body>
</html>