This note describes a bug in Java 1.1 that causes channel access
to not work properly with Java on Solaris.
Channel access (CA) can be invoked as a native method in Java.
While this makes the code platform dependent and not "100% Java", it
is the only way to use EPICS with Java until someone writes a Java
version of CA.
However, there is a bug, at least through JDK 1.1.5, that
prevents CA from working when using the default (green_threads)
implementation of Java on Solaris.
The problem is caused by an improper implementation of the recv()
call. This is the function that reads a socket. By default, if there
is nothing to read on the socket, recv() waits until there is,
blocking the program. TCP sockets in CA are set to be non-blocking,
in which case recv() returns with a status indicating that it "would
block". CA typically reads the socket until it gets the "would block"
status and then goes on about its business. The problem is that in
Java recv() blocks all the time. This means that CA hangs as soon as
it has finished reading the first message. It takes a certain amount
of programming time to determine that this is what is happening, as
well. (Java is hard to debug with native methods since the program
that is running is java, not your own application. Java, of course,
is not built with debugging information.) Hopefully, this note may
help others avoid spending this time.
The bug has been reported to Java but they do not respond to bug
reports, at least from ordinary people. They just fix them as they
see fit. Since they market the "100% Java" concept, one can assume
this particular, operating-system-dependent bug will not be a high
priority.
The bug does not appear if one uses native_threads instead of
green_threads. Neither is well documented, the documentation
apparently appearing in the .javawrapper shell script in the java
installation directory.
My experience is that you can set the environment variable
THREADS_FLAG to native to use native threads. CA needs to be built to
be thread safe. Building shared libraries with the following options
seems to work:
-Kpic -G -D_REENTRANT.
However, building shared libraries is an exercise in itself.
-Ken
- Navigate by Date:
- Prev:
Channel Access and Windows 95 Ken Evans
- Next:
Re: April Collaboration Meeting - Hotels Bob Dalesio
- Index:
1994
1995
1996
1997
<1998>
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Channel Access and Windows 95 Ken Evans
- Next:
Re: April Collaboration Meeting - Hotels Bob Dalesio
- Index:
1994
1995
1996
1997
<1998>
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|