United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: 7142780 [macosx] Font2DTest demo throws NPE
7142780 : [macosx] Font2DTest demo throws NPE

Details
Type:
Bug
Submit Date:
2012-02-05
Status:
Closed
Updated Date:
2012-10-01
Project Name:
JDK
Resolved Date:
2012-03-13
Component:
client-libs
OS:
os_x
Sub-Component:
2d
CPU:
x86,generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
7u4
Fixed Versions:
7u4

Related Reports
Duplicate:

Sub Tasks

Description
JDK 7 Font2DTest demo throws NPE on MacOSX when being interacted with 

Test Configuration
------------------
    * OS: iMac 11.2 Mack OS X 10.7.2 - Intel Core i3
    * jdk build: jdk7u4-mac- b227
    * Font2DTest demo 

Steps to reproduce
------------------
0)  Getting 7u4-b227
2) Launch the Font2DTest demo as
/bin/java -jar Font2DTest.jar
3) Click on any character, simple, or number cells in the default display table 

If you see the following NPE repeatedly thrown, then the issue is reproducible.
(the problem seems to occur since b224)


/1.7.0.jdk/Contents/Home/bin/java -jar Font2DTest.jar
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at sun.lwawt.macosx.CCustomCursor.getImageData(CCustomCursor.java:123)
	at sun.lwawt.macosx.CCursorManager.setCursor(CCursorManager.java:75)
	at sun.lwawt.LWCursorManager.updateCursorImpl(LWCursorManager.java:104)
	at sun.lwawt.LWCursorManager.updateCursor(LWCursorManager.java:54)
	at sun.lwawt.LWComponentPeer.updateCursorImmediately(LWComponentPeer.java:873)
	at java.awt.Component.updateCursorImmediately(Component.java:3120)
	at java.awt.Component.setCursor(Component.java:3104)
	at FontPanel$FontCanvas.mousePressed(FontPanel.java:1201)
	at java.awt.Component.processMouseEvent(Component.java:6502)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
	at java.awt.Component.processEvent(Component.java:6270)
	at java.awt.Container.processEvent(Container.java:2229)
	at java.awt.Component.dispatchEventImpl(Component.java:4861)
	at java.awt.Container.dispatchEventImpl(Container.java:2287)
	at java.awt.Component.dispatchEvent(Component.java:4687)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4489)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
	at java.awt.Container.dispatchEventImpl(Container.java:2273)
	at java.awt.Window.dispatchEventImpl(Window.java:2713)
	at java.awt.Component.dispatchEvent(Component.java:4687)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:703)
	at java.awt.EventQueue.access$000(EventQueue.java:102)
	at java.awt.EventQueue$3.run(EventQueue.java:662)
	at java.awt.EventQueue$3.run(EventQueue.java:660)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
	at java.awt.EventQueue$4.run(EventQueue.java:676)
	at java.awt.EventQueue$4.run(EventQueue.java:674)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:673)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at sun.lwawt.macosx.CCustomCursor.getImageData(CCustomCursor.java:123)
	at sun.lwawt.macosx.CCursorManager.setCursor(CCursorManager.java:75)
	at sun.lwawt.LWCursorManager.updateCursorImpl(LWCursorManager.java:104)
	at sun.lwawt.LWCursorManager.updateCursor(LWCursorManager.java:54)
	at sun.lwawt.LWComponentPeer.updateCursorImmediately(LWComponentPeer.java:873)
	at java.awt.Component.updateCursorImmediately(Component.java:3123)
	at java.awt.Container.validate(Container.java:1635)
	at java.awt.Window.dispatchEventImpl(Window.java:2711)
	at java.awt.Component.dispatchEvent(Component.java:4687)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:703)
	at java.awt.EventQueue.access$000(EventQueue.java:102)
	at java.awt.EventQueue$3.run(EventQueue.java:662)
	at java.awt.EventQueue$3.run(EventQueue.java:660)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
	at java.awt.EventQueue$4.run(EventQueue.java:676)
	at java.awt.EventQueue$4.run(EventQueue.java:674)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:673)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at sun.lwawt.macosx.CCustomCursor.getImageData(CCustomCursor.java:123)
	at sun.lwawt.macosx.CCursorManager.setCursor(CCursorManager.java:75)
	at sun.lwawt.LWCursorManager.updateCursorImpl(LWCursorManager.java:104)
	at sun.lwawt.LWCursorManager.updateCursor(LWCursorManager.java:54)
	at sun.lwawt.LWComponentPeer.updateCursorImmediately(LWComponentPeer.java:873)
	at java.awt.Component.updateCursorImmediately(Component.java:3120)
	at java.awt.Container.validate(Container.java:1635)
	at javax.swing.RepaintManager.validateInvalidComponents(RepaintManager.java:653)
	at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1620)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:701)
	at java.awt.EventQueue.access$000(EventQueue.java:102)
	at java.awt.EventQueue$3.run(EventQueue.java:662)
	at java.awt.EventQueue$3.run(EventQueue.java:660)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:671)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at sun.lwawt.macosx.CCustomCursor.getImageData(CCustomCursor.java:123)
	at sun.lwawt.macosx.CCursorManager.setCursor(CCursorManager.java:75)
	at sun.lwawt.LWCursorManager.updateCursorImpl(LWCursorManager.java:104)
	at sun.lwawt.LWCursorManager.updateCursor(LWCursorManager.java:54)
	at sun.lwawt.LWCursorManager$1.run(LWCursorManager.java:69)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:701)
	at java.awt.EventQueue.access$000(EventQueue.java:102)
	at java.awt.EventQueue$3.run(EventQueue.java:662)
	at java.awt.EventQueue$3.run(EventQueue.java:660)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
	at java.awt.EventQueue$4.run(EventQueue.java:676)
	at java.awt.EventQueue$4.run(EventQueue.java:674)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:673)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at sun.lwawt.macosx.CCustomCursor.getImageData(CCustomCursor.java:123)
	at sun.lwawt.macosx.CCursorManager.setCursor(CCursorManager.java:75)
	at sun.lwawt.LWCursorManager.updateCursorImpl(LWCursorManager.java:104)
	at sun.lwawt.LWCursorManager.updateCursor(LWCursorManager.java:54)
	at sun.lwawt.LWComponentPeer.updateCursorImmediately(LWComponentPeer.java:873)
	at java.awt.Component.updateCursorImmediately(Component.java:3123)
	at java.awt.Component.hide(Component.java:1696)
	at java.awt.Window.hide(Window.java:1115)
	at FontPanel$FontCanvas.mouseReleased(FontPanel.java:1211)
	at java.awt.Component.processMouseEvent(Component.java:6505)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
	at java.awt.Component.processEvent(Component.java:6270)
	at java.awt.Container.processEvent(Container.java:2229)
	at java.awt.Component.dispatchEventImpl(Component.java:4861)
	at java.awt.Container.dispatchEventImpl(Container.java:2287)
	at java.awt.Component.dispatchEvent(Component.java:4687)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
	at java.awt.Container.dispatchEventImpl(Container.java:2273)
	at java.awt.Window.dispatchEventImpl(Window.java:2713)
	at java.awt.Component.dispatchEvent(Component.java:4687)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:703)
	at java.awt.EventQueue.access$000(EventQueue.java:102)
	at java.awt.EventQueue$3.run(EventQueue.java:662)
	at java.awt.EventQueue$3.run(EventQueue.java:660)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
	at java.awt.EventQueue$4.run(EventQueue.java:676)
	at java.awt.EventQueue$4.run(EventQueue.java:674)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:673)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at sun.lwawt.macosx.CCustomCursor.getImageData(CCustomCursor.java:123)
	at sun.lwawt.macosx.CCursorManager.setCursor(CCursorManager.java:75)
	at sun.lwawt.LWCursorManager.updateCursorImpl(LWCursorManager.java:104)
	at sun.lwawt.LWCursorManager.updateCursor(LWCursorManager.java:54)
	at sun.lwawt.LWCursorManager$1.run(LWCursorManager.java:69)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:701)
	at java.awt.EventQueue.access$000(EventQueue.java:102)
	at java.awt.EventQueue$3.run(EventQueue.java:662)
	at java.awt.EventQueue$3.run(EventQueue.java:660)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
	at java.awt.EventQueue$4.run(EventQueue.java:676)
	at java.awt.EventQueue$4.run(EventQueue.java:674)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:673)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at sun.lwawt.macosx.CCustomCursor.getImageData(CCustomCursor.java:123)
	at sun.lwawt.macosx.CCursorManager.setCursor(CCursorManager.java:75)
	at sun.lwawt.LWCursorManager.updateCursorImpl(LWCursorManager.java:104)
	at sun.lwawt.LWCursorManager.updateCursor(LWCursorManager.java:54)
	at sun.lwawt.LWCursorManager$1.run(LWCursorManager.java:69)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:701)
	at java.awt.EventQueue.access$000(EventQueue.java:102)
	at java.awt.EventQueue$3.run(EventQueue.java:662)
	at java.awt.EventQueue$3.run(EventQueue.java:660)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
	at java.awt.EventQueue$4.run(EventQueue.java:676)
	at java.awt.EventQueue$4.run(EventQueue.java:674)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:673)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
	at sun.lwawt.macosx.CCustomCursor.getImageData(CCustomCursor.java:123)
	at sun.lwawt.macosx.CCursorManager.setCursor(CCursorManager.java:75)
	at sun.lwawt.LWCursorManager.updateCursorImpl(LWCursorManager.java:104)
	at sun.lwawt.LWCursorManager.updateCursor(LWCursorManager.java:54)
	at sun.lwawt.LWComponentPeer.updateCursorImmediately(LWComponentPeer.java:873)
	at java.awt.Component.updateCursorImmediately(Component.java:3123)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4426)
	at java.awt.Container.dispatchEventImpl(Container.java:2273)
	at java.awt.Window.dispatchEventImpl(Window.java:2713)
	at java.awt.Component.dispatchEvent(Component.java:4687)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:703)
	at java.awt.EventQueue.access$000(EventQueue.java:102)
	at java.awt.EventQueue$3.run(EventQueue.java:662)
	at java.awt.EventQueue$3.run(EventQueue.java:660)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
	at java.awt.EventQueue$4.run(EventQueue.java:676)
	at java.awt.EventQueue$4.run(EventQueue.java:674)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:673)
	at java.awt.EventD

                                    

Comments
EVALUATION

Note that Font2DTest creates a bogus image in order to get blank cursor
(FontPanel.java, lines 495 - 498). This image can not be loaded and triggers
an error when MediaTracker tries to prepare the image. As soon as the error
is detected, the conversion of toolkit image to CImage is aborted, and the
CImage.Creator.createFromImage returns null.

CCustomCursor.getImageData has to be modified in order to be able to handle
null result of the createFormImage call.

However, in order to prevent numerous calls to createFromImage in case of faulty
image, we can check the status of image loading in the constructor, and set a flag
to indicate whether given image can be used as a cursor.
                                     
2012-02-06
SUGGESTED FIX

http://hg.openjdk.java.net/jdk7u/jdk7u-dev/jdk/rev/4a7a52c2b731
                                     
2012-02-06



Hardware and Software, Engineered to Work Together