Buggy code:
public class Menu extends Widget { NSMenu nsMenu ; int x ; int y ; int itemCount ; boolean hasLocation ; boolean visible ; MenuItem [ ] items ; MenuItem cascade ; MenuItem defaultItem ; Decorations parent ; public Menu ( Control parent ) { } public Menu ( Decorations parent , int style ) { } public Menu ( Menu parentMenu ) { } public Menu ( MenuItem parentItem ) { } static Control checkNull ( Control control ) { } static Menu checkNull ( Menu menu ) { } static MenuItem checkNull ( MenuItem item ) { } static int checkStyle ( int style ) { } void _setVisible ( boolean visible ) { if ( ( ( style ) & ( ( SWT . BAR ) | ( SWT . DROP_DOWN ) ) ) != 0 ) return ; TrayItem trayItem = display . currentTrayItem ; if ( ( trayItem != null ) && visible ) { trayItem . showMenu ( this ) ; return ; } if ( visible ) { Shell shell = getShell ( ) ; <START_BUG> NSWindow window = shell . window ; <END_BUG> NSPoint location = null ; if ( hasLocation ) { NSView topView = window . contentView ( ) ; Point shellCoord = display . map ( null , shell , new Point ( x , y ) ) ; location = new NSPoint ( ) ; float scaleFactor = window . userSpaceScaleFactor ( ) ; location . x = ( shellCoord . x ) * scaleFactor ; location . y = ( ( topView . frame ( ) . height ) - ( shellCoord . y ) ) * scaleFactor ; } else { location = window . mouseLocationOutsideOfEventStream ( ) ; } window . retain ( ) ; NSEvent nsEvent = NSEvent . otherEventWithType ( NSApplicationDefined , location , 0 , 0.0 , window . windowNumber ( ) , window . graphicsContext ( ) , ( ( short ) ( 0 ) ) , 0 , 0 ) ; NSMenu . popUpContextMenu ( nsMenu , nsEvent , shell . view ) ; window . release ( ) ; } else { nsMenu . cancelTracking ( ) ; } } public void addHelpListener ( HelpListener listener ) { } public void addMenuListener ( MenuListener listener ) { } void createHandle ( ) { } void createItem ( MenuItem item , int index ) { } void createWidget ( ) { } void deregister ( ) { } void destroyItem ( MenuItem item ) { } void fixMenus ( Decorations newParent ) { } public MenuItem getDefaultItem ( ) { } public boolean getEnabled ( ) { } public MenuItem getItem ( int index ) { } public int getItemCount ( ) { } public MenuItem [ ] getItems ( ) { } String getNameText ( ) { } public Decorations getParent ( ) { } public MenuItem getParentItem ( ) { } public Menu getParentMenu ( ) { } public Shell getShell ( ) { } public boolean getVisible ( ) { } public int indexOf ( MenuItem item ) { } public boolean isEnabled ( ) { } public boolean isVisible ( ) { } void menu_willHighlightItem ( int id , int sel , int menu , int itemID ) { } void menuNeedsUpdate ( int id , int sel , int menu ) { } void menuWillOpen ( int id , int sel , int menu ) { } void menuDidClose ( int id , int sel , int menu ) { } void register ( ) { } void releaseChildren ( boolean destroy ) { } void releaseHandle ( ) { } void releaseParent ( ) { } void releaseWidget ( ) { } public void removeHelpListener ( HelpListener listener ) { } public void removeMenuListener ( MenuListener listener ) { } void reskinChildren ( int flags ) { } public void setDefaultItem ( MenuItem item ) { } public void setEnabled ( boolean enabled ) { } public void setLocation ( int x , int y ) { } public void setLocation ( Point location ) { } public void setVisible ( boolean visible ) { } }

Fix:
NSWindow window = shell . view . window ( ) ;