Buggy code:
public class ContextAndHandlerManager implements IContextResolver { private final StatusLineContributionItem modeContributionItem = new StatusLineContributionItem ( "ModeContributionItem" ) ; private final IContextServiceListener contextServiceListener = new IContextServiceListener ( ) { public void contextServiceChanged ( IContextService contextService ) { } } ; private final IHandlerServiceListener handlerServiceListener = new IHandlerServiceListener ( ) { public void handlerServiceChanged ( IHandlerService handlerService ) { } } ; private final IPartListener partListener = new IPartListener ( ) { public void partActivated ( IWorkbenchPart workbenchPart ) { } public void partBroughtToTop ( IWorkbenchPart workbenchPart ) { } public void partClosed ( IWorkbenchPart workbenchPart ) { } public void partDeactivated ( IWorkbenchPart workbenchPart ) { } public void partOpened ( IWorkbenchPart workbenchPart ) { } } ; private final ShellListener shellListener = new ShellAdapter ( ) { public void shellActivated ( ShellEvent shellEvent ) { } public void shellDeactivated ( ShellEvent shellEvent ) { } } ; private final VerifyListener verifyListener = new VerifyListener ( ) { public void verifyText ( VerifyEvent verifyEvent ) { } } ; private AcceleratorMenu acceleratorMenu ; private IContextService activeWorkbenchPartContextService ; private IHandlerService activeWorkbenchPartHandlerService ; private WorkbenchWindow workbenchWindow ; private IContextService workbenchWindowContextService ; private IHandlerService workbenchWindowHandlerService ; private Map contextsByCommand ; public ContextAndHandlerManager ( WorkbenchWindow workbenchWindow ) { } private void contextServiceChanged ( ) { } private void handlerServiceChanged ( ) { } private void partEvent ( ) { } private void shellEvent ( ) { } private void clear ( ) { } private void pressed ( Stroke stroke , Event event ) { } private IHandler getHandler ( String command ) { } public void update ( ) { List contexts = new ArrayList ( ) ; if ( ( workbenchWindowContextService ) != null ) contexts . addAll ( workbenchWindowContextService . getContexts ( ) ) ; if ( ( activeWorkbenchPartContextService ) != null ) contexts . addAll ( activeWorkbenchPartContextService . getContexts ( ) ) ; SequenceMachine keyMachine = Manager . getInstance ( ) . getKeyMachine ( ) ; try { if ( ( contexts . size ( ) ) == 0 ) contexts . add ( DEFAULT_ACCELERATOR_SCOPE_ID ) ; <START_BUG> keyMachine . setScopes ( ( ( String [ ] ) ( contexts . toArray ( new String [ contexts . size ( ) ] ) ) ) ) ; <END_BUG> } catch ( IllegalArgumentException eIllegalArgument ) { System . err . println ( eIllegalArgument ) ; } Sequence mode = keyMachine . getMode ( ) ; List strokes = mode . getStrokes ( ) ; int size = strokes . size ( ) ; Map sequenceMapForMode = keyMachine . getSequenceMapForMode ( ) ; SortedSet strokeSetForMode = new TreeSet ( ) ; Iterator iterator = sequenceMapForMode . entrySet ( ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { Map . Entry entry = ( ( Map . Entry ) ( iterator . next ( ) ) ) ; Sequence sequence = ( ( Sequence ) ( entry . getKey ( ) ) ) ; String command = ( ( String ) ( entry . getValue ( ) ) ) ; if ( sequence . isChildOf ( mode , false ) ) { IHandler handler = getHandler ( command ) ; if ( handler != null ) strokeSetForMode . add ( sequence . getStrokes ( ) . get ( size ) ) ; } } iterator = strokeSetForMode . iterator ( ) ; int [ ] accelerators = new int [ strokeSetForMode . size ( ) ] ; int i = 0 ; while ( iterator . hasNext ( ) ) accelerators [ ( i ++ ) ] = ( ( Stroke ) ( iterator . next ( ) ) ) . getValue ( ) ; if ( ( ( acceleratorMenu ) == null ) || ( acceleratorMenu . isDisposed ( ) ) ) { Menu parent = workbenchWindow . getShell ( ) . getMenuBar ( ) ; if ( ( parent == null ) || ( ( parent . getItemCount ( ) ) < 1 ) ) return ; MenuItem parentItem = parent . getItem ( ( ( parent . getItemCount ( ) ) - 1 ) ) ; parent = parentItem . getMenu ( ) ; if ( ( acceleratorMenu ) != null ) acceleratorMenu . dispose ( ) ; acceleratorMenu = new AcceleratorMenu ( parent ) ; acceleratorMenu . addSelectionListener ( new SelectionAdapter ( ) { public void widgetSelected ( SelectionEvent selectionEvent ) { Event event = new Event ( ) ; event . item = selectionEvent . item ; event . detail = selectionEvent . detail ; event . x = selectionEvent . x ; event . y = selectionEvent . y ; event . width = selectionEvent . width ; event . height = selectionEvent . height ; event . stateMask = selectionEvent . stateMask ; event . doit = selectionEvent . doit ; event . data = selectionEvent . data ; event . display = selectionEvent . display ; event . time = selectionEvent . time ; event . widget = selectionEvent . widget ; pressed ( Stroke . create ( selectionEvent . detail ) , event ) ; } } ) ; } acceleratorMenu . setAccelerators ( accelerators ) ; if ( size == 0 ) acceleratorMenu . removeVerifyListener ( verifyListener ) ; else acceleratorMenu . addVerifyListener ( verifyListener ) ; ContextResolver . getInstance ( ) . setContextResolver ( this ) ; MenuManager menuManager = ( ( WorkbenchWindow ) ( workbenchWindow ) ) . getMenuManager ( ) ; menuManager . update ( TEXT ) ; } public boolean inContext ( String commandId ) { } void reset ( ) { } }

Fix:
keyMachine . setContexts ( ( ( String [ ] ) ( contexts . toArray ( new String [ contexts . size ( ) ] ) ) ) ) ;