diff options
| author | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-03-10 21:46:48 +0000 |
|---|---|---|
| committer | mark <mark@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-03-10 21:46:48 +0000 |
| commit | ce57ab760f69de6db452def7ffbf5b114a2d8694 (patch) | |
| tree | ea38c56431c5d4528fb54254c3f8e50f517bede3 /libjava/classpath/java/net/URL.java | |
| parent | 50996fe55769882de3f410896032c887f0ff0d04 (diff) | |
| download | gcc-ce57ab760f69de6db452def7ffbf5b114a2d8694.tar.gz | |
Imported GNU Classpath 0.90
* scripts/makemake.tcl: Set gnu/java/awt/peer/swing to ignore.
* gnu/classpath/jdwp/VMFrame.java (SIZE): New constant.
* java/lang/VMCompiler.java: Use gnu.java.security.hash.MD5.
* java/lang/Math.java: New override file.
* java/lang/Character.java: Merged from Classpath.
(start, end): Now 'int's.
(canonicalName): New field.
(CANONICAL_NAME, NO_SPACES_NAME, CONSTANT_NAME): New constants.
(UnicodeBlock): Added argument.
(of): New overload.
(forName): New method.
Updated unicode blocks.
(sets): Updated.
* sources.am: Regenerated.
* Makefile.in: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@111942 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/java/net/URL.java')
| -rw-r--r-- | libjava/classpath/java/net/URL.java | 73 |
1 files changed, 46 insertions, 27 deletions
diff --git a/libjava/classpath/java/net/URL.java b/libjava/classpath/java/net/URL.java index 168c67a19ee..967cc80f69b 100644 --- a/libjava/classpath/java/net/URL.java +++ b/libjava/classpath/java/net/URL.java @@ -399,40 +399,59 @@ public final class URL implements Serializable && ! spec.regionMatches(colon, "://:", 0, 4)) context = null; + boolean protocolSpecified = false; + if ((colon = spec.indexOf(':')) > 0 && (colon < slash || slash < 0)) { - // Protocol specified in spec string. + // Protocol may have been specified in spec string. + protocolSpecified = true; protocol = spec.substring(0, colon).toLowerCase(); - if (context != null && context.protocol.equals(protocol)) - { - // The 1.2 doc specifically says these are copied to the new URL. - host = context.host; - port = context.port; - userInfo = context.userInfo; - authority = context.authority; - } + if (context != null) + { + if (context.protocol.equals(protocol)) + { + // The 1.2 doc specifically says these are copied to the new URL. + host = context.host; + port = context.port; + userInfo = context.userInfo; + authority = context.authority; + } + else + { + // There was a colon in the spec. Check to see if + // what precedes it is a valid protocol. If it was + // not, assume that it is relative to the context. + URLStreamHandler specPh = getURLStreamHandler(protocol.trim()); + if (null == specPh) + protocolSpecified = false; + } + } } - else if (context != null) + + if (!protocolSpecified) { - // Protocol NOT specified in spec string. - // Use context fields (except ref) as a foundation for relative URLs. - colon = -1; - protocol = context.protocol; - host = context.host; - port = context.port; - userInfo = context.userInfo; - if (spec.indexOf(":/", 1) < 0) - { - file = context.file; - if (file == null || file.length() == 0) - file = "/"; - } - authority = context.authority; + if (context != null) + { + // Protocol NOT specified in spec string. + // Use context fields (except ref) as a foundation for relative URLs. + colon = -1; + protocol = context.protocol; + host = context.host; + port = context.port; + userInfo = context.userInfo; + if (spec.indexOf(":/", 1) < 0) + { + file = context.file; + if (file == null || file.length() == 0) + file = "/"; + } + authority = context.authority; + } + else // Protocol NOT specified in spec. and no context available. + throw new MalformedURLException("Absolute URL required with null" + + " context: " + spec); } - else // Protocol NOT specified in spec. and no context available. - throw new MalformedURLException("Absolute URL required with null" - + " context: " + spec); protocol = protocol.trim(); |
