Commit e1caed89 by Michael Koch Committed by Michael Koch

2002-10-11 Michael Koch <konqueror@gmx.de>

	* java/net/URL.java
	(URL): Activate SecurityManager checks.
	(equals): Use URLStreamHandler implementation instead of doing it
	alone. This allows special protocol stream handlers to change default
	behaviour.
	(hashCode): Use URLStreamHandler implementation instead of doing it
	alone. This allows special protocol stream handlers to change default
	behaviour.
	* java/net/URLStreamHandler.java
	(equals): Implemented default URL equality check.
	(hostsEqual): Implemented default URL equality check.
	(hashCode): Implemented default URL hashCode algorithm.
	* java/net/natPlainDatagramSocketImpl.cc:
	No lines longer then 80 characters.

From-SVN: r58345
parent e2a450f6
2002-10-11 Michael Koch <konqueror@gmx.de>
* java/net/URL.java
(URL): Activate SecurityManager checks.
(equals): Use URLStreamHandler implementation instead of doing it
alone. This allows special protocol stream handlers to change default
behaviour.
(hashCode): Use URLStreamHandler implementation instead of doing it
alone. This allows special protocol stream handlers to change default
behaviour.
* java/net/URLStreamHandler.java
(equals): Implemented default URL equality check.
(hostsEqual): Implemented default URL equality check.
(hashCode): Implemented default URL hashCode algorithm.
* java/net/natPlainDatagramSocketImpl.cc:
No lines longer then 80 characters.
2002-10-20 Adam Megacz <adam@xwt.org> 2002-10-20 Adam Megacz <adam@xwt.org>
* aclocal.m4 (CHECK_FOR_BROKEN_MINGW_LD): added * aclocal.m4 (CHECK_FOR_BROKEN_MINGW_LD): added
......
...@@ -98,14 +98,9 @@ public final class URL implements Serializable ...@@ -98,14 +98,9 @@ public final class URL implements Serializable
if (handler != null) if (handler != null)
{ {
// TODO12: Need SecurityManager.checkPermission and SecurityManager s = System.getSecurityManager ();
// TODO12: java.net.NetPermission from JDK 1.2 to be implemented. if (s != null)
// Throw an exception if an extant security mgr precludes s.checkPermission (new NetPermission ("specifyStreamHandler"));
// specifying a StreamHandler.
//
// SecurityManager s = System.getSecurityManager();
// if (s != null)
// s.checkPermission(NetPermission("specifyStreamHandler"));
this.handler = handler; this.handler = handler;
} }
...@@ -234,14 +229,9 @@ public final class URL implements Serializable ...@@ -234,14 +229,9 @@ public final class URL implements Serializable
if (handler != null) if (handler != null)
{ {
// TODO12: Need SecurityManager.checkPermission and SecurityManager s = System.getSecurityManager ();
// TODO12: java.net.NetPermission from JDK 1.2 to be implemented. if (s != null)
// Throw an exception if an extant security mgr precludes s.checkPermission (new NetPermission ("specifyStreamHandler"));
// specifying a StreamHandler.
//
// SecurityManager s = System.getSecurityManager();
// if (s != null)
// s.checkPermission(NetPermission("specifyStreamHandler"));
this.handler = handler; this.handler = handler;
} }
...@@ -270,24 +260,8 @@ public final class URL implements Serializable ...@@ -270,24 +260,8 @@ public final class URL implements Serializable
return false; return false;
URL uObj = (URL) obj; URL uObj = (URL) obj;
// This comparison is very conservative. It assumes that any return handler.equals (this, uObj);
// field can be null.
return (port == uObj.port
&& ((protocol == null && uObj.protocol == null)
|| (protocol != null && protocol.equals(uObj.protocol)))
&& ((userInfo == null && uObj.userInfo == null)
|| (userInfo != null && userInfo.equals(uObj.userInfo)))
&& ((authority == null && uObj.authority == null)
|| (authority != null && authority.equals(uObj.authority)))
&& ((host == null && uObj.host == null)
|| (host != null && host.equals(uObj.host)))
&& ((file == null && uObj.file == null)
|| (file != null && file.equals(uObj.file)))
&& ((query == null && uObj.query == null)
|| (query != null && query.equals(uObj.query)))
&& ((ref == null && uObj.ref == null)
|| (ref != null && ref.equals(uObj.ref))));
} }
/** /**
...@@ -412,8 +386,7 @@ public final class URL implements Serializable ...@@ -412,8 +386,7 @@ public final class URL implements Serializable
if (hashCode != 0) if (hashCode != 0)
return hashCode; // Use cached value if available. return hashCode; // Use cached value if available.
else else
return (protocol.hashCode() + ((host == null) ? 0 : host.hashCode()) + return handler.hashCode (this);
port + file.hashCode());
} }
/** /**
......
...@@ -234,8 +234,30 @@ public abstract class URLStreamHandler ...@@ -234,8 +234,30 @@ public abstract class URLStreamHandler
*/ */
protected boolean equals (URL url1, URL url2) protected boolean equals (URL url1, URL url2)
{ {
// FIXME: implement this // This comparison is very conservative. It assumes that any
return false; // field can be null.
return (url1.getPort () == url2.getPort ()
&& ((url1.getProtocol () == null && url2.getProtocol () == null)
|| (url1.getProtocol () != null
&& url1.getProtocol ().equals (url2.getProtocol ())))
&& ((url1.getUserInfo () == null && url2.getUserInfo () == null)
|| (url1.getUserInfo () != null
&& url1.getUserInfo ().equals(url2.getUserInfo ())))
&& ((url1.getAuthority () == null && url2.getAuthority () == null)
|| (url1.getAuthority () != null
&& url1.getAuthority ().equals(url2.getAuthority ())))
&& ((url1.getHost () == null && url2.getHost () == null)
|| (url1.getHost () != null
&& url1.getHost ().equals(url2.getHost ())))
&& ((url1.getPath () == null && url2.getPath () == null)
|| (url1.getPath () != null
&& url1.getPath ().equals (url2.getPath ())))
&& ((url1.getQuery () == null && url2.getQuery () == null)
|| (url1.getQuery () != null
&& url1.getQuery ().equals(url2.getQuery ())))
&& ((url1.getRef () == null && url2.getRef () == null)
|| (url1.getRef () != null
&& url1.getRef ().equals(url2.getRef ()))));
} }
/** /**
...@@ -244,9 +266,12 @@ public abstract class URLStreamHandler ...@@ -244,9 +266,12 @@ public abstract class URLStreamHandler
* @exception UnknownHostException If an unknown host is found * @exception UnknownHostException If an unknown host is found
*/ */
protected boolean hostsEqual (URL url1, URL url2) protected boolean hostsEqual (URL url1, URL url2)
throws UnknownHostException
{ {
// FIXME: implement this InetAddress addr1 = InetAddress.getByName (url1.getHost ());
return false; InetAddress addr2 = InetAddress.getByName (url2.getHost ());
return addr1.equals (addr2);
} }
/** /**
...@@ -285,8 +310,10 @@ public abstract class URLStreamHandler ...@@ -285,8 +310,10 @@ public abstract class URLStreamHandler
*/ */
protected int hashCode (URL url) protected int hashCode (URL url)
{ {
// FIXME: implement this return url.getProtocol ().hashCode () +
return 0; ((url.getHost () == null) ? 0 : url.getHost ().hashCode ()) +
url.getFile ().hashCode() +
url.getPort ();
} }
/** /**
......
...@@ -280,18 +280,17 @@ java::net::PlainDatagramSocketImpl::bind (jint lport, ...@@ -280,18 +280,17 @@ java::net::PlainDatagramSocketImpl::bind (jint lport,
} }
void void
java::net::PlainDatagramSocketImpl::connect (java::net::InetAddress *addr, java::net::PlainDatagramSocketImpl::connect (java::net::InetAddress *, jint)
jint port)
{ {
throw new ::java::lang::InternalError ( throw new ::java::lang::InternalError (JvNewStringLatin1 (
JvNewStringLatin1 ("PlainDatagramSocketImpl::connect: not implemented yet")); "PlainDatagramSocketImpl::connect: not implemented yet"));
} }
void void
java::net::PlainDatagramSocketImpl::disconnect () java::net::PlainDatagramSocketImpl::disconnect ()
{ {
throw new ::java::lang::InternalError ( throw new ::java::lang::InternalError (JvNewStringLatin1 (
JvNewStringLatin1 ("PlainDatagramSocketImpl::disconnect: not implemented yet")); "PlainDatagramSocketImpl::disconnect: not implemented yet"));
} }
jint jint
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment