[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug classpath/23733] "SelectorImpl" throws a null pointer exception
From: |
subramanian dot vaitheeswaran at applabs dot com |
Subject: |
[Bug classpath/23733] "SelectorImpl" throws a null pointer exception |
Date: |
13 Oct 2005 10:42:22 -0000 |
------- Comment #7 from subramanian dot vaitheeswaran at applabs dot com
2005-10-13 10:42 -------
Hi All,
I believe, the main issue with gnu.classpath implementation of Selector class
is- if the selector is not registered with any socket channels and select() is
invoked on it we get an null pointer exception.
Simple Java.nio.selector TestCase which passes on Java and fails on .net
environments. NOTE:- IKVMC is used to generate .dll from jar.
---------------------Java Code -------------------------------------
package selectortest;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
/*
* Test1
*/
public class Test1 {
Selector selector;
public Test1() {
try {
selector = Selector.open();
/* Uncomment below code, for successfully execution of test case on both the
environments*/
// ServerSocketChannel serverSocketChannel =
ServerSocketChannel
// .open();
// serverSocketChannel.socket().bind(
// new InetSocketAddress("ravishankar", 7121));
// serverSocketChannel.configureBlocking(false);
// serverSocketChannel.register(selector,
SelectionKey.OP_ACCEPT);
// serverSocketChannel.accept();
} catch (IOException e) {
e.printStackTrace();
}
new tempThread().start();
}
class tempThread extends Thread {
public void run() {
try {
System.out.println("Before calling select");
selector.select();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
new Test1();
}
}
Note :- In the above test code, an selector is opened and select() is called
on it with out registering any server/client socket channels.
Java Ouput :- The tempThread blocks on calling select() method.
Before calling select
.Net output :-
Before calling select
Exception in thread "Thread-1" java.lang.NullPointerException
at cli.System.Net.Sockets.Socket.Select (Unknown Source)
at gnu.java.nio.SelectorImpl.select (SelectorImpl.java:212)
at gnu.java.nio.SelectorImpl.select (SelectorImpl.java:128)
at selectortest.Test1$tempThread.run (Test1.java:38)
at java.lang.VMThread.run (VMThread.java:42)
at java.lang.VMThread.access$2 (VMThread.java:26)
at java.lang.VMThread$1.Invoke (VMThread.java:296)
at cli.System.Threading.ThreadHelper.ThreadStart_Context (Unknown
Source)
at cli.System.Threading.ExecutionContext.Run (Unknown Source)
at cli.System.Threading.ThreadHelper.ThreadStart (Unknown Source)
regards
Subrmanian
--
subramanian dot vaitheeswaran at applabs dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |subramanian dot
| |vaitheeswaran at applabs dot
| |com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23733
- [Bug classpath/23733] "SelectorImpl" throws a null pointer exception,
subramanian dot vaitheeswaran at applabs dot com <=