Buggy code:
} List commandDefinitions = new ArrayList ( ) ; commandDefinitions . addAll ( pluginCommandRegistry . getCommandDefinitions ( ) ) ; commandDefinitions . addAll ( preferenceCommandRegistry . getCommandDefinitions ( ) ) ; commandDefinitionsById = CommandDefinition . commandDefinitionsById ( commandDefinitions , false ) ; commandIdsByCategoryId = new HashMap ( ) ; HashSet categoryIdsReferencedByCommandDefinitions = new HashSet ( ) ; for ( Iterator iterator = commandDefinitionsById . values ( ) . iterator ( ) ; iterator . hasNext ( ) ; ) { ICommandDefinition commandDefinition = ( ( ICommandDefinition ) ( iterator . next ( ) ) ) ; String categoryId = commandDefinition . getCategoryId ( ) ; String name = commandDefinition . getName ( ) ; if ( ( ( name == null ) || ( ( name . length ( ) ) == 0 ) ) || ( ( categoryId != null ) && ( ! ( categoryDefinitionsById . containsKey ( categoryId ) ) ) ) ) iterator . remove ( ) ; else { String commandId = commandDefinition . getId ( ) ; Set commandIds = ( ( Set ) ( commandIdsByCategoryId . get ( categoryId ) ) ) ; if ( commandIds == null ) { commandIds = new HashSet ( ) ; commandIdsByCategoryId . put ( categoryId , commandIds ) ; } commandIds . add ( commandId ) ; categoryIdsReferencedByCommandDefinitions . add ( categoryId ) ; } } categoryDefinitionsById . keySet ( ) . retainAll ( categoryIdsReferencedByCommandDefinitions ) ; List keyConfigurationDefinitions = new ArrayList ( ) ; keyConfigurationDefinitions . addAll ( pluginCommandRegistry . getKeyConfigurationDefinitions ( ) ) ; keyConfigurationDefinitions . addAll ( preferenceCommandRegistry . getKeyConfigurationDefinitions ( ) ) ; keyConfigurationDefinitionsById = KeyConfigurationDefinition . keyConfigurationDefinitionsById ( keyConfigurationDefinitions , false ) ; for ( Iterator iterator = keyConfigurationDefinitionsById . values ( ) . iterator ( ) ; iterator . hasNext ( ) ; ) { IKeyConfigurationDefinition keyConfigurationDefinition = ( ( IKeyConfigurationDefinition ) ( iterator . next ( ) ) ) ; String name = keyConfigurationDefinition . getName ( ) ; if ( ( name == null ) || ( ( name . length ( ) ) == 0 ) ) iterator . remove ( ) ; } for ( Iterator iterator = keyConfigurationDefinitionsById . keySet ( ) . iterator ( ) ; iterator . hasNext ( ) ; ) if ( ! ( CommandManager . isKeyConfigurationDefinitionChildOf ( null , ( ( String ) ( iterator . next ( ) ) ) , keyConfigurationDefinitionsById ) ) ) iterator . remove ( ) ; List activeKeyConfigurationDefinitions = new ArrayList ( ) ; activeKeyConfigurationDefinitions . addAll ( pluginCommandRegistry . getActiveKeyConfigurationDefinitions ( ) ) ; activeKeyConfigurationDefinitions . addAll ( preferenceCommandRegistry . getActiveKeyConfigurationDefinitions ( ) ) ; String activeKeyConfigurationId = null ; if ( ! ( activeKeyConfigurationDefinitions . isEmpty ( ) ) ) { IActiveKeyConfigurationDefinition activeKeyConfigurationDefinition = ( ( IActiveKeyConfigurationDefinition ) ( activeKeyConfigurationDefinitions . get ( ( ( activeKeyConfigurationDefinitions . size ( ) ) - 1 ) ) ) ) ; activeKeyConfigurationId = activeKeyConfigurationDefinition . getKeyConfigurationId ( ) ; if ( ! ( keyConfigurationDefinitionsById . containsKey ( activeKeyConfigurationId ) ) ) activeKeyConfigurationId = null ; } IContextRegistry pluginContextRegistry = contextManager . getPluginContextRegistry ( ) ; IContextRegistry preferenceContextRegistry = contextManager . getPreferenceContextRegistry ( ) ; List contextDefinitions = new ArrayList ( ) ; contextDefinitions . addAll ( pluginContextRegistry . getContextDefinitions ( ) ) ; contextDefinitions . addAll ( preferenceContextRegistry . getContextDefinitions ( ) ) ; contextDefinitionsById = ContextDefinition . contextDefinitionsById ( contextDefinitions , false ) ; for ( Iterator iterator = contextDefinitionsById . values ( ) . iterator ( ) ; iterator . hasNext ( ) ; ) { IContextDefinition contextDefinition = ( ( IContextDefinition ) ( iterator . next ( ) ) ) ; String name = contextDefinition . getName ( ) ; if ( ( name == null ) || ( ( name . length ( ) ) == 0 ) ) iterator . remove ( ) ; } for ( Iterator iterator = contextDefinitionsById . keySet ( ) . iterator ( ) ; iterator . hasNext ( ) ; ) <START_BUG> if ( ! ( CommandManager . isContextDefinitionChildOf ( null , ( ( String ) ( iterator . next ( ) ) ) , contextDefinitionsById ) ) ) <END_BUG> iterator . remove ( ) ; List contextBindingDefinitions = new ArrayList ( ) ; contextBindingDefinitions . addAll ( pluginCommandRegistry . getContextBindingDefinitions ( ) ) ; contextBindingDefinitions . addAll ( preferenceCommandRegistry . getContextBindingDefinitions ( ) ) ; contextIdsByCommandId = new HashMap ( ) ; for ( Iterator iterator = contextBindingDefinitions . iterator ( ) ; iterator . hasNext ( ) ; ) { IContextBindingDefinition contextBindingDefinition = ( ( IContextBindingDefinition ) ( iterator . next ( ) ) ) ; String commandId = contextBindingDefinition . getCommandId ( ) ; String contextId = contextBindingDefinition . getContextId ( ) ; boolean validCommandId = commandDefinitionsById . containsKey ( commandId ) ; boolean validContextId = contextDefinitionsById . containsKey ( contextId ) ; if ( ( ! validCommandId ) || ( ! validContextId ) ) iterator . remove ( ) ; else { Set contextIds = ( ( Set ) ( contextIdsByCommandId . get ( commandId ) ) ) ; if ( contextIds == null ) { contextIds = new HashSet ( ) ; contextIdsByCommandId . put ( commandId , contextIds ) ; } contextIds . add ( contextId ) ; } } List imageBindingDefinitions = new ArrayList ( ) ; imageBindingDefinitions . addAll ( pluginCommandRegistry . getImageBindingDefinitions ( ) ) ; imageBindingDefinitions . addAll ( preferenceCommandRegistry . getImageBindingDefinitions ( ) ) ; for ( Iterator iterator = imageBindingDefinitions . iterator ( ) ; iterator . hasNext ( ) ; ) { IImageBindingDefinition imageBindingDefinition = ( ( IImageBindingDefinition ) ( iterator . next ( ) ) ) ; String commandId = imageBindingDefinition . getCommandId ( ) ; boolean validCommandId = ( commandId == null ) || ( commandDefinitionsById . containsKey ( commandId ) ) ; if ( ! validCommandId ) iterator . remove ( ) ;

Fix:
if ( ! ( ContextManager . isContextDefinitionChildOf ( null , ( ( String ) ( iterator . next ( ) ) ) , contextDefinitionsById ) ) )