[libbluray-devel] [PATCH] VM loading for win32 dll's

Erik Van Grunderbeeck erik at arawix.com
Sun Mar 27 14:31:30 CEST 2011


Erik Van Grunderbeeck wrote:
> This fixes loading VM�s for Win32. I general, its a known problem
> since 2004 or so (just google for �JNI_CreateJavaVM crash�). 
[...]
> Do direct load of Java VM through LoadLibrary on Win32. Loading
> through dl_sym() will destroy the function pointers on a 64 bit VM on
> Win32 (not sure for *Nix)
[...]
> -    fptr_JNI_CreateJavaVM JNI_CreateJavaVM_fp = (fptr_JNI_CreateJavaVM)dl_dlsym(jvm_lib,
> -            "JNI_CreateJavaVM");
> -
> +#ifdef WIN32
> +    fptr_JNI_CreateJavaVM JNI_CreateJavaVM_fp = (fptr_JNI_CreateJavaVM)GetProcAddress(jvm_lib, "JNI_CreateJavaVM");
> +#else  //      #ifdef WIN32
> +    fptr_JNI_CreateJavaVM JNI_CreateJavaVM_fp = (fptr_JNI_CreateJavaVM)dl_dlsym(jvm_lib, "JNI_CreateJavaVM");
> +#endif //      #ifdef WIN32

>If GetProcAddress() returns pointer (32-bit in Win32), I can't see how
>those two differ ? dl_dlsym() is just a wrapper for GetProcAddress().

My description is off, should have been Win64 instead of Win32.

Although it shouldnt be a problem, the double cast causes problems when compiling with intel compiler on Win32. I get a stack exception when I use a call through dl_dlsym() when using intel icc 10 and 11. It may be because of a compiler/linker bug, or the funky signature, or both, not sure. Other dll loading seems to be fine. I suspect the intel compiler, since I know of at least one other intel compiler bug that behaves strangly in cases like this (mainly due to cross module optimizing).

In general, the dll loading should probably also be cached since reloading the VM will currenly always fail when a java bray is ejected and another java bray is inserted.

Not sure if you want to apply the patch (since it does clutter up stuff), I currenly only have a dll working through VS2005. It may be that gcc doesnt cause problems, once that is working I could confirms yes or no.


Erik
_______________________________________________
libbluray-devel mailing list
libbluray-devel at videolan.org
http://mailman.videolan.org/listinfo/libbluray-devel



More information about the libbluray-devel mailing list