Proposal for CNI/JNI problems
Per Bothner
per@bothner.com
Sat Apr 1 00:00:00 GMT 2000
David Pettersson <dapet@mai.liu.se> writes:
> I think there are two problems if JNI C interface is not supported.
We are talking about the classpath *implementation*, not whether
JNI should be supported. There are two separate issues:
(1) Supporting JNI code written in C. such code can be compiled with
any C compiler, resulting an object file using the JNI ABI.
Implementing JNI is a task that needs to be supported by JVM run-time.
(Gcj will probably also use compile-/link-time tools to implement
JNI.)
(2) Writing libraries that can be invoked using either JNI or CNI.
This requires conditional compilation and/or a smart compiler.
Using pure conditional compilation would allow full portability to
any JVM and C/C++ compiler. However, it becomes very tedious and
ugly, and you give up the simplicity of CNI. An alternative is
some kind of pre-processor. The ultimate pre-processor is
G++, which is what I suggested. It allows libraries to maintain
(most of) the simplicity of CNI, while still producing code that
is binary compatible with JVMs that only understand JNI.
The discussion is about (2).
> Classpath will not be able to compile with other C compilers.
True.
> Classes that use JNI can not be used with gcc/gcj.
False.
--
--Per Bothner
per@bothner.com http://www.bothner.com/~per/
More information about the Java
mailing list