更新到7u45后,带有LWJGL的Java Applet破产

时间:2013-10-24 11:51:25

标签: java applet lwjgl

我们有一个Java Apllet,几年来运行没有问题。它使用LWJGL,所有罐子都签有适当的证书(非自签名)。 在u45的最后一次Java更新之后,applet崩溃了。

到目前为止我们做了什么:

  • 添加了权限:对所有JAR的清单的所有权限
  • 将pplication-Library-Allowable-Codebase:*添加到所有JAR的清单
  • 将Caller-Allowable-Codebase:*添加到所有JAR的清单
  • 为所有JAR的清单添加了Codebase:*
  • 上述
  • 的不同排列

我知道安全警告的配置方式有一些变化,但(现在!)我们不关心要求权限的弹出窗口。首先,我们想让它发挥作用,

以下是java控制台内部发生的所有异常情况。输出的其余部分似乎没问题:

java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.lwjgl.util.applet.AppletLoader$4.getPermissions(AppletLoader.java:1206)
    at java.security.SecureClassLoader.getProtectionDomain(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at org.lwjgl.util.applet.AppletLoader.switchApplet(AppletLoader.java:1319)
    at org.lwjgl.util.applet.AppletLoader$2.run(AppletLoader.java:909)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$200(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.NullPointerException
    at sun.plugin2.applet.Plugin2ClassLoader.loadAllowedCodebases(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.getPermissions(Unknown Source)
    at sun.plugin2.applet.Applet2ClassLoader.getPermissions(Unknown Source)
    ... 31 more

java.lang.reflect.InvocationTargetException
    at java.awt.EventQueue.invokeAndWait(Unknown Source)
    at java.awt.EventQueue.invokeAndWait(Unknown Source)
    at org.lwjgl.util.applet.AppletLoader.run(AppletLoader.java:906)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ExceptionInInitializerError
    at org.lwjgl.Sys.createImplementation(Sys.java:124)
    at org.lwjgl.Sys.<clinit>(Sys.java:111)
    at org.lwjgl.opengl.AWTGLCanvas.<clinit>(AWTGLCanvas.java:87)
    at j2cad.d.c.k(Unknown Source)
    at j2cad.applet.J2CadApplet.init(Unknown Source)
    at org.lwjgl.util.applet.AppletLoader.switchApplet(AppletLoader.java:1330)
    at org.lwjgl.util.applet.AppletLoader$2.run(AppletLoader.java:909)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$200(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.security.AccessControlException: access denied ("java.util.PropertyPermission" "org.lwjgl.util.Debug" "read")
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at sun.plugin2.applet.AWTAppletSecurityManager.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
    at java.lang.System.getProperty(Unknown Source)
    at java.lang.Boolean.getBoolean(Unknown Source)
    at org.lwjgl.LWJGLUtil$4.run(LWJGLUtil.java:454)
    at org.lwjgl.LWJGLUtil$4.run(LWJGLUtil.java:452)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.lwjgl.LWJGLUtil.getPrivilegedBoolean(LWJGLUtil.java:452)
    at org.lwjgl.LWJGLUtil.<clinit>(LWJGLUtil.java:265)
    ... 21 more

第一个出现多次,第二个出现在日志的最后一次。

所有建议都表示赞赏,对于所有进行更新的人来说网站都已关闭了!

谢谢大家!

1 个答案:

答案 0 :(得分:4)

由于lwjgl_util_applet.jar中的AppletLoader通过替换默认的classLoader来覆盖安全上下文,因此我找到了一个令人毛骨悚然的解决方法来避免此问题。所以我们需要修补它:

1 - 下载课程HERE

2 - 替换它:

classLoader = new URLClassLoader(urls) {

用这个:

classLoader = new URLClassLoader(urls, Thread.currentThread().getContextClassLoader()) {

这样:

Thread.currentThread().setContextClassLoader(classLoader);
Class appletClass = classLoader.loadClass(getParameter("al_main"));

用这个:

Class appletClass = Thread.currentThread().getContextClassLoader().loadClass(getParameter("al_main"));

和此:

urlconnection.setDefaultUseCaches(false);

用这个:

urlconnection.setDefaultUseCaches(true);

3 - 使用新的.class编译和覆盖lwjgl_util_applet.jar的.class。

4 - 删除所有罐子的签名(如果存在)并使用MANIFEST.MF中的所有属性重新签名

Manifest-Version: 1.0
Trusted-Library: true
Application-Library-Allowable-Codebase: *
Trusted-Only: false
Application-Name: My app
Permissions: all-permissions
Created-By: 1.6.0_16 (Sun Microsystems Inc.)
Caller-Allowable-Codebase: *
Codebase: *

5 - 在applet标签中,输入:

<param name="permissions" value="all-permissions">
<param name="codebase_lookup" value="true">
<param name="classloader_cache" value="false">
<param name="al_version" value="0.1">"

6 - (令人毛骨悚然的部分)将所有的罐子放在参数“al_jars”中的param“archive”中(只需在al_jars中放一个空格),

7 - 清理缓存(java和浏览器)并将java缓存设置为活动状态(如应用程序的未来用户),

8 - 运行你的小程序,让你的手指交叉。