A small thinko in this one. The SelectorProvider.inheritedChannel() has
to be concrete with a default impl of null (I suppose). I also added the
required security checks.
2007-04-04 Roman Kennke <[EMAIL PROTECTED]>
* java/nio/channels/spi/SelectorProvider.java
(inheritedChannel): Make method concrete and move default impl
to here. Perform security checks as mandated by the spec.
* gnu/java/nio/SelectorProviderImpl.java
(inheritedChannel): Removed. Default impl is in SelectorProvider.
/Roman
--
aicas Allerton Interworks Computer Automated Systems GmbH
Haid-und-Neu-Straße 18 * D-76131 Karlsruhe * Germany
http://www.aicas.com * Tel: +49-721-663 968-0
USt-Id: DE216375633, Handelsregister HRB 109481, AG Karlsruhe
Geschäftsführer: Dr. James J. Hunt
Index: java/nio/channels/spi/SelectorProvider.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/nio/channels/spi/SelectorProvider.java,v
retrieving revision 1.12
diff -u -1 -5 -r1.12 SelectorProvider.java
--- java/nio/channels/spi/SelectorProvider.java 3 Apr 2007 21:27:14 -0000 1.12
+++ java/nio/channels/spi/SelectorProvider.java 4 Apr 2007 11:37:31 -0000
@@ -114,31 +114,44 @@
* @exception IOException if an error occurs
*/
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;
+ public Channel inheritedChannel()
+ throws IOException
+ {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ {
+ sm.checkPermission(new RuntimePermission("inheritedChannel"));
+ }
+ // 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;
+ }
/**
* Returns the system-wide default selector provider for this invocation
* of the Java virtual machine.
*
* @return the default seletor provider
*/
public static synchronized SelectorProvider provider()
{
if (systemDefaultProvider == null)
{
String propertyValue =
System.getProperty("java.nio.channels.spi.SelectorProvider");
if (propertyValue == null || propertyValue.equals(""))
Index: gnu/java/nio/SelectorProviderImpl.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/nio/SelectorProviderImpl.java,v
retrieving revision 1.11
diff -u -1 -5 -r1.11 SelectorProviderImpl.java
--- gnu/java/nio/SelectorProviderImpl.java 3 Apr 2007 21:27:14 -0000 1.11
+++ gnu/java/nio/SelectorProviderImpl.java 4 Apr 2007 11:37:31 -0000
@@ -29,31 +29,30 @@
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
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;
import java.nio.channels.SocketChannel;
import java.nio.channels.spi.AbstractSelector;
import java.nio.channels.spi.SelectorProvider;
public class SelectorProviderImpl extends SelectorProvider
{
private static final String SELECTOR_IMPL_KQUEUE = "kqueue";
private static final String SELECTOR_IMPL_EPOLL = "epoll";
private static final String SELECTOR_IMPL = "gnu.java.nio.selectorImpl";
private static boolean epoll_failed = false;
public SelectorProviderImpl ()
@@ -107,24 +106,16 @@
return new SelectorImpl (this);
}
public ServerSocketChannel openServerSocketChannel ()
throws IOException
{
return new ServerSocketChannelImpl (this);
}
public SocketChannel openSocketChannel ()
throws IOException
{
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;
- }
}