summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Kennke <roman@kennke.org>2007-04-03 21:27:14 +0000
committerRoman Kennke <roman@kennke.org>2007-04-03 21:27:14 +0000
commit0d4b4a31da5cf9cb6791dfc2fd836d97e7851888 (patch)
treeefb8f674b28fae10122e851fea792a4aa875e983
parent0198fbda626fcb4dbe64299c4c15901088be6f53 (diff)
downloadclasspath-0d4b4a31da5cf9cb6791dfc2fd836d97e7851888.tar.gz
2007-04-03 Roman Kennke <roman@kennke.org>
* java/lang/System.java (inheritedChannel): New method, wraps SelectorProvider.inheritedChannel(). * java/nio/channels/spi/SelectorProvider.java (inheritedChannel): New abstract method. * gnu/java/nio/SelectorProviderImpl.java (inheritedChannel): New method, return null as default.
-rw-r--r--ChangeLog10
-rw-r--r--gnu/java/nio/SelectorProviderImpl.java10
-rw-r--r--java/lang/System.java22
-rw-r--r--java/nio/channels/spi/SelectorProvider.java14
4 files changed, 56 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index a4dce4384..8f47fe256 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
2007-04-03 Roman Kennke <roman@kennke.org>
+ * java/lang/System.java
+ (inheritedChannel): New method, wraps
+ SelectorProvider.inheritedChannel().
+ * java/nio/channels/spi/SelectorProvider.java
+ (inheritedChannel): New abstract method.
+ * gnu/java/nio/SelectorProviderImpl.java
+ (inheritedChannel): New method, return null as default.
+
+2007-04-03 Roman Kennke <roman@kennke.org>
+
* java/nio/ByteOrder.java
(nativeByteOrder): Let this fail when the corresponding
property is not set properly.
diff --git a/gnu/java/nio/SelectorProviderImpl.java b/gnu/java/nio/SelectorProviderImpl.java
index 56167b69e..d50d0ee61 100644
--- a/gnu/java/nio/SelectorProviderImpl.java
+++ b/gnu/java/nio/SelectorProviderImpl.java
@@ -41,6 +41,7 @@ package gnu.java.nio;
import gnu.classpath.SystemProperties;
import java.io.IOException;
+import java.nio.channels.Channel;
import java.nio.channels.DatagramChannel;
import java.nio.channels.Pipe;
import java.nio.channels.ServerSocketChannel;
@@ -117,4 +118,13 @@ public class SelectorProviderImpl extends SelectorProvider
{
return new SocketChannelImpl (this);
}
+
+ public Channel inheritedChannel() throws IOException
+ {
+ // Implementation note: The default implementation can't do much more
+ // than return null. If a VM can provide something more useful it should
+ // install its own SelectorProvider (maybe a subclass of this one) to
+ // return something more useful.
+ return null;
+ }
}
diff --git a/java/lang/System.java b/java/lang/System.java
index 9ca93fb1d..68d76fc21 100644
--- a/java/lang/System.java
+++ b/java/lang/System.java
@@ -42,8 +42,11 @@ package java.lang;
import gnu.classpath.SystemProperties;
import gnu.classpath.VMStackWalker;
+import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
+import java.nio.channels.Channel;
+import java.nio.channels.spi.SelectorProvider;
import java.util.AbstractCollection;
import java.util.Collection;
import java.util.Collections;
@@ -672,6 +675,25 @@ public final class System
return VMRuntime.mapLibraryName(libname);
}
+ /**
+ * Returns the inherited channel of the VM.
+ *
+ * This wraps the inheritedChannel() call of the system's default
+ * {@link SelectorProvider}.
+ *
+ * @return the inherited channel of the VM
+ *
+ * @throws IOException If an I/O error occurs
+ * @throws SecurityException If an installed security manager denies access
+ * to RuntimePermission("inheritedChannel")
+ *
+ * @since 1.5
+ */
+ public static Channel inheritedChannel()
+ throws IOException
+ {
+ return SelectorProvider.provider().inheritedChannel();
+ }
/**
* This is a specialised <code>Collection</code>, providing
diff --git a/java/nio/channels/spi/SelectorProvider.java b/java/nio/channels/spi/SelectorProvider.java
index db4e65fe1..bae006492 100644
--- a/java/nio/channels/spi/SelectorProvider.java
+++ b/java/nio/channels/spi/SelectorProvider.java
@@ -40,6 +40,7 @@ package java.nio.channels.spi;
import gnu.java.nio.SelectorProviderImpl;
import java.io.IOException;
+import java.nio.channels.Channel;
import java.nio.channels.DatagramChannel;
import java.nio.channels.Pipe;
import java.nio.channels.ServerSocketChannel;
@@ -115,6 +116,19 @@ public abstract class SelectorProvider
public abstract SocketChannel openSocketChannel() throws IOException;
/**
+ * Returns the inherited channel of the VM.
+ *
+ * @return the inherited channel of the VM
+ *
+ * @throws IOException If an I/O error occurs
+ * @throws SecurityException If an installed security manager denies access
+ * to RuntimePermission("inheritedChannel")
+ *
+ * @since 1.5
+ */
+ public abstract Channel inheritedChannel() throws IOException;
+
+ /**
* Returns the system-wide default selector provider for this invocation
* of the Java virtual machine.
*