Bug 32861 - SelectableChannel.configureBlocking fails to throw IllegalBlockingModeException
Summary: SelectableChannel.configureBlocking fails to throw IllegalBlockingModeException
Status: UNCONFIRMED
Alias: None
Product: classpath
Classification: Unclassified
Component: classpath (show other bugs)
Version: 0.95
: P3 normal
Target Milestone: ---
Assignee: Mark Wielaard
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-07-23 07:22 UTC by Debian GCC Maintainers
Modified: 2007-07-23 08:07 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Debian GCC Maintainers 2007-07-23 07:22:54 UTC
[forwarded from http://bugs.debian.org/415109]

seen with GCC trunk, 20070730 (cp-0.95):

The java API for SelectableChannel requires that attempts to toggle
blocking mode with configureBlocking fail when a channel is registered.

This test program demonstrates that gcj fails to throw the expected
exception...

===
# first use sun jvm
msimons@blitz:~/java/listen$ ~/java/jdk1.5.0_10/bin/java test2
java.nio.channels.IllegalBlockingModeException
        at java.nio.channels.spi.AbstractSelectableChannel.configureBlocking(AbstractSelectableChannel.java:257)
        at test2.main(test2.java:19)
# now gcj
msimons@blitz:~/java/listen$ java test2
msimons@blitz:~/java/listen$ reportbug -o blocking.bug `which java`
===


http://java.sun.com/j2se/1.4.2/docs/api/java/nio/channels/SelectableChannel.html
===
Blocking mode

A selectable channel is either in blocking mode or in non-blocking
mode. In blocking mode, every I/O operation invoked upon the channel
will block until it completes. In non-blocking mode an I/O operation
will never block and may transfer fewer bytes than were requested or
possibly no bytes at all. The blocking mode of a selectable channel may
be determined by invoking its isBlocking method.

Newly-created selectable channels are always in blocking
mode. Non-blocking mode is most useful in conjunction with selector-based
multiplexing. A channel must be placed into non-blocking mode before
being registered with a selector, and may not be returned to blocking
mode until it has been deregistered.
===

sample code:
===
import java.net.InetSocketAddress;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.spi.SelectorProvider;

public class test2 {
  public static void main(String[] args) {
    try {
      Selector sel = null;
      InetSocketAddress isa = new InetSocketAddress(2300);
      ServerSocketChannel ssc = ServerSocketChannel.open();

      ssc.configureBlocking(false);
      ssc.socket().bind(isa);

      sel = SelectorProvider.provider().openSelector();
      ssc.register(sel, SelectionKey.OP_ACCEPT);
      ssc.configureBlocking(true);
    } catch(Exception e) {
      e.printStackTrace();            
    }
  }
}
===
Comment 1 chris burdess 2007-07-23 08:07:55 UTC
Hi Mark,

this shouldn't be in the inetlib component, please reassign to whoever is dealing with NIO.