From 8aa540d2f783474d1d2e06f16744bf67b9c1facc Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Fri, 10 Mar 2006 21:46:48 +0000 Subject: Imported GNU Classpath 0.90 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. From-SVN: r111942 --- libjava/classpath/java/net/URL.java | 73 +++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 27 deletions(-) (limited to 'libjava/classpath/java/net/URL.java') 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(); -- cgit v1.2.3