diff options
author | Bryce McKinlay <bryce@waitaki.otago.ac.nz> | 2001-09-30 07:52:16 +0000 |
---|---|---|
committer | Bryce McKinlay <bryce@gcc.gnu.org> | 2001-09-30 08:52:16 +0100 |
commit | 218e1e912d74b89f0a6bd7c694bdc89c4515610b (patch) | |
tree | cee5ad8e6a313b1e905f67f99992217b06f84001 | |
parent | fa8290383271f5131ea04a917cb130e116150538 (diff) | |
download | gcc-218e1e912d74b89f0a6bd7c694bdc89c4515610b.zip gcc-218e1e912d74b89f0a6bd7c694bdc89c4515610b.tar.gz gcc-218e1e912d74b89f0a6bd7c694bdc89c4515610b.tar.bz2 |
re PR libgcj/4383 (file: protocol not supported in URLConnection?)
PR libgcj/4383
* gnu/gcj/protocol/file/Connection.java (connect): Throw
FileNotFoundException if appropriate.
* gnu/gcj/protocol/file/Handler.java (openConnection): Throw an
IOException if we got a file: url with a hostname. Comment out protocol
switch to ftp for now.
* java/net/URL.java (URL): Include protocol name in exception
message
when handler can't be found.
From-SVN: r45898
-rw-r--r-- | libjava/ChangeLog | 8 | ||||
-rw-r--r-- | libjava/gnu/gcj/protocol/file/Connection.java | 6 | ||||
-rw-r--r-- | libjava/gnu/gcj/protocol/file/Handler.java | 3 | ||||
-rw-r--r-- | libjava/java/net/URL.java | 4 |
4 files changed, 18 insertions, 3 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index a76e941..11791d2 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -2,6 +2,14 @@ * java/lang/natClass.cc (_Jv_IsAssignableFrom): Handle the case of an uninitialized target class. + + * gnu/gcj/protocol/file/Connection.java (connect): Throw + FileNotFoundException if appropriate. + * gnu/gcj/protocol/file/Handler.java (openConnection): Throw an + IOException if we got a file: url with a hostname. Comment out protocol + switch to ftp for now. + * java/net/URL.java (URL): Include protocol name in exception message + when handler can't be found. 2001-09-28 Per Bothner <per@bothner.com> diff --git a/libjava/gnu/gcj/protocol/file/Connection.java b/libjava/gnu/gcj/protocol/file/Connection.java index b7804cb..e9ef08f 100644 --- a/libjava/gnu/gcj/protocol/file/Connection.java +++ b/libjava/gnu/gcj/protocol/file/Connection.java @@ -48,7 +48,11 @@ class Connection extends URLConnection // If not connected, then file needs to be openned. fileIn = new File(url.getFile()); - connected = true; + + if (fileIn.exists()) + connected = true; + else + throw new FileNotFoundException("No such file or directory"); } public InputStream getInputStream() throws IOException diff --git a/libjava/gnu/gcj/protocol/file/Handler.java b/libjava/gnu/gcj/protocol/file/Handler.java index b4d8fbf..f48ef8e 100644 --- a/libjava/gnu/gcj/protocol/file/Handler.java +++ b/libjava/gnu/gcj/protocol/file/Handler.java @@ -35,6 +35,8 @@ public class Handler extends URLStreamHandler String host = url.getHost(); if ((host != null) && (! host.equals(""))) { + throw new IOException("ftp protocol handler not yet implemented."); + /* // Reset the protocol (and implicitly the handler) for this URL. // Then have the URL attempt the connection again, as it will // get the changed handler the next time around. @@ -43,6 +45,7 @@ public class Handler extends URLStreamHandler // Until the ftp protocol handler is written, this will cause // a NullPointerException. return url.openConnection(); + */ } return new Connection(url); diff --git a/libjava/java/net/URL.java b/libjava/java/net/URL.java index 25291fa..636e6ef 100644 --- a/libjava/java/net/URL.java +++ b/libjava/java/net/URL.java @@ -76,7 +76,7 @@ public final class URL implements Serializable this.handler = setURLStreamHandler(protocol); if (this.handler == null) - throw new MalformedURLException("Handler for protocol not found"); + throw new MalformedURLException("Protocol handler not found: " + protocol); this.host = host; @@ -175,7 +175,7 @@ public final class URL implements Serializable this.handler = setURLStreamHandler(protocol); if (this.handler == null) - throw new MalformedURLException("Handler for protocol not found"); + throw new MalformedURLException("Protocol handler not found: " + protocol); // JDK 1.2 doc for parseURL specifically states that any '#' ref // is to be excluded by passing the 'limit' as the indexOf the '#' |