summaryrefslogtreecommitdiff
path: root/java/net
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2005-01-16 15:14:51 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2005-01-16 15:14:51 +0000
commitf3bca904add8a1e256b2c245c169e8e5a69efcd7 (patch)
tree4b18335ee421c49bcc9a418d9abc4193634986f7 /java/net
parente38101c185b90d301bac951b84a77ed711d18e54 (diff)
downloadclasspath-f3bca904add8a1e256b2c245c169e8e5a69efcd7.tar.gz
2005-01-16 Andrew John Hughes <gnu_andrew@member.fsf.org>
Final merge of HEAD patches to generics branch All changes are listed in merged Changelog. In addition, * java/lang/System.java: (getenv()): changed Runtime.securityManager to SecurityManager.current (getenv(String)): likewise (remove(String)): pointed to SystemProperties * gnu/classpath/SystemProperties.java: (remove(String)): implemented and documented
Diffstat (limited to 'java/net')
-rw-r--r--java/net/Inet4Address.java68
-rw-r--r--java/net/InetAddress.java33
-rw-r--r--java/net/URL.java11
3 files changed, 37 insertions, 75 deletions
diff --git a/java/net/Inet4Address.java b/java/net/Inet4Address.java
index 917e9e3e6..cdcfab052 100644
--- a/java/net/Inet4Address.java
+++ b/java/net/Inet4Address.java
@@ -1,5 +1,5 @@
/* Inet4Address.java --
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -39,7 +39,6 @@ exception statement from your version. */
package java.net;
import java.io.ObjectStreamException;
-import java.util.Arrays;
/*
* Written using on-line Java Platform 1.4 API Specification and
@@ -85,7 +84,7 @@ public final class Inet4Address extends InetAddress
*/
public boolean isMulticastAddress()
{
- return (addr[0] & 0xF0) == 0xE0;
+ return super.isMulticastAddress();
}
/**
@@ -93,7 +92,7 @@ public final class Inet4Address extends InetAddress
*/
public boolean isLoopbackAddress()
{
- return addr[0] == 0x7F;
+ return super.isLoopbackAddress();
}
/**
@@ -103,9 +102,7 @@ public final class Inet4Address extends InetAddress
*/
public boolean isAnyLocalAddress()
{
- byte[] anylocal = { 0, 0, 0, 0 };
-
- return Arrays.equals(addr, anylocal);
+ return super.isAnyLocalAddress();
}
/**
@@ -115,8 +112,7 @@ public final class Inet4Address extends InetAddress
*/
public boolean isLinkLocalAddress()
{
- // XXX: This seems to not exist with IPv4 addresses
- return false;
+ return super.isLinkLocalAddress();
}
/**
@@ -126,23 +122,7 @@ public final class Inet4Address extends InetAddress
*/
public boolean isSiteLocalAddress()
{
- // 10.0.0.0/8
- if (addr[0] == 0x0A)
- return true;
-
- // XXX: Suns JDK 1.4.1 (on Linux) seems to have a bug here:
- // it says 172.16.0.0 - 172.255.255.255 are site local addresses
- //
- // 172.16.0.0/12
- if (addr[0] == 0xAC && (addr[1] & 0xF0) == 0x01)
- return true;
-
- // 192.168.0.0/16
- if (addr[0] == 0xC0 && addr[1] == 0xA8)
- return true;
-
- // XXX: Do we need to check more addresses here ?
- return false;
+ return super.isSiteLocalAddress();
}
/**
@@ -152,8 +132,7 @@ public final class Inet4Address extends InetAddress
*/
public boolean isMCGlobal()
{
- // XXX: This seems to net exist with IPv4 addresses
- return false;
+ return super.isMCGlobal();
}
/**
@@ -163,8 +142,7 @@ public final class Inet4Address extends InetAddress
*/
public boolean isMCNodeLocal()
{
- // XXX: This seems to net exist with IPv4 addresses
- return false;
+ return isMCNodeLocal();
}
/**
@@ -174,10 +152,7 @@ public final class Inet4Address extends InetAddress
*/
public boolean isMCLinkLocal()
{
- if (! isMulticastAddress())
- return false;
-
- return (addr[0] == 0xE0) && (addr[1] == 0x00) && (addr[2] == 0x00);
+ return super.isMCLinkLocal();
}
/**
@@ -187,8 +162,7 @@ public final class Inet4Address extends InetAddress
*/
public boolean isMCSiteLocal()
{
- // XXX: This seems to net exist with IPv4 addresses
- return false;
+ return super.isMCSiteLocal();
}
/**
@@ -198,8 +172,7 @@ public final class Inet4Address extends InetAddress
*/
public boolean isMCOrgLocal()
{
- // XXX: This seems to net exist with IPv4 addresses
- return false;
+ return isMCOrgLocal();
}
/**
@@ -217,22 +190,7 @@ public final class Inet4Address extends InetAddress
*/
public String getHostAddress()
{
- StringBuffer sbuf = new StringBuffer(40);
- int len = addr.length;
- int i = 0;
-
- for (;;)
- {
- sbuf.append(addr[i] & 0xFF);
- i++;
-
- if (i == len)
- break;
-
- sbuf.append('.');
- }
-
- return sbuf.toString();
+ return super.getHostAddress();
}
/**
@@ -272,4 +230,4 @@ public final class Inet4Address extends InetAddress
return true;
}
-} // class Inet4Address
+}
diff --git a/java/net/InetAddress.java b/java/net/InetAddress.java
index dd3706177..a99057df8 100644
--- a/java/net/InetAddress.java
+++ b/java/net/InetAddress.java
@@ -227,7 +227,7 @@ public class InetAddress implements Serializable
{
// Mask against high order bits of 1110
if (addr.length == 4)
- return (addr[0] & 0xF0) == 0xE0;
+ return (addr[0] & 0xf0) == 0xe0;
return false;
}
@@ -253,7 +253,7 @@ public class InetAddress implements Serializable
{
// This is the IPv4 implementation.
// Any class derived from InetAddress should override this.
- return addr[0] == 0x7F;
+ return (addr[0] & 0xff) == 0x7f;
}
/**
@@ -278,18 +278,17 @@ public class InetAddress implements Serializable
{
// This is the IPv4 implementation.
// Any class derived from InetAddress should override this.
+
// 10.0.0.0/8
- if (addr[0] == 0x0A)
+ if ((addr[0] & 0xff) == 0x0a)
return true;
- // XXX: Suns JDK 1.4.1 (on Linux) seems to have a bug here:
- // it says 172.16.0.0 - 172.255.255.255 are site local addresses
// 172.16.0.0/12
- if (addr[0] == 0xAC && (addr[1] & 0xF0) == 0x01)
+ if ((addr[0] & 0xff) == 0xac && (addr[1] & 0xf0) == 0x10)
return true;
// 192.168.0.0/16
- if (addr[0] == 0xC0 && addr[1] == 0xA8)
+ if ((addr[0] & 0xff) == 0xc0 && (addr[1] & 0xff) == 0xa8)
return true;
// XXX: Do we need to check more addresses here ?
@@ -310,7 +309,7 @@ public class InetAddress implements Serializable
}
/**
- * Utility reoutine to check if InetAddress is a node local multicast address
+ * Utility routine to check if InetAddress is a node local multicast address.
*
* @since 1.4
*/
@@ -323,7 +322,7 @@ public class InetAddress implements Serializable
}
/**
- * Utility reoutine to check if InetAddress is a link local multicast address
+ * Utility routine to check if InetAddress is a link local multicast address.
*
* @since 1.4
*/
@@ -334,11 +333,13 @@ public class InetAddress implements Serializable
if (! isMulticastAddress())
return false;
- return (addr[0] == 0xE0 && addr[1] == 0x00 && addr[2] == 0x00);
+ return ((addr[0] & 0xff) == 0xe0
+ && (addr[1] & 0xff) == 0x00
+ && (addr[2] & 0xff) == 0x00);
}
/**
- * Utility routine to check if InetAddress is a site local multicast address
+ * Utility routine to check if InetAddress is a site local multicast address.
*
* @since 1.4
*/
@@ -351,8 +352,8 @@ public class InetAddress implements Serializable
}
/**
- * Utility reoutine to check if InetAddress is a organization local
- * multicast address
+ * Utility routine to check if InetAddress is a organization local
+ * multicast address.
*
* @since 1.4
*/
@@ -474,7 +475,7 @@ public class InetAddress implements Serializable
int i = len > 4 ? len - 4 : 0;
for (; i < len; i++)
- hash = (hash << 8) | (addr[i] & 0xFF);
+ hash = (hash << 8) | (addr[i] & 0xff);
return hash;
}
@@ -802,7 +803,7 @@ public class InetAddress implements Serializable
* This method returns the hostname for a given IP address. It will
* throw an UnknownHostException if the hostname cannot be determined.
*
- * @param ip The IP address as a int array
+ * @param ip The IP address as a byte array
*
* @return The hostname
*
@@ -847,7 +848,7 @@ public class InetAddress implements Serializable
int i = len - 4;
for (; i < len; i++)
- address = address << 8 | (((int) addr[i]) & 0xFF);
+ address = address << 8 | (addr[i] & 0xff);
oos.defaultWriteObject();
}
diff --git a/java/net/URL.java b/java/net/URL.java
index 4efd7c6d1..c63d4a49f 100644
--- a/java/net/URL.java
+++ b/java/net/URL.java
@@ -392,13 +392,14 @@ public final class URL implements Serializable
// right after the "://". The second colon is for an optional port value
// and implies that the host from the context is used if available.
int colon;
+ int slash = spec.indexOf('/');
if ((colon = spec.indexOf("://", 1)) > 0
+ && ((colon < slash || slash < 0))
&& ! spec.regionMatches(colon, "://:", 0, 4))
context = null;
- int slash;
if ((colon = spec.indexOf(':')) > 0
- && (colon < (slash = spec.indexOf('/')) || slash < 0))
+ && (colon < slash || slash < 0))
{
// Protocol specified in spec string.
protocol = spec.substring(0, colon).toLowerCase();
@@ -429,8 +430,6 @@ public final class URL implements Serializable
authority = context.authority;
}
else // Protocol NOT specified in spec. and no context available.
-
-
throw new MalformedURLException("Absolute URL required with null context");
protocol = protocol.trim();
@@ -901,6 +900,10 @@ public final class URL implements Serializable
Class c = Class.forName(clsName, true, systemClassLoader);
ph = (URLStreamHandler) c.newInstance();
}
+ catch (ThreadDeath death)
+ {
+ throw death;
+ }
catch (Throwable t) { /* ignored */ }
}
while (ph == null && pkgPrefix.hasMoreTokens());