JDK-6891332 : Regression: Applet fails to load from the /lib/applet
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 6u18
  • Priority: P1
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2009-10-14
  • Updated: 2010-09-08
  • Resolved: 2009-12-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6u18 b04Fixed
Related Reports
Relates :  
Relates :  
Description
With 6u18-b03 applets with jars sitting inside <jre>/lib/applet fails to load at all.
Bug is only reproducible with new Plug-in and from 6u18-b03. Bug was not there inside the PIT build against 6u18-b03.
Steps to reproduce:
------------------
1) Copy hostile.jar from following location and copy it inside the <jre>/lib/applet directory
http://sqeweb.sfbay.sun.com/deployment2/jitu/deployment_mustang_exec_ws/deployment/src/plugin/AppletSecurity/AppletSecurity/lib/
2) try to load applet 
http://sqeweb.sfbay.sun.com/deployment2/jitu/deployment_mustang_exec_ws/deployment/src/plugin/AppletSecurity/AppletSecurity/html/app_security02.html
If applets fail to load by throwing following exception then bug is reproduced

java.lang.NoClassDefFoundError: Appletmain
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(Unknown Source)
	at java.lang.ClassLoader.defineClass(Unknown Source)
	at java.security.SecureClassLoader.defineClass(Unknown Source)
	at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
	at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
	at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: Appletmain
	at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	... 11 more
Caused by: java.io.IOException: open HTTP connection failed:http://sqeweb.sfbay.sun.com/deployment2/jitu/deployment_mustang_exec_ws/deployment/src/plugin/AppletSecurity/AppletSecurity/classes/wwwY/Appletmain.class
	at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
	at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
	at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
	at java.security.AccessController.doPrivileged(Native Method)
	... 14 more

Comments
EVALUATION A fix is to add a null check on the CacheEntry in Plugin2ClassLoader.defineClassHelper fixes the problem. The reason is that prior to the fix for 6830734, the code path goes through the "else" part; with the fix for 6830734 with a new defineClass method, the code path goes through the "if" part. For a jar file with file URL, we don't store it in cache and that's why the CacheEntry is null in this case.
16-10-2009

EVALUATION This problem occurred after the fix for 6830734 was integrated into 6u18. Prior to the fix for 6830734, the useNewDefineClassMethod flag in Plugin2ClassLoader is always equal to false and the "old" defineClass method was invoked. A quick fix for this problem is in Plugin2ClassLoader.getDefineClassMethod to not searching for the "new" defineClass method.
15-10-2009