S
stef
Hi guys,
Could U tell me where is my error with my little JNI calling :
with VC 6 and JAVA 1.5.2
(i omitted the package/import declaration to gain time)
//--------------------------------------- C method : (generating a test.dll)
JNIEXPORT void JNICALL Java_com_pack_JTest_Connect(JNIEnv *env, jobject
this, jstring Str)
{
jfieldID fid;
jclass cls;
jlong val;
cls = (*env)->GetObjectClass(env, this);
fid = (*env)->GetFieldID(env, cls, "m_hdl", "J");
val = (*env)->GetLongField(env, this, fid);
(*env)->SetLongField(env, this, fid, 666);
}
//--------------------------------------- Java
public class JTest
{
private long m_hdl;
static
{
try
{
System.loadLibrary("test");
}
catch (java.lang.UnsatisfiedLinkError e)
{
System.out.println("error : " + e);
}
}
public static native void Connect( String xmlConnect );
/*
*
*/
public JTest()
{
Connect("");
System.out.println("Test : "+m_hdl);
}
}
Simple no ?
and with a little test like
class main
{
public static void main(String[] args)
{
JTest p;
int i=0;
p = new JTest();
p.Connect("");
}
}
I get :
Exception in thread "main" java.lang.NoSuchFieldError: m_hdl
at com.pack.JTest.Connect(Native Method)
at com.pack.JTest.<init>(JTest.java:35)
at main.main(main.java:18)
As I can see in debug mode, method GetFieldID() doesn't "see" m_hdl !!!!
why ???
thanx for your help
Could U tell me where is my error with my little JNI calling :
with VC 6 and JAVA 1.5.2
(i omitted the package/import declaration to gain time)
//--------------------------------------- C method : (generating a test.dll)
JNIEXPORT void JNICALL Java_com_pack_JTest_Connect(JNIEnv *env, jobject
this, jstring Str)
{
jfieldID fid;
jclass cls;
jlong val;
cls = (*env)->GetObjectClass(env, this);
fid = (*env)->GetFieldID(env, cls, "m_hdl", "J");
val = (*env)->GetLongField(env, this, fid);
(*env)->SetLongField(env, this, fid, 666);
}
//--------------------------------------- Java
public class JTest
{
private long m_hdl;
static
{
try
{
System.loadLibrary("test");
}
catch (java.lang.UnsatisfiedLinkError e)
{
System.out.println("error : " + e);
}
}
public static native void Connect( String xmlConnect );
/*
*
*/
public JTest()
{
Connect("");
System.out.println("Test : "+m_hdl);
}
}
Simple no ?
and with a little test like
class main
{
public static void main(String[] args)
{
JTest p;
int i=0;
p = new JTest();
p.Connect("");
}
}
I get :
Exception in thread "main" java.lang.NoSuchFieldError: m_hdl
at com.pack.JTest.Connect(Native Method)
at com.pack.JTest.<init>(JTest.java:35)
at main.main(main.java:18)
As I can see in debug mode, method GetFieldID() doesn't "see" m_hdl !!!!
why ???
thanx for your help