为什么GWT编辑器框架不支持数组作为args?

时间:2013-05-08 08:42:37

标签: arrays gwt

假设您要创建实现接口LeafValueEditor<int[]>的编辑器,如下所示:

class MyEditor implements LeafValueEditor<int[]> {
    @Override
    public void setValue(@NotNull int[] value) {

    }

    @NotNull
    @Override
    public int[] getValue() {
        return new int[0];
    }
}

如果您仍在使用GWT 2.4,则代码​​将在运行时因NPE而失败

Generator 'com.google.gwt.editor.rebind.SimpleBeanEditorDriverGenerator' threw an exception while rebinding 'HERE IS YOUR DRIVER CLASS' java.lang.NullPointerException: null
at com.google.gwt.editor.rebind.model.EditorModel.findBeanPropertyMethods(EditorModel.java:509)
at com.google.gwt.editor.rebind.model.EditorModel.createEditorData(EditorModel.java:407)
at com.google.gwt.editor.rebind.model.EditorModel.calculateEditorData(EditorModel.java:345)
at com.google.gwt.editor.rebind.model.EditorModel.<init>(EditorModel.java:237)

在GWT 2.5中情况稍好一些。编辑器框架将忽略驱动程序描述中具有此类数组args的编辑器。为什么GWT团队决定忽略问题而不是在此版本中解决问题?

我查看了EditorModel的源代码,在这种情况下,实现JArrayType支持并不是很难。但它真的很烦人,因为我需要为包装数组或使用java集合编写样板类。

0 个答案:

没有答案