It is very common to write device drivers and code that access low level operation system functions in C or C++. There are also many powerful C and C++ libraries available for a variety of tasks. java is a programming...
详细信息
ISBN:
(纸本)9780819496201
It is very common to write device drivers and code that access low level operation system functions in C or C++. There are also many powerful C and C++ libraries available for a variety of tasks. java is a programming language that is meant to be system independent and is arguably much simpler to code than C/C++. However, java has minimal support for talking to native libraries, which results in interesting challenges when using C/C++ libraries with java code. Part of the problem is that java's standard mechanism for communicating with C libraries, javanative Interface, requires a significant amount of effort to do fairly simple things, such as copy structure data from C to a class in java. This is largely solved by using the java native access Library, which provides a reasonable way of transferring data between C structures and java classes and calling C functions from java. A more serious issue is that there is no mechanism for a C/C++ library loaded by a java program to call a java function in the java program, as this is a major issue with any library that uses callback functions. A solution to this problem was found using a moderate amount of C code and multiple threads in java. The Keck Task Language API (KTL) is used as a primary means of inter-process communication at Keck and Lick Observatory. KTL is implemented in a series or C libraries and uses callback functions for asynchronous communication. It is a good demonstration of how to use a C library within a java program.
暂无评论