(a)
extern "Java"
{
class CSimpleJNI;
};
class ::CSimpleJNI : public ::java::lang::Object
{
public:
virtual jint getValue () { return nValue; }
virtual void putValue (jint);
virtual jint transformValue (jint);
virtual void nativeMethod (jint);
CSimpleJNI ();
private:
jint nValue;
public:
static ::java::lang::Class class$;
};
(b)
void CSimpleJNI::nativeMethod(jint param1) {
jint value = getValue();
// complex code omitted
value++;
putValue(value);
}
Example 2: (a) Using gcjh to create a CNI header file for the previous example yields this C++ code; (b) the code necessary to implement nativeMethod.
Back to Article