在浏览器中的 Applet 中重新加载 DLL

发布于 2024-09-30 03:25:00 字数 864 浏览 1 评论 0原文

我有一个关于为什么出现以下问题的理论,但我找不到任何文档以某种方式证明我的理论,所以我需要一些建议。

我有一个加载 DLL 的(签名的)小程序。现在,上周五我点击“刷新”,小程序重新加载正常,包括显然重新加载 DLL。但今天,点击“刷新”会导致以下异常:

java.lang.UnsatisfiedLinkError: Native Library XXX already loaded in another classloader

根据 Javadoc (Java 6) System.loadLibrary 是 Runtime.loadLibrary 的一种便捷方法,并且根据该文档:

如果使用相同的库名称多次调用此方法,则忽略第二次和后续调用。

我知道并理解,你不能在同一个 JVM 的不同类加载器中加载相同的本机库,这解释了上述异常。我想要证明的是为什么它在某一天似乎有效,但现在却不起作用。特别是考虑到 DLL 加载方面根本没有任何代码更改。

所以我的假设是这样的;

  1. 上面的文档应该是“在同一个类加载器中*的第二个和后续调用被忽略
  2. 上周五,行星处于不同的对齐方式,因此浏览器使用不同的 JVM(或者可能是相同的类加载器?),当我正在点击刷新,因此 DLL 已正确加载,并且运行良好,
  3. 今天行星的对齐方式不同,并且浏览器重用了相同的 JVM,但使用了不同的类加载器,这解释了为什么我现在收到此错误

。问题是 IE7,我运行的是 Java 1.6,我认为浏览器版本不是特别重要,因为我的理解是,浏览器决定如何处理小程序完全取决于浏览器实现者,

这些假设是否合理? 吗?我可能错过了什么?

正确

I have a theory as to why I have the following problem, but I can't find any documentation proving my theory one way or another so I'd like some advice.

I have a (signed) applet which loads a DLL. Now, last Friday I was hitting "Refresh" and the applet was reloading fine, including apparently reloading the DLLs. But today, hitting "Refresh" is causing the following exception:

java.lang.UnsatisfiedLinkError: Native Library XXX already loaded in another classloader

According to the Javadoc (Java 6) System.loadLibrary is a convenience method for Runtime.loadLibrary and according to that documentation:

If this method is called more than once with the same library name, the second and subsequent calls are ignored.

I know and understand that you cannot load the same native library in different class loaders in the same JVM, which explains the above exception. What I'm trying to prove is why it seemed to work on one day, but now doesn't. Especially given that there has been no code changes at all around the DLL loading.

So my assumptions are this;

  1. The above documentation should read "the second and subsequent calls *in the same class loader* are ignored
  2. Last Friday, the planets were in a different alignment and so the browser was using a different JVM (or maybe the same class loader?) when I was hitting refresh, so the DLL was loaded properly and things worked nicely.
  3. Today the planets are aligned differently and the browser is reusing the same JVM but a different classloader and this explains why I'm getting this error now.

Incidentally, the browser in question was IE7 and I'm running Java 1.6. I don't think the browser version is particularly important since it's my understanding that what the browser decides to do with an applet is completely up to the browser implementer.

Do these assumptions seem reasonable and correct? What might I have missed?

Many thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅浅 2024-10-07 03:25:00

听起来像这样 问题:本机库已加载到另一个类加载器中

现在他们正在说话关于 servlet,而不是 applet,但许多相同的行为都适用。

浏览器将类加载器与 url 以及可能的套接字连接联系起来。因此,重新加载将重用相同的类加载器,除非浏览器停留足够长的时间来空闲连接,此时您将获得一个新的套接字,从而获得一个新的类加载器。我们在同一页面上有多个小程序,并且在重新加载页面后它们是否会共享类加载器是一个糟糕的问题。

It sounds like this Problem : Native Library already loaded in another classloader

Now they are talking about servlets, not applets, but many of the same behaviors apply.

Browsers tie the classloader to the url and possibly the socket connection. So, reloading would reuse the same class loader unless the browser sat long enough to idle out the connection at which point you get a new socket and hence a new class loader. We had multiple applets on the same page and it was a crap shoot whether they would share a class loader following a reload of the page.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文