JDK-7130377 : [macosx] Adding Preferences menu results in NPE
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 7
  • Priority: P4
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: generic
  • CPU: generic
  • Submitted: 2012-01-16
  • Updated: 2012-03-26
  • Resolved: 2012-03-16
Related Reports
Relates :  
Description
The bug report is submitted here: http://mail.openjdk.java.net/pipermail/macosx-port-dev/2012-January/002217.html

2012-01-16 12:18:54.086 java[39364:c07] *** -[__NSArrayM
insertObject:atIndex:]: object cannot be nil
2012-01-16 12:18:54.095 java[39364:c07] (
	0   CoreFoundation                      0x00007fff889a2286
__exceptionPreprocess + 198
	1   libobjc.A.dylib                     0x00007fff90583d5e
objc_exception_throw + 43
	2   CoreFoundation                      0x00007fff88949108
-[__NSArrayM insertObject:atIndex:] + 296
	3   AppKit                              0x00007fff8ad1a109 -[NSMenu
insertItem:atIndex:] + 478
	4   liblwawt.dylib                      0x00000001110bac14 addMenuItem + 185
	5   liblwawt.dylib                      0x00000001110ba905
-[ApplicationDelegate _updatePreferencesMenu:enabled:] + 211
	6   liblwawt.dylib                      0x00000001110baee1
__Java_com_apple_eawt__1AppMenuBarHandler_nativeSetMenuState_block_invoke_1
+ 227
	7   JavaNativeFoundation                0x00000001100855fd
+[JNFRunLoop _performCopiedBlock:] + 20
	8   CoreFoundation                      0x00007fff889cc0cd +[NSObject
performSelector:withObject:] + 61
	9   Foundation                          0x00007fff8e225e44
__NSThreadPerformPerform + 214
	10  CoreFoundation                      0x00007fff88910b51
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
	11  CoreFoundation                      0x00007fff889103bd
__CFRunLoopDoSources0 + 253
	12  CoreFoundation                      0x00007fff889371a9 __CFRunLoopRun + 905
	13  CoreFoundation                      0x00007fff88936ae6
CFRunLoopRunSpecific + 230
	14  HIToolbox                           0x00007fff89e493d3
RunCurrentEventLoopInMode + 277
	15  HIToolbox                           0x00007fff89e5063d
ReceiveNextEventCommon + 355
	16  HIToolbox                           0x00007fff89e504ca
BlockUntilNextEventMatchingListInMode + 62
	17  AppKit                              0x00007fff8ad033f1 _DPSNextEvent + 659
	18  AppKit                              0x00007fff8ad02cf5
-[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 135
	19  libosxapp.dylib                     0x0000000110e1b82c
-[NSApplicationAWT nextEventMatchingMask:untilDate:inMode:dequeue:] +
124
	20  AppKit                              0x00007fff8acff62d
-[NSApplication run] + 470
	21  libosxapp.dylib                     0x0000000110e1b74b
+[NSApplicationAWT runAWTLoopWithApp:] + 156
	22  liblwawt.dylib                      0x00000001110b8dad
-[AWTStarter starter:] + 1616
	23  CoreFoundation                      0x00007fff88991a1d -[NSObject
performSelector:withObject:] + 61
	24  Foundation                          0x00007fff8e225e44
__NSThreadPerformPerform + 214
	25  CoreFoundation                      0x00007fff88910b51
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
	26  CoreFoundation                      0x00007fff889103bd
__CFRunLoopDoSources0 + 253
	27  CoreFoundation                      0x00007fff889371a9 __CFRunLoopRun + 905
	28  CoreFoundation                      0x00007fff88936ae6
CFRunLoopRunSpecific + 230
	29  java                                0x000000010aee7cb4
CreateExecutionEnvironment + 841
	30  java                                0x000000010aee57b8 JLI_Launch + 1933
	31  java                                0x000000010aee9a30 main + 108
	32  java                                0x000000010aee33f4 start + 52
	33  ???                                 0x0000000000000011 0x0 + 17
)
2012-01-16 12:18:54.096 java[39364:c07] *** -[__NSArrayM
insertObject:atIndex:]: object cannot be nil
2012-01-16 12:18:54.097 java[39364:c07] (
	0   CoreFoundation                      0x00007fff889a2286
__exceptionPreprocess + 198
	1   libobjc.A.dylib                     0x00007fff90583d5e
objc_exception_throw + 43
	2   CoreFoundation                      0x00007fff88949108
-[__NSArrayM insertObject:atIndex:] + 296
	3   AppKit                              0x00007fff8ad1a109 -[NSMenu
insertItem:atIndex:] + 478
	4   liblwawt.dylib                      0x00000001110bac14 addMenuItem + 185
	5   liblwawt.dylib                      0x00000001110ba905
-[ApplicationDelegate _updatePreferencesMenu:enabled:] + 211
	6   liblwawt.dylib                      0x00000001110baee1
__Java_com_apple_eawt__1AppMenuBarHandler_nativeSetMenuState_block_invoke_1
+ 227
	7   JavaNativeFoundation                0x00000001100855fd
+[JNFRunLoop _performCopiedBlock:] + 20
	8   CoreFoundation                      0x00007fff889cc0cd +[NSObject
performSelector:withObject:] + 61
	9   Foundation                          0x00007fff8e225e44
__NSThreadPerformPerform + 214
	10  CoreFoundation                      0x00007fff88910b51
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
	11  CoreFoundation                      0x00007fff889103bd
__CFRunLoopDoSources0 + 253
	12  CoreFoundation                      0x00007fff889371a9 __CFRunLoopRun + 905
	13  CoreFoundation                      0x00007fff88936ae6
CFRunLoopRunSpecific + 230
	14  HIToolbox                           0x00007fff89e493d3
RunCurrentEventLoopInMode + 277
	15  HIToolbox                           0x00007fff89e5058f
ReceiveNextEventCommon + 181
	16  HIToolbox                           0x00007fff89e504ca
BlockUntilNextEventMatchingListInMode + 62
	17  AppKit                              0x00007fff8ad033f1 _DPSNextEvent + 659
	18  AppKit                              0x00007fff8ad02cf5
-[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 135
	19  libosxapp.dylib                     0x0000000110e1b82c
-[NSApplicationAWT nextEventMatchingMask:untilDate:inMode:dequeue:] +
124
	20  AppKit                              0x00007fff8acff62d
-[NSApplication run] + 470
	21  libosxapp.dylib                     0x0000000110e1b74b
+[NSApplicationAWT runAWTLoopWithApp:] + 156
	22  liblwawt.dylib                      0x00000001110b8dad
-[AWTStarter starter:] + 1616
	23  CoreFoundation                      0x00007fff88991a1d -[NSObject
performSelector:withObject:] + 61
	24  Foundation                          0x00007fff8e225e44
__NSThreadPerformPerform + 214
	25  CoreFoundation                      0x00007fff88910b51
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
	26  CoreFoundation                      0x00007fff889103bd
__CFRunLoopDoSources0 + 253
	27  CoreFoundation                      0x00007fff889371a9 __CFRunLoopRun + 905
	28  CoreFoundation                      0x00007fff88936ae6
CFRunLoopRunSpecific + 230
	29  java                                0x000000010aee7cb4
CreateExecutionEnvironment + 841
	30  java                                0x000000010aee57b8 JLI_Launch + 1933
	31  java                                0x000000010aee9a30 main + 108
	32  java                                0x000000010aee33f4 start + 52
	33  ???                                 0x0000000000000011 0x0 + 17
)

Comments
EVALUATION The following code looks suspicious in ApplicationDelegate.m: if ([self.fPreferencesMenu menu] == nil) { // Position of Prefs depends upon About availability. NSInteger index = ([self.fAboutMenu menu] != nil) ? 2 : 0; addMenuItem(self.fPreferencesMenu, index); } It looks like the addMenuItem() may be invoked with the self.fPreferencesMenu == nil, which in turn causes the issue. It needs to be investigated whether self.fPreferencesMenu is allowed to be nil in general, as well as whether we should call addMenuItem() in this case.
16-01-2012