JDK-6881931 : NPE in findAppletJDKLevel is thrown when NoClassDefFoundError should be thrown
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 6u10,6u15,6u18
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,windows_xp
  • CPU: generic,x86
  • Submitted: 2009-09-15
  • Updated: 2010-11-03
  • Resolved: 2010-01-13
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 b05Fixed
Related Reports
Duplicate :  
Description
FULL PRODUCT VERSION :
Java Plug-in 1.6.0_18
Using JRE version 1.6.0_18-ea-b02 Java HotSpot(TM) Client VM

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
When using the next generation java plug-in, and a class file cannot be found in the archive jar file(s), findAppletJDKLevel is thrown as follows:

java.lang.NullPointerException
	at sun.plugin2.applet.Plugin2Manager.findAppletJDKLevel(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)
Exception: java.lang.NullPointerException
Ignored exception: java.lang.NullPointerException



STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1) Close all browsers, ensuring that there are no plugin coffee cup icons in the Windows taskbar.
2) Open the Java Control panel (Start->Control Panel->Java).
2.5) On the General tab, clear cache by clicking Settings..., Delete Files..., OK.
3) Open the Advanced tab.
4) Expand the Java Plug-in tree option.
5) Ensure that the "Enable the next-generation Java Plug-in"  option is checked and click OK.
6) Visit page http://www.printdesktop.com/IeTabbedCrash/IeTabbedCrash.html
7) View the java console stacktrace.  It should include findAppletJDKLevel message.

Now, to see the correct error message (NoClassDefFoundError) displayed, follow these steps:
1) Close all browsers, ensuring that there are no plugin coffee cup icons in the Windows taskbar.
2) Open the Java Control panel (Start->Control Panel->Java).
2.5) On the General tab, clear cache by clicking Settings..., Delete Files..., OK.
3) Open the Advanced tab.
4) Expand the Java Plug-in tree option.
5) Ensure that the "Enable the next-generation Java Plug-in"  option is NOT checked and click OK.
6) Visit page http://www.printdesktop.com/IeTabbedCrash/IeTabbedCrash.html
7) View the java console stacktrace.  It should include NoClassDefFoundError error message.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
See a useful stacktrace:

java.lang.NoClassDefFoundError: IeTabbedCrash$2
	at java.lang.Class.getDeclaredConstructors0(Native Method)
	at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
	at java.lang.Class.getConstructor0(Unknown Source)
	at java.lang.Class.newInstance0(Unknown Source)
	at java.lang.Class.newInstance(Unknown Source)
	at sun.applet.AppletPanel.createApplet(Unknown Source)
	at sun.plugin.AppletViewer.createApplet(Unknown Source)
	at sun.applet.AppletPanel.runLoader(Unknown Source)
	at sun.applet.AppletPanel.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: IeTabbedCrash$2
	at sun.applet.AppletClassLoader.findClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	at sun.applet.AppletClassLoader.loadClass(Unknown Source)
	at java.lang.ClassLoader.loadClass(Unknown Source)
	... 10 more
Ignored exception: java.lang.NoClassDefFoundError: IeTabbedCrash$2

ACTUAL -
See this misleading stacktrace:

java.lang.NullPointerException
	at sun.plugin2.applet.Plugin2Manager.findAppletJDKLevel(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)
Exception: java.lang.NullPointerException
Ignored exception: java.lang.NullPointerException

ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.NullPointerException
	at sun.plugin2.applet.Plugin2Manager.findAppletJDKLevel(Unknown Source)
	at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
	at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
http://www.printdesktop.com/IeTabbedCrash/IeTabbedCrash.jar
---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Disable the Next-generation java plug-in.

Comments
EVALUATION Since we're catching error in the runnable in Plugin2Manager, changes in DeployAWTUtil isn't necessary.
27-10-2009

EVALUATION The problem is due to in DeployAWTUtil.invokeAndWait(), we always pass in "true" as the catchThrowables when creating an InvocationEvent. We're only getting the exception by event.getException(). But in this case, an error is thrown. Potentially, we can use event.getThrowable() to get the error but getThrowable() is available in jdk 5.0 and newer releases. In order for the error to propagate back to Plugin2Manager, a new invokeAndWait() is added. The new method takes 3 arguments - the last one is to set the catchThrowables flag. In Plugin2Manager, we catch the error in the runnable which creates an applet instance. If an error occurs, a new RuntimeException will be thrown.
22-10-2009