United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6881931 NPE in findAppletJDKLevel is thrown when NoClassDefFoundError should be thrown
JDK-6881931 : NPE in findAppletJDKLevel is thrown when NoClassDefFoundError should be thrown

Details
Type:
Bug
Submit Date:
2009-09-15
Status:
Closed
Updated Date:
2010-11-03
Project Name:
JDK
Resolved Date:
2010-01-13
Component:
deploy
OS:
generic,windows_xp
Sub-Component:
plugin
CPU:
x86,generic
Priority:
P2
Resolution:
Fixed
Affected Versions:
6u10,6u15,6u18
Fixed Versions:
6u18 (b05)

Related Reports
Duplicate:

Sub Tasks

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

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.
                                     
2009-10-22
EVALUATION

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



Hardware and Software, Engineered to Work Together