aboutsummaryrefslogtreecommitdiff
path: root/libjava/java
diff options
context:
space:
mode:
authorMichael Koch <konqueror@gmx.de>2002-10-03 17:17:39 +0000
committerMichael Koch <mkoch@gcc.gnu.org>2002-10-03 17:17:39 +0000
commit8e3cce32349c578ffd02306f3f16e0c78ba161d3 (patch)
treec0d1c4c8a1b42f1f8f57815e6d86959c5be2b5f2 /libjava/java
parentbfc1eae300993c406f0a0cb67c10b22c06a7c993 (diff)
downloadgcc-8e3cce32349c578ffd02306f3f16e0c78ba161d3.zip
gcc-8e3cce32349c578ffd02306f3f16e0c78ba161d3.tar.gz
gcc-8e3cce32349c578ffd02306f3f16e0c78ba161d3.tar.bz2
InetAddress.java (class InetAddress): Removed final keyword.
2002-10-03 Michael Koch <konqueror@gmx.de> * java/net/InetAddress.java (class InetAddress): Removed final keyword. (equals): Fixed typo. (getByAddress): New method. From-SVN: r57779
Diffstat (limited to 'libjava/java')
-rw-r--r--libjava/java/net/InetAddress.java26
1 files changed, 24 insertions, 2 deletions
diff --git a/libjava/java/net/InetAddress.java b/libjava/java/net/InetAddress.java
index 49bc310..91e3490 100644
--- a/libjava/java/net/InetAddress.java
+++ b/libjava/java/net/InetAddress.java
@@ -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 implements java.io.Serializable
// 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;
@@ -206,7 +208,27 @@ public final class InetAddress implements java.io.Serializable
{
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);