I’m taking C++/CLI for a spin, and I’ve run into an annoying warning:
JNIEnvWrapper.obj : warning LNK4248: unresolved typeref token (0100000C) for '_jmethodID'; image may not run
JNIEnvWrapper.obj : warning LNK4248: unresolved typeref token (0100000D) for '_jfieldID'; image may not run
#pragma managed(push,off)
struct JNIEnv_;
typedef JNIEnv_ JNIEnv;
struct JavaVM_;
typedef JavaVM_ JavaVM;
struct _jfieldID;
typedef _jfieldID *jfieldID;
struct _jmethodID;
typedef _jmethodID *jmethodID;
#pragma managed(pop)
Replacing the section above with
#pragma managed(push,off)
#include <jni.h>
#pragma managed(pop)
doesn't solve the problem either ...
Neither does
#pragma warning( disable : 4248 )
Oddly enough I'm not getting any warnings about JNIEnv_ or JavaVM_.
I'm just using jmethodID and jfieldID in managed code.
Declaration:
jmethodID FromReflectedMethod(JavaObject^ method);
jfieldID FromReflectedField(JavaObject^ field);
Implmentation:
jmethodID JNIEnvWrapper::FromReflectedMethod(JavaObject^ method)
{
jmethodID result = 0;
jobject jObj = method->JNINative;
result = env->FromReflectedMethod(jObj);
return result;
}
jfieldID JNIEnvWrapper::FromReflectedField(JavaObject^ field)
{
jfieldID result = 0;
jobject jObj = field->JNINative;
result = env->FromReflectedField(jObj);
return result;
}
So _jfieldID and _jmethodID are treated as opaque types. (As I'm not playing around with the internals of the JDK, they could hardly be anything else.) The code seems to run just fine, but I would like to get rid of the warnings - they are usually there for a reason :).
Any ideas? I'll be happy to just find a way to suppress the warning ...
Regards
Espen Harlinn