Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: JNI, applets and ClassLoader re-use



ugly :-)
but definitely will work
thanks

On Mar 17, 2004, at 6:02 PM, Jon Stocks wrote:

This may not be the optimal solution but one thing you can do is load a
duplicate of the jni lib depending on if you could load the previous
library. This will result in multiple jni libraries on the client's machine
but, it will get you around the problem.

Essentially, what you could do is package the jni library in your jar file.
When the client requires the jni library, the applet (thanks to it being
signed) could copy the jni library to the client. Your first copy could be
something like:

Library0.jnilib

If the applet fails to load it, copy a duplicate library called
Library1.jnilib. Then try to load that library instead. Etc...

There are all sorts of algorithms you could use here.

Now, this may not be a very good solution for your setup. It depends on how
often your library gets loaded or how big your jni library is. But, it will
allow you to use JNI from an applet without running into this problem.

Jon

-----Original Message-----
From: email@hidden [mailto:email@hidden]
On Behalf Of Beau Burke
Sent: Wednesday, March 17, 2004 1:57 PM
To: email@hidden
Subject: JNI, applets and ClassLoader re-use

This is causing me to pull my hair out. Any insight would be
appreciated.

So, I've got a signed applet that makes use of a JNI library. I can

load this applet once just fine, in any browser (tried IE 5.2.3,
Firefox 0.8, Safari 1.21 - all on 10.3.3) and everything will work
fine. If I close the applet-containing page, but not the entire
browser, then try and reload the exact same page, I get
UnsatisfiedLinkError, like so:

java.lang.UnsatisfiedLinkError: Native Library
/Users/beau/Library/Application Support/myfolder/blahblahblah.jnilib
already loaded in another classloader
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1378)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1309)
at java.lang.Runtime.load0(Runtime.java:693)
at java.lang.System.load(System.java:792)
...(my static code)..
at sun.applet.AppletPanel.run(AppletPanel.java:339)
at java.lang.Thread.run(Thread.java:491)

Am I doing something stupid or is Apple? Java documentation seems
to
imply this error should be thrown only when the library can't be found.
Also, fiddling with the plugin settings (re-cycle classloader,
clearing jar cache, etc) doesn't help at all.

-Beau
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/java-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Do not post admin requests to the list. They will be ignored.


Dmitry Markman
_______________________________________________
java-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/java-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >RE: JNI, applets and ClassLoader re-use (From: Jon Stocks <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.