You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Sergey Dmitriev (JIRA)" <ji...@apache.org> on 2007/08/30 19:32:31 UTC

[jira] Created: (HARMONY-4698) [classlib][nio] channels are not interruptible

[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 nothing.

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());
        predatorThread.start();

        ServerSocketChannel ssch = ServerSocketChannel.open();
        ServerSocket sSocket = ssch.socket();
        sSocket.bind(new InetSocketAddress(9999));
        System.out.println("accepting...");
        ssch.accept();
    }

    static class PredatorThread extends Thread {
        Thread victim;

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

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

[guy@computer:~] java  niointerrupt
accepting...
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
http://harmony.apache.org
accepting...
interrupting the Thread[main,5,main]...
^C

[guy@computer:~]


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


[jira] Commented: (HARMONY-4698) [classlib][nio] channels are not interruptible

Posted by "Paulex Yang (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4698?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12524427 ] 

Paulex Yang commented on HARMONY-4698:
--------------------------------------

Sergey,

Thank you for finding this. I suppose this is the DRLVM kernel class issue rather than classlib/nio? or you think there's something to be fixed in nio module? If you have no objects, I'd change the title prefix to [drlvm][kernel]. 

> [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 nothing.
> 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());
>         predatorThread.start();
>         ServerSocketChannel ssch = ServerSocketChannel.open();
>         ServerSocket sSocket = ssch.socket();
>         sSocket.bind(new InetSocketAddress(9999));
>         System.out.println("accepting...");
>         ssch.accept();
>     }
>     static class PredatorThread extends Thread {
>         Thread victim;
>         public PredatorThread(Thread victim) {
>             this.victim = victim;
>         }
>         public void run() {
>             try {
>                 Thread.sleep(3000);
>             } catch (InterruptedException e) {
>                 System.out.println(e);
>             }
>             System.out.println("interrupting the " + victim + "...");
>             victim.interrupt();
>         }
>     }
> }
> [guy@computer:~] java  niointerrupt
> accepting...
> 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
> http://harmony.apache.org
> accepting...
> interrupting the Thread[main,5,main]...
> ^C
> [guy@computer:~]

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


[jira] Commented: (HARMONY-4698) [classlib][nio] channels are not interruptible

Posted by "Sergey Dmitriev (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4698?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12524433 ] 

Sergey Dmitriev commented on HARMONY-4698:
------------------------------------------

Right, Paulex, please change the category.

> [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 nothing.
> 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());
>         predatorThread.start();
>         ServerSocketChannel ssch = ServerSocketChannel.open();
>         ServerSocket sSocket = ssch.socket();
>         sSocket.bind(new InetSocketAddress(9999));
>         System.out.println("accepting...");
>         ssch.accept();
>     }
>     static class PredatorThread extends Thread {
>         Thread victim;
>         public PredatorThread(Thread victim) {
>             this.victim = victim;
>         }
>         public void run() {
>             try {
>                 Thread.sleep(3000);
>             } catch (InterruptedException e) {
>                 System.out.println(e);
>             }
>             System.out.println("interrupting the " + victim + "...");
>             victim.interrupt();
>         }
>     }
> }
> [guy@computer:~] java  niointerrupt
> accepting...
> 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
> http://harmony.apache.org
> accepting...
> interrupting the Thread[main,5,main]...
> ^C
> [guy@computer:~]

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


[jira] Updated: (HARMONY-4698) [drlvm][kernel] channels are not interruptible

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4698?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tim Ellison updated HARMONY-4698:
---------------------------------

    Component/s:     (was: Classlib)
                 DRLVM
        Summary: [drlvm][kernel] channels are not interruptible  (was: [classlib][nio] channels are not interruptible)

Helping out with reclassification.

> [drlvm][kernel] channels are not interruptible
> ----------------------------------------------
>
>                 Key: HARMONY-4698
>                 URL: https://issues.apache.org/jira/browse/HARMONY-4698
>             Project: Harmony
>          Issue Type: Bug
>          Components: DRLVM
>            Reporter: Sergey Dmitriev
>
> Currently nio.channels are not interruptible.
> Methods begin() and end() from java.nio.channels.spi.AbstractInterruptibleChannel class do nothing.
> 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());
>         predatorThread.start();
>         ServerSocketChannel ssch = ServerSocketChannel.open();
>         ServerSocket sSocket = ssch.socket();
>         sSocket.bind(new InetSocketAddress(9999));
>         System.out.println("accepting...");
>         ssch.accept();
>     }
>     static class PredatorThread extends Thread {
>         Thread victim;
>         public PredatorThread(Thread victim) {
>             this.victim = victim;
>         }
>         public void run() {
>             try {
>                 Thread.sleep(3000);
>             } catch (InterruptedException e) {
>                 System.out.println(e);
>             }
>             System.out.println("interrupting the " + victim + "...");
>             victim.interrupt();
>         }
>     }
> }
> [guy@computer:~] java  niointerrupt
> accepting...
> 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
> http://harmony.apache.org
> accepting...
> interrupting the Thread[main,5,main]...
> ^C
> [guy@computer:~]

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