This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: java.net
Am Donnerstag, 3. Oktober 2002 17:59 schrieb Tom Tromey:
> Michael> I've commited the attached patch.
>
> I now get a build failure:
>
> ./../../gcc/libjava/java/net/InetSocketAddress.java: In class
> `java.net.InetSocketAddress':
> ./../../gcc/libjava/java/net/InetSocketAddress.java: In constructor
> `(int)': ./../../gcc/libjava/java/net/InetSocketAddress.java:91:
> error: Can't find method `getByAddress([B)' in type
> `java.net.InetAddress'. this.addr = InetAddress.getByAddress (any);
> ^
> 1 error
>
> Sure enough, that method doesn't exist.
> I'm guessing you forgot to commit part of the patch.
Thanx for reporting. I commited the attached fix.
Michael
--
Homepage: http://www.worldforge.org/
GPG-key: http://konqueror.dyndns.org/~mkoch/michael.gpg
cvs -f log -N -r1.8 java/net/InetAddress.java
RCS file: /cvs/gcc/gcc/libjava/java/net/InetAddress.java,v
Working file: java/net/InetAddress.java
head: 1.8
branch:
locks: strict
access list:
keyword substitution: kv
total revisions: 14; selected revisions: 1
description:
----------------------------
revision 1.8
date: 2002/10/03 17:17:39; author: mkoch; state: Exp; lines: +24 -2
2002-10-03 Michael Koch <konqueror@gmx.de>
* java/net/InetAddress.java
(class InetAddress): Removed final keyword.
(equals): Fixed typo.
(getByAddress): New method.
=============================================================================
cvs -f diff -bp -u -r1.7 -r1.8 java/net/InetAddress.java
Index: java/net/InetAddress.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/InetAddress.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -b -p -u -r1.7 -r1.8
--- java/net/InetAddress.java 12 Jan 2002 10:11:13 -0000 1.7
+++ java/net/InetAddress.java 3 Oct 2002 17:17:39 -0000 1.8
@@ -23,9 +23,11 @@ import java.io.IOException;
* as "The Java Class Libraries", 2nd edition (Addison-Wesley, 1998).
* (The latter turns out to have some errors ...)
* Status: Believed complete and correct.
+ *
+ * @specnote This class is not final since JK 1.4
*/
-public final class InetAddress implements java.io.Serializable
+public class InetAddress implements java.io.Serializable
{
// The Serialized Form specifies that an int 'address' is saved/restored.
// This class uses a byte array internally so we'll just do the conversion
@@ -190,7 +192,7 @@ public final class InetAddress implement
// multiple names instances of InetAddress for different name of
// that same machine are not equal. This is because they have
// different host names." This violates the description in the
- // JDK 1.2 API documentation. A little experiementation
+ // JDK 1.2 API documentation. A little experimentation
// shows that the latter is correct.
byte[] addr1 = addr;
byte[] addr2 = ((InetAddress) obj).addr;
@@ -207,6 +209,26 @@ public final class InetAddress implement
return getHostName()+'/'+getHostAddress();
}
+ /**
+ * Returns an InetAddress object given the raw IP address.
+ *
+ * The argument is in network byte order: the highest order byte of the
+ * address is in getAddress()[0].
+ *
+ * @exception UnknownHostException If no IP address for the host could
+ * be found
+ *
+ * @since 1.4
+ */
+ public static InetAddress getByAddress(byte[] addr)
+ throws UnknownHostException
+ {
+ if (addr.length != 4 && addr.length != 16)
+ throw new UnknownHostException ("IP address has illegal length");
+
+ return new InetAddress (addr, "");
+ }
+
/** If host is a valid numeric IP address, return the numeric address.
* Otherwise, return null. */
private static native byte[] aton (String host);