Java_java_lang_System_mapLibraryName Does this need to be native?
Michael Franz
mvfranz at gmail.com
Thu Oct 9 21:06:52 PDT 2008
Hi,
I have another plan that would create another native method called
mapAltLibraryName. This would work the same way as mapLibraryName but use
JNI_LIB_PREFIX and ALT_JNI_LIB_SUFFIX. On platforms that do not have an
alternate suffix NULL would be returned.
This method can then be called in ClassLoader.java when the library name
created by mapLibraryName fails.
The following files would be changed:
jdk/src/solaris/javavm/export/jvm_md.h -- define ALT_JNI_LIB_SUFFIX for OS X
jdk/src/share/native/java/lang/System.c -- implementation that uses
ALT_JNI_LIB_SUFFIX
jdk/src/share/classes/java/lang/ClassLoader.java -- use mapAltLibraryName
jdk/src/share/classes/java/lang/System.java -- define package scope
mapAltLibraryname
I think this limits the changes and impact to other platforms.
To be compatible with Apple's implementation JNI_LIB_SUFFIX should be
defined as .jnilib and ALT_JNI_LIB_SUFFIX should be defined as .dylib
Michael
On Mon, Oct 6, 2008 at 9:44 PM, Michael Franz <mvfranz at gmail.com> wrote:
> Hi,
>
> After looking at Java_java_lang_System_mapLibraryName I am wondering why
> this has to be a native method? It seems that the only benefit to being
> native is that JNI_LIB_PREFIX and JNI_LIB_SUFFIX are defined using defines
> in the platform header files.
>
> Being a much stronger Java programmer than a C programmer, I would prefer
> to have a way to get the two values (JNI_LIB_PREFIX and JNI_LIB_SUFFIX) and
> manipulate the string building using StringBuilder.
>
> If that is not feasible I would try to create a new method that returns a
> String[] of the possible library names. Since I am interested in the OS X
> version a load of abc would return:
>
> return new String[] { "libabc.dylib", "libabc.jnilib" }
>
> Then ClassLoader.loadLibrary can loop over the string array when it is
> searching the sys_paths. This method would also work for cases where there
> are multiple choices for the JNI_LIB_PREFIX.
>
> Comments?
>
> Michael
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/bsd-port-dev/attachments/20081010/e837d238/attachment.html
More information about the bsd-port-dev
mailing list