www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - DLL jni Java6 update 1

reply Christoph <christoph singewald.at> writes:
Hi All!

Ich have a problem with jni and Java6 update 1. 
I have follwing files

my.dll  (DMD, bud)
myjni.dll (SWIGm, dmc or bcc32) references my.dll

When I am using Java5 everthing runs fine.
Ich I use Java6 I get an access violation and the end of the app, I think when
it happens when java is unloding the dll. I tested it with a plain dll without
gc and any other D function:

--DLL

import std.c.windows.windows;
HINSTANCE g_hInst;

extern(C) export int getX() {
        return 1;
}


extern (Windows) 
    BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved) {
   switch (ulReason) {
	    case DLL_THREAD_ATTACH:
	    case DLL_THREAD_DETACH:
	        return false;
    }
    g_hInst=hInstance;
    return true;
   
}

If I use a c++ dll created with bcc32/dmc everthing  runs fine with Java6.

thank you for helping 
christoph
Mar 13 2008
parent reply Robert Fraser <fraserofthenight gmail.com> writes:
Christoph wrote:
 Hi All!
 
 Ich have a problem with jni and Java6 update 1. 
 I have follwing files
 
 my.dll  (DMD, bud)
 myjni.dll (SWIGm, dmc or bcc32) references my.dll
 
 When I am using Java5 everthing runs fine.
 Ich I use Java6 I get an access violation and the end of the app, I think when
it happens when java is unloding the dll. I tested it with a plain dll without
gc and any other D function:
 
 --DLL
 
 import std.c.windows.windows;
 HINSTANCE g_hInst;
 
 extern(C) export int getX() {
         return 1;
 }
 
 
 extern (Windows) 
     BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved) {
    switch (ulReason) {
 	    case DLL_THREAD_ATTACH:
 	    case DLL_THREAD_DETACH:
 	        return false;
     }
     g_hInst=hInstance;
     return true;
    
 }
 
 If I use a c++ dll created with bcc32/dmc everthing  runs fine with Java6.
 
 thank you for helping 
 christoph
Hi Christoph, Sorry I can't help you with your problem directly. However, if you plan to use D's garbage collection, be warned that D and Java's garbage collectors don't get along (since they use the same signals). If you need the GC, IPC is a better solution (check http://www.dsource.org/projects/dbus-d/ ). Frank Benoit probably knows more about that than I do. If you don't need D's GC, then JNI is a perfect solution, but I'm not sure exactly what your problem is. Sorry I couldn't be more helpful, Robert
Mar 13 2008
parent reply Christoph <christoph singewald.at> writes:
Robert Fraser Wrote:

 Christoph wrote:
 Hi All!
 
 Ich have a problem with jni and Java6 update 1. 
 I have follwing files
 
 my.dll  (DMD, bud)
 myjni.dll (SWIGm, dmc or bcc32) references my.dll
 
 When I am using Java5 everthing runs fine.
 Ich I use Java6 I get an access violation and the end of the app, I think when
it happens when java is unloding the dll. I tested it with a plain dll without
gc and any other D function:
 
 --DLL
 
 import std.c.windows.windows;
 HINSTANCE g_hInst;
 
 extern(C) export int getX() {
         return 1;
 }
 
 
 extern (Windows) 
     BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved) {
    switch (ulReason) {
 	    case DLL_THREAD_ATTACH:
 	    case DLL_THREAD_DETACH:
 	        return false;
     }
     g_hInst=hInstance;
     return true;
    
 }
 
 If I use a c++ dll created with bcc32/dmc everthing  runs fine with Java6.
 
 thank you for helping 
 christoph
Hi Christoph, Sorry I can't help you with your problem directly. However, if you plan to use D's garbage collection, be warned that D and Java's garbage collectors don't get along (since they use the same signals). If you need the GC, IPC is a better solution (check http://www.dsource.org/projects/dbus-d/ ). Frank Benoit probably knows more about that than I do. If you don't need D's GC, then JNI is a perfect solution, but I'm not sure exactly what your problem is. Sorry I couldn't be more helpful, Robert
Hi Robert! Thank you for your fast reply. You're are right, thats a real problem under unix/linux. But the curent problem appear to me under windows, I did not test it under linux at the moment. So may be I have to find another solution, because I want to use it under inw32 and linux Christoph
Mar 13 2008
parent Christoph Singewald <christoph singewald.at> writes:
Christoph Wrote:

 Robert Fraser Wrote:
 
 Christoph wrote:
 Hi All!
 
 Ich have a problem with jni and Java6 update 1. 
 I have follwing files
 
 my.dll  (DMD, bud)
 myjni.dll (SWIGm, dmc or bcc32) references my.dll
 
 When I am using Java5 everthing runs fine.
 Ich I use Java6 I get an access violation and the end of the app, I think when
it happens when java is unloding the dll. I tested it with a plain dll without
gc and any other D function:
 
 --DLL
 
 import std.c.windows.windows;
 HINSTANCE g_hInst;
 
 extern(C) export int getX() {
         return 1;
 }
 
 
 extern (Windows) 
     BOOL DllMain(HINSTANCE hInstance, ULONG ulReason, LPVOID pvReserved) {
    switch (ulReason) {
 	    case DLL_THREAD_ATTACH:
 	    case DLL_THREAD_DETACH:
 	        return false;
     }
     g_hInst=hInstance;
     return true;
    
 }
 
 If I use a c++ dll created with bcc32/dmc everthing  runs fine with Java6.
 
 thank you for helping 
 christoph
Hi Christoph, Sorry I can't help you with your problem directly. However, if you plan to use D's garbage collection, be warned that D and Java's garbage collectors don't get along (since they use the same signals). If you need the GC, IPC is a better solution (check http://www.dsource.org/projects/dbus-d/ ). Frank Benoit probably knows more about that than I do. If you don't need D's GC, then JNI is a perfect solution, but I'm not sure exactly what your problem is. Sorry I couldn't be more helpful, Robert
Hi Robert! Thank you for your fast reply. You're are right, thats a real problem under unix/linux. But the curent problem appear to me under windows, I did not test it under linux at the moment. So may be I have to find another solution, because I want to use it under inw32 and linux Christoph
I capitulate! On windows I had as above said problems loading the D-DLL and under Linux there are real probrlems with the GC. I use sockets now and I am happy with it. christoph
Mar 26 2008