为什么我们得到AssertionFailedError?

时间:2010-06-21 12:04:00

标签: java swt jface

我有以下代码:

        TableViewer tv = new TableViewer(attributeTable);
        tv.setContentProvider(new BOAttributeTableContentProvider());
        tv.setLabelProvider(new BOAttributeTableLabelProvider());

在设置标签提供者时,我得到AssertionFailedError。谁能告诉我我在这做什么错?或者在哪种情况下会引发此错误?

错误日志:

org.eclipse.jface.util.Assert$AssertionFailedException: null argument;
    at org.eclipse.jface.util.Assert.isNotNull(Assert.java:150)
    at org.eclipse.jface.util.Assert.isNotNull(Assert.java:126)
    at org.eclipse.jface.viewers.StructuredViewer.disassociate(StructuredViewer.java:615)
    at org.eclipse.jface.viewers.TableViewer.internalRefreshAll(TableViewer.java:904)
    at org.eclipse.jface.viewers.TableViewer.internalRefresh(TableViewer.java:818)
    at org.eclipse.jface.viewers.TableViewer.internalRefresh(TableViewer.java:807)
    at org.eclipse.jface.viewers.StructuredViewer$7.run(StructuredViewer.java:1388)
    at org.eclipse.jface.viewers.StructuredViewer.preservingSelection(StructuredViewer.java:1323)
    at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1386)
    at org.eclipse.jface.viewers.StructuredViewer.refresh(StructuredViewer.java:1345)
    at org.eclipse.jface.viewers.ContentViewer.setLabelProvider(ContentViewer.java:281)
    at org.eclipse.jface.viewers.StructuredViewer.setLabelProvider(StructuredViewer.java:2003)
    at org.eclipse.jface.viewers.TableViewer.setLabelProvider(TableViewer.java:1086)
    at com.misys.bankfusion.bpdesigner.boeditor.pages.BOAttributesPage.populateAttributeTableContents(BOAttributesPage.java:458)
    at com.misys.bankfusion.bpdesigner.boeditor.pages.BOAttributesPage.access$000(BOAttributesPage.java:128)
    at com.misys.bankfusion.bpdesigner.boeditor.pages.BOAttributesPage$1.setToModel(BOAttributesPage.java:341)
    at com.trapedza.bankfusion.editor.AbstractEditorDelegate.updateData(AbstractEditorDelegate.java:173)
    at com.trapedza.bankfusion.editor.AbstractEditorDelegate$1.dialogFieldChanged(AbstractEditorDelegate.java:181)
    at com.trapedza.bankfusion.utils.dialogs.internal.DialogField.dialogFieldChanged(DialogField.java:132)
    at com.trapedza.bankfusion.utils.dialogs.internal.ListBoxDialogField.doModifySelection(ListBoxDialogField.java:51)
    at com.trapedza.bankfusion.utils.dialogs.internal.ComboDialogField$2.widgetSelected(ComboDialogField.java:153)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:90)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3348)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2968)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1930)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1894)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:422)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95)
    at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
    at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
    at org.eclipse.core.launcher.Main.run(Main.java:977)
    at org.eclipse.core.launcher.Main.main(Main.java:952)

4 个答案:

答案 0 :(得分:2)

确保方法名称开头的“test”为小写。如果您说TestMethod,您将收到此错误消息。你应该说testMethod。

例如:

@Test
    public void test_VPlugin() throws Exception {

这对我有用,我希望它对你有用

答案 1 :(得分:0)

您正在使用的构造函数(TableViewer)或两个setter(setContentProvidersetLabelProvider)具有保护assert语句,这些语句会抛出这些异常。代码的作者有一个想法,保护其代码免受调用她/他的代码时使用的不规则参数。

答案 2 :(得分:0)

堆栈跟踪显示您从'BOAttributesPage.populateAttributeTableContents()'调用'TableViewer.setLabelProvider()'最终会调用'org .eclipse.jface.viewers.StructuredViewer.disassociate()'与 null 参数,该方法约束输入参数不是 - null

答案 3 :(得分:0)

看起来BOAttributeTableContentProvider在沿线的某处提供了一个空对象(您尝试在表中显示的元素之一为null)。 调试内容提供程序。希望我迟到的回答会有所帮助。