harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Dmitriev (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-4698) [classlib][nio] channels are not interruptible
Date Thu, 30 Aug 2007 17:32:31 GMT
[classlib][nio] channels are not interruptible

                 Key: HARMONY-4698
                 URL: https://issues.apache.org/jira/browse/HARMONY-4698
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Sergey Dmitriev

Currently nio.channels are not interruptible.

Methods begin() and end() from java.nio.channels.spi.AbstractInterruptibleChannel class do

The idea was to set special "interrupt action" in the begin() before the blocking operation
(as spec says). And in case of interruption this action supposed to get called and this action
in turn supposed to wake up the blocked operation. That was implemented via java.lang.Thread.setInterruptAction(Runnable).
But at some point the DRLVM's kernel classes have been changed significantly and that machinery
has been erased. The classlib compilation goes just fine because the classlib's kernel classes'
stubs contain the corresponding method stubs. As for the runtime: classlib ignored the errors
at startup (getting via reflection of java.lang.Thread.setInterruptAction(Runnable) method)
and runs smoothly without such a feature as 'interruptible channels".

You can take a look at HARMONY-635 as well.

Here is a small demo:

[guy@computer:~] cat niointerrupt.java
import java.net.*;
import java.nio.*;
import java.nio.channels.*;

public class niointerrupt {
    public static void main(String args[]) throws Exception {
        PredatorThread predatorThread = new PredatorThread(Thread.currentThread());

        ServerSocketChannel ssch = ServerSocketChannel.open();
        ServerSocket sSocket = ssch.socket();
        sSocket.bind(new InetSocketAddress(9999));

    static class PredatorThread extends Thread {
        Thread victim;

        public PredatorThread(Thread victim) {
            this.victim = victim;

        public void run() {
            try {
            } catch (InterruptedException e) {
            System.out.println("interrupting the " + victim + "...");

[guy@computer:~] java  niointerrupt
interrupting the Thread[Main Thread,5,main]...
Exception in thread "Main Thread" java.nio.channels.ClosedByInterruptException
        at java.nio.channels.spi.AbstractInterruptibleChannel.end(AbstractInterruptibleChannel.java:184)
        at sun.nio.ch.ServerSocketChannelImpl.accept(ServerSocketChannelImpl.java:152)
        at niointerrupt.main(niointerrupt.java:14)

[guy@computer:~] ~/jre/bin/java -showversion niointerrupt
Apache Harmony Launcher : (c) Copyright 1991, 2006 The Apache Software Foundation or its licensors,
as applicable.
java version "1.5.0"
pre-alpha : not complete or compatible
svn = r570813, (Aug 30 2007), Linux/ia32/gcc 3.3.3, release build
interrupting the Thread[main,5,main]...


This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message