JDK-5062222 : NPE in XYZApp.newBackBuffer
  • Type: Bug
  • Component: deploy
  • Sub-Component: plugin
  • Affected Version: 5.0
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: solaris_8,solaris_9
  • CPU: generic,sparc
  • Submitted: 2004-06-11
  • Updated: 2004-10-13
  • Resolved: 2004-10-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.
Other JDK 6
5.0u6Fixed 6 b08Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Description
Run demo applet MolucularViewer, example3.html, on Solaris in Mozilla with jdk1.5.0
Reload applet several time, try to reload applet while it is not yet painted. The following exceptions occur sometimes:

java.lang.Exception: Token[NOTHING], line 1
	at XYZChemModel.<init>(XYZApp.java:140)
	at XYZApp.run(XYZApp.java:331)
	at java.lang.Thread.run(Thread.java:595)

java.lang.NullPointerException
	at XYZApp.newBackBuffer(XYZApp.java:300)
	at XYZApp.init(XYZApp.java:316)
	at sun.applet.AppletPanel.run(AppletPanel.java:373)
	at java.lang.Thread.run(Thread.java:595)

java.security.AccessControlException: access denied (java.lang.RuntimePermission modifyThread)
	at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
	at java.security.AccessController.checkPermission(AccessController.java:427)
	at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
	at sun.applet.AppletSecurity.checkAccess(AppletSecurity.java:138)
	at java.lang.Thread.checkAccess(Thread.java:1209)
	at java.lang.Thread.setPriority(Thread.java:956)
	at XYZApp.run(XYZApp.java:329)
	at java.lang.Thread.run(Thread.java:595)

NPE happens because an Image, returned from createImage, is null. This happens becaue peer at this time is null. This seems weird - in init applet should always have peer.
###@###.### 2004-06-11

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: mustang FIXED IN: mustang
01-10-2004

EVALUATION I made a trace of calls for constructor, addNotify, removeNotify, init, newBackBuffer, whether parent peer is null in init, whether applet's peer is null in init and what is the index of applet in parent. I distinguish different applets by hashCode. Here is the output when peer is null: Constr 21153656 Init 21153656 Parent peer is null? true Peer is null? true We've been added? 0 This: 21153656 EXCEPTION in newBackBuffer ========================== As you can see, applet was constructed, init was called and newBackBuffer was called from it. addNotify wasn't called but add was - applet's index is 0. It is also can be seen that parent and applet both have no peers. ###@###.### 2004-06-11 This happens because at the time when init it called, AppletPanel has not yet been added to EmbeddedFrame: =============== Constr 12256262 Init 1418145 Parent peer is null? false Peer is null? false We've been added? 0 Have been added to embedded frame? true Parent's parent peer is null? false Parent's parent is visible? true This: 1418145 Init 29532653 Parent peer is null? false Peer is null? false We've been added? 0 Have been added to embedded frame? true Parent's parent peer is null? false Parent's parent is visible? true This: 29532653 Init 12256262 Parent peer is null? true Peer is null? true We've been added? 0 Have been added to embedded frame? false This: 12256262 EXCEPTION in newBackBuffer ========================== This is a plugin bug. I think the cause of it is that addition is scheduled asynchronously on EDT: MNetscapePluginObject.java private synchronized void initPlugin() { ... DeployAWTUtil.invokeLater(frame, new Runnable() { public void run() { frame.add(panel); frame.setVisible(true); } }); ... while initialization happens on the Applet thread: public void run() { ... case APPLET_INIT: if (status != APPLET_LOAD) { showAppletStatus("notloaded"); break; } applet.resize(defaultAppletSize); if (doInit) { if (PerformanceLogger.loggingEnabled()) { PerformanceLogger.setTime("Applet Init"); PerformanceLogger.outputLog(); } applet.init(); } ... private void runLoader() { ... // Fixed #4508194: NullPointerException thrown during // quick page switch // if (applet != null) { // Stick it in the frame applet.setStub(this); applet.hide(); add("Center", applet); showAppletStatus("loaded"); validate(); } ... ###@###.### 2004-06-11 Suggested fix is to remove frame.add(panel) from invokeLater in initPlugin method in MNetscapePluginObject.java. The fix needs further evaluation and detailed testing on all platforms. Similar changes should be made in WNetscapePluginObject.java and IExplorerPluginObject.java, since even though the problem is currently reproducible on Unix platform only, it is a timing issue and might become visible on other platforms in future releases. ###@###.### 2004-06-18
18-06-2004