Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 5062191
Votes 9
Synopsis NPE in Win32SurfaceData.initOps when exiting appletviewer on Swing applet
Category java:classes_2d
Reported Against b15 , tiger-beta2
Release Fixed
State 6-Fix Understood, bug
Priority: 4-Low
Related Bugs 6255371 , 6212318 , 5098186
Submit Date 11-JUN-2004
Description
Version: Tiger b54
System: Dual Processor x86
OS: Windows NT 4

\> cd demos
\> cd jfc
\> cd SwingSet2
\> appletviewer SwingSet2.html
When SwingSet has finished loading, hit the X to close the window.

\> cd demos
\> cd jfc
\> cd SwingApplet
appletviewer SwingApplet.html
When the applet has finished loading, hit X to close the window.

In both cases, the following exception is printed on the console:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: component argument pData
        at sun.awt.windows.Win32SurfaceData.initOps(Native Method)
        at sun.awt.windows.Win32SurfaceData.<init>(Win32SurfaceData.java:448)
        at sun.awt.windows.Win32SurfaceData.createData(Win32SurfaceData.java:316)
        at sun.awt.Win32GraphicsConfig.createSurfaceData(Win32GraphicsConfig.java:357)
        at sun.awt.windows.WComponentPeer.replaceSurfaceData(WComponentPeer.java:326)
        at sun.awt.windows.WComponentPeer.replaceSurfaceData(WComponentPeer.java:307)
        at sun.awt.windows.WComponentPeer$2.run(WComponentPeer.java:347)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Work Around
N/A
Evaluation
The bug is reproducible all the way since b18 (don't have
the earlier builds handy), but not on 1.4.2, as far as I can tell.

Also, I've only been able to reproduce it on Windows dual-cpu systems
(I've reproduced it on both windows-i586 and windows-amd64).

I wouldn't call it a tiger showstopper, as the exception seems to be
harmless - we detect a null data pointer and throw the exception. 
It's possible that applets running in browser can throw
it as well when the user leaves the page - I haven't tried this
yet.

  xxxxx@xxxxx   2004-06-17
I believe the bug is fixed with my change in WComponentPeer.
The change is a part of the fix for 6255371. The change
is to post an invocation event (which replaces the surface 
data associated with the component) to the event dispatch thread
of the app context, to which the current component belongs.
Previously all such invocation events were posted to the event 
dispatch thread of the main app context and a thread race
might result in NullPointerException.

Note the bug is not easily reproducible, so I can't verify 
whether it's fixed. The bug may be closed if it is not 
reproducible any more.
Posted Date : 2006-04-03 15:16:19.0

I don't have a dual CPU machine any more and it's therefore very hard to see if this is gone. Does anyone else have a machine to test this out on?
Posted Date : 2006-04-03 18:07:10.0

Note that it appears that 2D doesn't use the native peer data correctly,
at least, on windows.

Prior to getting the pData we should first obtain a global
lock, otherwise other thread may dispose the native component's data.

In Win32SurfaceData_GetWindow() we call Win32SurfaceData_GetComp()
which retrieves a pointer to AwtComponent from the peer object,
and this pointer is then used to get the insets. A thread
could dispose the native data at any time since we don't
hold any locks, and we'll die when dereferencing.
Posted Date : 2006-12-27 21:52:17.0
Comments
  
  Include a link with my name & email   

Submitted On 18-APR-2006
doobnet
I have got this bug on every applet I have tested to compile and run. I have a single  CPU computer and running jdk 1.5 and eclipse 3.1.1. I only get it the first time I run it after I changed anything in the code. And I can very easy reproduce the bug with minimal code.


Submitted On 19-APR-2006
dmitri_trembovetski
Could you please try this on the latest mustang (Java 6) build from http://mustang.dev.java.net ?

This bug appears to have been fixed in mustang b62.

Thank you,
  Dmitri
Java2D Team


Submitted On 07-DEC-2006
Mustafa_KIRAC@CWRI
I was having the same problem with JDK 1.5 (with all updates including 10th) on machines with dual-core CPUs. I am using JDK 1.6 RC, and it seems that the bug is fixed now.

Mustafa Kirac.


Submitted On 06-FEB-2007
Is this bug fixed at all?  It occurs all the time when I dispose of an applet properly. here are my stats:

Eclipse SDK

Version: 3.2.1
Build id: M20060921-0945

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: component argument pData
	at sun.awt.windows.Win32SurfaceData.initOps(Native Method)
	at sun.awt.windows.Win32SurfaceData.<init>(Unknown Source)
	at sun.awt.windows.Win32SurfaceData.createData(Unknown Source)
	at sun.awt.Win32GraphicsConfig.createSurfaceData(Unknown Source)
	at sun.awt.windows.WComponentPeer.replaceSurfaceData(Unknown Source)
	at sun.awt.windows.WComponentPeer.replaceSurfaceData(Unknown Source)
	at sun.awt.windows.WComponentPeer$2.run(Unknown Source)
	at java.awt.event.InvocationEvent.dispatch(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)


Submitted On 06-FEB-2007
Sorry, my e-mail didn't show up.  It is posted above.


Submitted On 06-FEB-2007
heh, nice.  Ok, here it is:
joseph.st.onge@concurrenteda.com


Submitted On 09-MAR-2007
Here is some code from an Applet that reproduce this Bug very often:

package de.schmiereck.geneden;

import java.applet.Applet;
/*
 * Created on 05.03.2007, Copyright (c) schmiereck, 2007
 */
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.HeadlessException;
import java.awt.Image;
import java.util.Iterator;
import java.util.Random;

/**
 * <p>
 * 	Main-Applet-View.
 * </p>
 * 
 * @author smk
 * @version <p>05.03.2007:	created, smk</p>
 */
public class MainApplet
	extends Applet
{
	private Image      	dbImage		= null;
	private Graphics   	dbGraphics	= null;
	private Dimension	dbDimension = null;

	private Color backgroundColor		= Color.BLACK;
	private Color areaColor				= new Color(0, 0, 0);
	private Color springColor			= new Color(0, 200, 0);
	private Color bottomColor			= new Color(155, 55, 155);
	
	/**
	 * Main-Model.
	 */
	private MainModel mainModel;

	/**
	 * Main-Controller 
	 * zum Benachrichtigen bei Eingaben des Users.
	 */
	private MainController mainController;
	
	/**
	 * Breite der Zeichen-Area.
	 */
	private int	maxX = 0;
	
	/**
	 * Höhe der Zeichen-Area.
	 */
	private int	maxY = 0;

	private Random rnd = new Random();
	
	private Color[]	messengerColors = new Color[]
	{
		new Color(255, 0, 0),	
		new Color(0, 255, 0),	
		new Color(0, 0, 255)	
	};
	
	/**
	 * Constructor.
	 * 
	 */
	public MainApplet()
		throws HeadlessException
	{
		this.mainModel = new MainModel();
		
		this.mainController = new MainController(this.mainModel,
		                                         this);
	}
	
	/* (non-Javadoc)
	 * @see java.applet.Applet#init()
	 */
	public void init()
	{
		super.init();

		this.setSize(640, 320);
	}

	/* (non-Javadoc)
	 * @see java.awt.Component#update(java.awt.Graphics)
	 */
	public void update(Graphics g)
	{
		// Um zu verhindern, das er den Hintergrund zeichnet,
		// nicht super() aufrufen, sondern direkt paint().
		//super.update(arg0);
		
		Dimension d = this.getSize();
    	
			// Double-Buffer nicht initialisiert oder
			// Größe geändert ?
		if ((this.dbImage == null) || 
			(d.width != this.dbDimension.width) ||
			(d.height != this.dbDimension.height))
		{
			// Create the offscreen graphics context
			this.dbDimension = d;
			this.dbImage = this.createImage(d.width, d.height);
			this.dbGraphics = this.dbImage.getGraphics();
			
			this.dbGraphics.setColor(this.areaColor);
			this.dbGraphics.fillRect(0, 0, d.width, d.height);
			//this.viewerData.setSize(d.width, d.height);

			this.maxX = this.getSize().width - this.getInsets().left - this.getInsets().right;
			this.maxY = this.getSize().height - this.getInsets().top - this.getInsets().bottom;
		}

		// Erase the previous image
		this.dbGraphics.setColor(this.backgroundColor);
		this.dbGraphics.fillRect(0, 0, d.width, d.height);
		
			// Offscreen Zeichnen.
		this.paintFrame(this.dbGraphics);

		// Puffer auf dem Screen anzeigen.
		g.drawImage(this.dbImage, 0, 0, this);
		
		//this.paint(g);
	}
	/**
	 * @param g
	 * 			ist das Grafik Objekt.
	 */
	private void paintFrame(Graphics g)
	{
		//==========================================================================================
		// Bottom: 
		
		g.setColor(this.bottomColor);
		
		this.drawLine(g,
		              (int)0, (int)this.mainModel.getBottomPosY(), 
		              (int)this.maxX, (int)this.mainModel.getBottomPosY());
		
	}

	/* (non-Javadoc)
	 * @see java.awt.Component#paint(java.awt.Graphics)
	 */
	synchronized public void paint(Graphics g)
	{
		super.paint(g);
		
		if (this.dbImage != null)
		{
			//int maxX = getSize().width - getInsets().left - getInsets().right;
			//int maxY = getSize().height - getInsets().top - getInsets().bottom;

			// Offscreen anzeigen.
			g.drawImage(this.dbImage, 
			            0, 0, 
			            this);
		}
	}

}


Submitted On 10-APR-2007
java 1.6.0_01
and i have dual cpu

F:\java>appletviewer ScrollingSimple.html
initializing...
starting...
stopping...
preparing for unloading...
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: component
 argument pData
        at sun.awt.windows.Win32SurfaceData.initOps(Native Method)
        at sun.awt.windows.Win32SurfaceData.<init>(Win32SurfaceData.java:448)
        at sun.awt.windows.Win32SurfaceData.createData(Win32SurfaceData.java:316
)
        at sun.awt.Win32GraphicsConfig.createSurfaceData(Win32GraphicsConfig.jav
a:357)
        at sun.awt.windows.WComponentPeer.replaceSurfaceData(WComponentPeer.java
:332)
        at sun.awt.windows.WComponentPeer.replaceSurfaceData(WComponentPeer.java
:313)
        at sun.awt.windows.WComponentPeer$2.run(WComponentPeer.java:353)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchTh
read.java:242)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:163)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)

        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)

        at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)


Submitted On 15-MAY-2007
i m not catching what u wrote above.please write in easy


Submitted On 15-MAY-2007
I also got the same prb. .what to do please tell



Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: component argument pData
	at sun.awt.windows.Win32SurfaceData.initOps(Native Method)
	at sun.awt.windows.Win32SurfaceData.<init>(Win32SurfaceData.java:448)
	at sun.awt.windows.Win32SurfaceData.createData(Win32SurfaceData.java:316)
	at sun.awt.Win32GraphicsConfig.createSurfaceData(Win32GraphicsConfig.java:357)
	at sun.awt.windows.WComponentPeer.replaceSurfaceData(WComponentPeer.java:332)
	at sun.awt.windows.WComponentPeer.replaceSurfaceData(WComponentPeer.java:313)
	at sun.awt.windows.WComponentPeer$2.run(WComponentPeer.java:353)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
	at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)


Submitted On 15-MAY-2007
I also got the same prb. .what to do please tell



Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: component argument pData
	at sun.awt.windows.Win32SurfaceData.initOps(Native Method)
	at sun.awt.windows.Win32SurfaceData.<init>(Win32SurfaceData.java:448)
	at sun.awt.windows.Win32SurfaceData.createData(Win32SurfaceData.java:316)
	at sun.awt.Win32GraphicsConfig.createSurfaceData(Win32GraphicsConfig.java:357)
	at sun.awt.windows.WComponentPeer.replaceSurfaceData(WComponentPeer.java:332)
	at sun.awt.windows.WComponentPeer.replaceSurfaceData(WComponentPeer.java:313)
	at sun.awt.windows.WComponentPeer$2.run(WComponentPeer.java:353)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
	at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)


Thank you
Sushma


Submitted On 04-JUL-2007
naansoft
Get the same error here. I'm running Java version 1.5.0_11 from Eclipse 3.2.2 on an Intel Pentium 4HT, 2600 MHz (13 x 200) , using Windows XP SP2.


Submitted On 27-JAN-2008
xgme
Sorry I can not figure out how to fix this problem. Is there any one to tell the solution in a easier voice.


Submitted On 30-SEP-2009
The solution is easy: stop using Java for graphics and use Flash/Flex. 



PLEASE NOTE: JDK6 is formerly known as Project Mustang