我正在开发一个 Eclipse E4 RCP 应用程序,我使用依赖注入。
我注意到,当 postconstruct 中存在运行时异常时,我在控制台中看不到该异常(它被吞没了吗?)。我确实看到了一个无法注入该类的异常。
因此,例如以下代码:
@Creatable
@Singleton
public class OurClass {
@PostConstruct
public void postConstruct() {
System.out.println("PostConstruct Start");
throw new RuntimeException("Test");
}
}
public class OurPart {
@Inject
private OurClass ourClass;
}
给出以下输出:
PostConstruct Start
org.eclipse.e4.core.di.InjectionException: Unable to process "OurPart.ourClass": no actual value was found for the argument "OurClass".
at org.eclipse.e4.core.internal.di.InjectorImpl.reportUnresolvedArgument(InjectorImpl.java:392)
at org.eclipse.e4.core.internal.di.InjectorImpl.resolveRequestorArgs(InjectorImpl.java:383)
at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:100)
at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:318)
at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:240)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:161)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:102)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:71)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:53)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.processHierarchy(E4Workbench.java:170)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.init(E4Workbench.java:118)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.<init>(E4Workbench.java:69)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:302)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:132)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.equinox.internal.app.MainApplicationLauncher.run(MainApplicationLauncher.java:32)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:353)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
at org.eclipse.equinox.launcher.Main.main(Main.java:1414)
PostConstruct Start
有谁知道如何确保也显示运行时异常?