JNI and FileDescriptor
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Thomas_Bruchmann
Posted On:   Thursday, April 19, 2001 06:37 AM

System: Win-NT 4, Language: Visual C++ 6.0, JDK: 1.3 I have written a DLL-function static void SetFileHandle( JNIEnv* pEnv, jobject fileDescriptor, long handle) { handle = _open_osfhandle(handle, 0)+1; jclass FileDescriptorClass = pEnv->GetObjectClass( fileDescriptor ); jfieldID handle_id = pEnv->GetFieldID( FileDescriptorClass, "fd","I"); pEnv->SetIntField( fileDescriptor, handle_id, handle); } to transfer a newly created filehandle (from a pipe) to a given FileDescriptor instance. On the Java-side I use a new BufferedInputStream(new FileInputStream(fd)) to read from that   More>>

System: Win-NT 4, Language: Visual C++ 6.0, JDK: 1.3



I have written a DLL-function


			
static void SetFileHandle( JNIEnv* pEnv, jobject fileDescriptor, long handle)
{
handle = _open_osfhandle(handle, 0)+1;
jclass FileDescriptorClass = pEnv->GetObjectClass( fileDescriptor );
jfieldID handle_id = pEnv->GetFieldID( FileDescriptorClass, "fd","I");
pEnv->SetIntField( fileDescriptor, handle_id, handle);
}



to transfer a newly created filehandle (from a pipe) to a given FileDescriptor instance.
On the Java-side I use a


new BufferedInputStream(new FileInputStream(fd))



to read from that (pipe)file. But now I get the input from system-jar-file!
It seems that the file-handle on the java-side points to another file as on
the C++-side (the numeric values are equal).


Whats wrong?    <<Less

Re: JNI and FileDescriptor

Posted By:   Thomas_Bruchmann  
Posted On:   Friday, April 20, 2001 09:53 AM

I must be sure, that there is no second C-Runtime-Area in the Process.
To do this I must set /MD Flag (resp. MDd in Debug-Mode) in the
MS-Visual C++ Compiler-Options.
About | Sitemap | Contact