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] Commented: (HARMONY-4698) [classlib][nio] channels are not interruptible
Date Mon, 03 Sep 2007 05:23:19 GMT

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


Mime
View raw message