Hi,
I have a java class with a native method implemented in C++.
This method uses fstream. I got a Segmentation Fault when the destructor
of the fstream is called.
Is it a bug in JNI ? Am I missing something ?
#include <fstream.h>
JNIEXPORT
jboolean
JNICALL
Java_MyClass_write(JNIEnv * env, jobject obj)
{
ofstream out;
out.open("file");
if(!out.is_open())
return false;
out << "HelloWorld" << endl;
out.close();
return true;
} /* it crashes here */
another version
#include <fstream.h>
JNIEXPORT
jboolean
JNICALL
Java_MyClass_write(JNIEnv * env, jobject obj)
{
ofstream * out;
out = new ofstream;
out->open("file");
if(!out->is_open())
return false;
*out << "HelloWorld" << endl;
out->close();
delete out; /* it crashes here and it works fine if this line is
removed */
return true;
} /* it crashes here */
Pierre
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]