已加载 class 的类型不正确:预期 (org.eclipse.ui.menus.WorkbenchWindowControlContribution) 得到 (de.blub.menu.ToolbarContributionItem)

Loaded class is of incorrect type: expected(org.eclipse.ui.menus.WorkbenchWindowControlContribution) got (de.blub.menu.ToolbarContributionItem)

这是我在 plugin.xml 中的菜单贡献:

<menuContribution
        locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
    <dynamic
           class="de.blub.menu.ToolbarContributionItem"
           id="some.id">
         <visibleWhen checkEnabled="false">
            <!-- some conditions -->
         </visibleWhen>
    </dynamic>  
</menuContribution>

ToolBarContributionItem class 根据文档的要求扩展了 CompoudStatement:

The element provides a mechanism that will call back into the defined class to provide an IContributionItem to be shown when the menu or toolbar is built. The defined class must be a derivative of the org.eclipse.jface.action.ContributionItem base class. It can also use org.eclipse.ui.action.CompoundContributionItem and provide an implementation for the abstract getContributionItems method to provide a dynamic menu item.

public class ToolbarContributionItem extends CompoundContributionItem {
...

但我收到错误消息

!MESSAGE Loaded class is of incorrect type: expected(org.eclipse.ui.menus.WorkbenchWindowControlContribution) got (de.blub.menu.ToolbarContributionItem)
!STACK 0
java.lang.IllegalArgumentException: Loaded class is of incorrect type: expected(org.eclipse.ui.menus.WorkbenchWindowControlContribution) got (de.blub.menu.ToolbarContributionItem)
at org.eclipse.ui.internal.util.Util.safeLoadExecutableExtension(Util.java:713)

那么这里有什么问题?

文档有误,请参阅 Eclipse 错误 509635

class 必须扩展 org.eclipse.ui.menus.WorkbenchWindowControlContribution