无法将org.eclipse.ui.internal.WorkbenchWindow转换为org.eclipse.jface.window.ApplicationWindow

时间:2015-07-17 09:07:51

标签: eclipse exception casting

当代码从Eclipse 3.x迁移到4.5 Mars,Java 6到Java 8时,就会发生这种情况。

尝试在此代码中转换为ApplicationWindow时抛出异常:

CoolItem[] coolbarItems = ((ApplicationWindow)getWindowConfigurer().getWindow()).getCoolBarManager().getControl().getItems();

例外:

!ENTRY org.eclipse.e4.ui.workbench.swt 4 2 2015-07-16 18:54:00.897

!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.e4.ui.workbench.swt". !STACK 0java.lang.**ClassCastException**: org.eclipse.ui.internal.**WorkbenchWindow cannot be cast to org.eclipse.jface.window.ApplicationWindow** at com.ApplicationWorkbenchWindowAdvisor.setElementPathToolBar(ApplicationWorkbenchWindowAdvisor.java:336) at 

1 个答案:

答案 0 :(得分:1)

Eclipse内部版本基本上是针对Eclipse 4重写的,@Entity(name = "A") @Table(name = "A") public class A { ??? Hibernate Annotation or query Map<B,List<C>> BMapC; } @Entity(name = "B") @Table(name = "B") public class B { ... } @Entity(name = "C") @Table(name = "C") public class C { ... } 不再来自WorkbenchWindow,因此您无法执行此操作。无论如何,这绝不是定义的API的一部分。

要让酷吧经理使用:

ApplicationWindow