Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/ikvm-fork.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsmallsql <smallsql>2011-07-09 13:41:39 +0400
committersmallsql <smallsql>2011-07-09 13:41:39 +0400
commit957a60ebd7f947076c610925a0161e89d5b81bbe (patch)
tree1934818da934a3d33bae28efa4b1ce48f203ab49 /openjdk/sun/nio/ch/Net.java
parentf17485a1081248cd8b06374ced05edd0752e869a (diff)
Add some stup methods to sun.nio.ch.Net with a NotYetImplementedError to compile the Java 7 sources.
Diffstat (limited to 'openjdk/sun/nio/ch/Net.java')
-rw-r--r--openjdk/sun/nio/ch/Net.java112
1 files changed, 112 insertions, 0 deletions
diff --git a/openjdk/sun/nio/ch/Net.java b/openjdk/sun/nio/ch/Net.java
index 087a35cb..a6b1bf9e 100644
--- a/openjdk/sun/nio/ch/Net.java
+++ b/openjdk/sun/nio/ch/Net.java
@@ -36,6 +36,7 @@ import cli.System.Net.Sockets.SocketType;
import cli.System.Net.Sockets.ProtocolType;
import cli.System.Net.Sockets.AddressFamily;
import cli.System.Net.Sockets.SocketShutdown;
+import ikvm.internal.NotYetImplementedError;
import ikvm.lang.CIL;
import java.io.*;
import java.lang.reflect.*;
@@ -48,6 +49,13 @@ class Net { // package-private
private Net() { }
+ // unspecified protocol family
+ static final ProtocolFamily UNSPEC = new ProtocolFamily() {
+ public String name() {
+ return "UNSPEC";
+ }
+ };
+
static FileDescriptor serverSocket(boolean stream) throws IOException
{
return socket(stream);
@@ -491,4 +499,108 @@ class Net { // package-private
{
translateException(x, false);
}
+
+ static void setSocketOption(FileDescriptor fd, ProtocolFamily family,
+ SocketOption<?> name, Object value)
+ throws IOException
+ {
+ if (value == null)
+ throw new IllegalArgumentException("Invalid option value");
+
+ // only simple values supported by this method
+ Class<?> type = name.type();
+ if (type != Integer.class && type != Boolean.class)
+ throw new AssertionError("Should not reach here");
+
+ // special handling
+ if (name == StandardSocketOptions.SO_RCVBUF ||
+ name == StandardSocketOptions.SO_SNDBUF)
+ {
+ int i = ((Integer)value).intValue();
+ if (i < 0)
+ throw new IllegalArgumentException("Invalid send/receive buffer size");
+ }
+ if (name == StandardSocketOptions.SO_LINGER) {
+ int i = ((Integer)value).intValue();
+ if (i < 0)
+ value = Integer.valueOf(-1);
+ if (i > 65535)
+ value = Integer.valueOf(65535);
+ }
+ if (name == StandardSocketOptions.IP_TOS) {
+ int i = ((Integer)value).intValue();
+ if (i < 0 || i > 255)
+ throw new IllegalArgumentException("Invalid IP_TOS value");
+ }
+ if (name == StandardSocketOptions.IP_MULTICAST_TTL) {
+ int i = ((Integer)value).intValue();
+ if (i < 0 || i > 255)
+ throw new IllegalArgumentException("Invalid TTL/hop value");
+ }
+
+ // map option name to platform level/name
+ OptionKey key = SocketOptionRegistry.findOption(name, family);
+ if (key == null)
+ throw new AssertionError("Option not found");
+
+ int arg;
+ if (type == Integer.class) {
+ arg = ((Integer)value).intValue();
+ } else {
+ boolean b = ((Boolean)value).booleanValue();
+ arg = (b) ? 1 : 0;
+ }
+
+ boolean mayNeedConversion = (family == UNSPEC);
+ setIntOption0(fd, mayNeedConversion, key.level(), key.name(), arg);
+ }
+
+ static Object getSocketOption(FileDescriptor fd, ProtocolFamily family,
+ SocketOption<?> name)
+ throws IOException
+ {
+ Class<?> type = name.type();
+
+ // only simple values supported by this method
+ if (type != Integer.class && type != Boolean.class)
+ throw new AssertionError("Should not reach here");
+
+ // map option name to platform level/name
+ OptionKey key = SocketOptionRegistry.findOption(name, family);
+ if (key == null)
+ throw new AssertionError("Option not found");
+
+ boolean mayNeedConversion = (family == UNSPEC);
+ int value = getIntOption0(fd, mayNeedConversion, key.level(), key.name());
+
+ if (type == Integer.class) {
+ return Integer.valueOf(value);
+ } else {
+ return (value == 0) ? Boolean.FALSE : Boolean.TRUE;
+ }
+ }
+
+
+ public final static int SHUT_RD = 0;
+ public final static int SHUT_WR = 1;
+ public final static int SHUT_RDWR = 2;
+
+ static /*native*/ void shutdown(FileDescriptor fd, int how) throws IOException
+ {
+ throw new NotYetImplementedError(); //TODO JDK7
+ }
+
+ private static /*native*/ int getIntOption0(FileDescriptor fd, boolean mayNeedConversion,
+ int level, int opt)
+ throws IOException
+ {
+ throw new NotYetImplementedError(); //TODO JDK7
+ }
+
+ private static /*native*/ void setIntOption0(FileDescriptor fd, boolean mayNeedConversion,
+ int level, int opt, int arg)
+ {
+ throw new NotYetImplementedError(); //TODO JDK7
+ }
+
}