You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2003/01/13 16:39:45 UTC

DO NOT REPLY [Bug 16028] New: - JNI safety framework mechanism required

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16028>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16028

JNI safety framework mechanism required

           Summary: JNI safety framework mechanism required
           Product: Tomcat 5
           Version: 5.0.0
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Unknown
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: junk@bbs.darktech.org


Hi,

   I would like the following officially clarified. Please think on it .. don't
just close the issue as INVALID.

   Specifically, it is impossible to *safely* use JNI under Tomcat 4.x (I assume
the same is true for 5.x) because of a JVM limitation whereby a native shared
library may only be loaded once per JVM. This leads to the following problem:

- class A uses library L
- Since Tomcat makes use of multiple classloaders and might load the same bean
multiple times in different classloaders, System.loadLibrary() (which is
required for JNI) might get executed multiple times across different classloaders.
- This isn't a problem if we know for a fact that the old bean was unloaded
before the new one was loaded. I believe the shared library is unloaded with the
old instance.
- Sun's Bug Parades suggests the only way to solve this problem is to make sure
that across all classloaders, all instances of class A make use of a utility
class B which does the actual System.loadLibrary() call. It is suggested that
the developer guarantee that class B (System.loadLibrary()) is only loaded once
per JVM whereas class A may be loaded multiple times in multiple classloaders.
That is, as long as class B is loaded in a parent classloader to class A's
classloader everything will be fine. Furthermore, only one instance of B may
exist per JVM.
- The problem with the above workaround is that Tomcat provides no framework
mecanism that guarantees JNI library loaders (as mentioned above as class B)
will only be loaded once.
- I urge you to contact Sun engineers for more details so you're aware of all
the issues before responding.

Thank you,
Gili

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>