> One of my tasks which is on the back burner of a stove I don't own in
> a dump a hundred miles away is to look at CNI and determine how might
> be the easiest method to get Classpath to work with it. If I read the
> above messages correctly this means I should think in terms of either
> providing #ifdef'ing all the native code or writing some portability
> layer?
Here's a trivial sample of gcj's CNI; I put it together when I was
trying to figure out how to do it. (grin)
As you can see, it's rather different from the JNI interface...
==> sampNat.cc <==
#include "sample.h"
#include <stream.h>
#include <java/io/PrintStream.h>
#include <java/lang/System.h>
#include <java/lang/String.h>
#include <cni.h>
void sample::myNative(java::lang::String *s)
{
cout << "Hello, C++" << endl;
// The following line causes a link error for a missing typeinfo
// unless this file is compiled with '-fno-rtti'
java::lang::System::out->println(s);
}
==> sample.java <==
public class sample {
public native void myNative(String s);
public void myJava(String s) {
s = s + ", Java";
System.out.println(s);
}
public static void main(String args[]) {
sample x = new sample();
x.myJava("Hello");
x.myNative("Hello, Java (from C++)");
x.myJava("Goodbye");
}
}