← Back to team overview

openjdk team mailing list archive

[Bug 199732] Re: applet fails to load with nullpointerexception

 

This bug is caused when the Java plugin hasn't had a window registered
using PluginMain.registerWindow(),  which will set
PluginMain.currentWindow.

Without PluginMain.currentWindow set (it is initialised to null), when
the gcjwebplugin sends the applet the "width" message, the applet's
PluginMain.start() message-reading loop reads the width correctly, but
then tries to get the internal height property using:

int height = currentWindow.getHeight();

Because currentWindow is NULL it causes the Null Pointer Exception on
line 211.

The problem is caused in PluginAppletViewer.parse(...). There are
several overloaded versions of this function but they all pass through
to the work-horse overload that takes a complete set of arguments.

In PluginAppletViewer.parse() it scans the HTML APPLET/OBJECT/EMBED tag
and extracts the attribute values. When it finds an EMBED tag it passes
it to PluginAppletViewer.scanTag(). That method is responsible for
scanning the parameters inside the <EMBED> tag and assigning them to
internal attributes.

When scanTag() returns the EMBED detection-logic does some sanity checks
on the attributes to ensure it has what it needs to execute the applet
successfully. It checks for the CODE, WIDTH, and HEIGHT attributes not
being null. If any one of them is null it sets the attribute reference
to null too - effectively wiping them all out.

When the logic in PluginAppletViewer.parse() finds the closing tag
</EMBED> it checks if the attributes reference IS NOT null and if so
calls PluginAppletViewerFactory.createAppletViewer(). That in turn calls
PluginMain.registerWindow() which, as I said at the beginning, sets
PluginMain.currentWindow.

But, because an attribute of the EMBED tag was missing, the attribute
reference was null and so PluginMain.registerWindow() wasn't called and
PluginMain.currentWindow remained with its initialised value, which is
null.

Hence the bug.

In the case of the sites here the missing tag is CODE, and you can see
the warning in the output:

Warning: <embed> tag requires code attribute.

That really should say "Error" since it is fatal.

Because the EMBED tag was not part of a W3C standard the definition of
legal parameters is hazy. It has been introduced for HTML 5 *but* will
not support the CODE attribute.


** Also affects: openjdk-6 (Ubuntu)
   Importance: Undecided
       Status: New

** Changed in: openjdk-6 (Ubuntu)
   Importance: Undecided => Medium
     Assignee: (unassigned) => TJ (intuitivenipple)
       Status: New => Confirmed

-- 
applet fails to load with nullpointerexception
https://bugs.launchpad.net/bugs/199732
You received this bug notification because you are a member of OpenJDK,
which is subscribed to openjdk-6 in ubuntu.

Status in “icedtea-gcjwebplugin” source package in Ubuntu: Confirmed
Status in “openjdk-6” source package in Ubuntu: Confirmed
Status in “openjdk-6” source package in Fedora: Confirmed

Bug description:
Binary package hint: icedtea-java7-plugin

I am trying to access an applet from http://www.jigzone.com. The applet fails to load with error:

Exception in thread "main" java.lang.NullPointerException
	at sun.applet.PluginMain.start(PluginMain.java:211)
	at sun.applet.PluginMain.main(PluginMain.java:73)


I am running Hardy Alpha 6 (firefox3, icedtea-java7). The applet works just fine on my Gutsy box (firefox2, sun6).

I have attached the complete console output

ProblemType: Bug
Architecture: i386
Date: Fri Mar  7 23:13:26 2008
DistroRelease: Ubuntu 8.04
Package: firefox 3.0~b3+nobinonly-0ubuntu4
PackageArchitecture: all
SourcePackage: firefox-3.0
Uname: Linux 2.6.24-11-generic i686