我有一个无法解决的怪异问题。我的课如下:
public class I18nTextBox extends I18nAbstractTextBox<String> {
public I18nTextBox() {
this("", Consts.MAXL_BASIC);
}
public I18nTextBox(String keyTitle) {
this(keyTitle, Consts.MAXL_BASIC);
}
public I18nTextBox(String keyTitle, int maxLength, String ... substitutions) {
super(keyTitle, maxLength, substitutions);
}
// ...
}
其父类(super class)定义如下:public abstract class I18nAbstractTextBox<T> extends TextBox implements IRefreshableDisplay, IModelDataField<T> {
// some properties ...
public I18nAbstractTextBox() {
this("", Consts.MAXL_BASIC);
}
public I18nAbstractTextBox(String keyTitle) {
this(keyTitle, Consts.MAXL_BASIC);
}
public I18nAbstractTextBox(String keyTitle, int maxLength, String ... substitutions) {
// do some logic
}
//...
}
Eclipse不会显示任何编译器错误,但是,当我运行GWT的 Debug模式时,一旦它尝试加载应用程序,我便会得到整个的加载。每次我实例化第一个类时,构造函数I18nTextBox()都是未定义的错误(I18nTextBox
)。I18nTextBox
,但是我们把它抽象化并创建了I18nTextBox
来扩展它,因为我们需要一种特殊的类型类型,所以我知道该类可以独立工作。String ... substitutions
是可选参数,因此,如果未指定,则应默认为null。 public I18nTextBox(String keyTitle, int maxLength) {
this(keyTitle, maxLength, "");
}
然后,我修复了I18nTextBox
中的错误,但对于I18nIntegerTextBox
却获得了相同的错误,该错误的定义方式完全相同:public class I18nIntegerTextBox extends I18nAbstractTextBox<Integer> {
public I18nIntegerTextBox() {
this("", Consts.MAXL_BASIC);
}
public I18nIntegerTextBox(String keyTitle) {
this(keyTitle, Consts.MAXL_BASIC);
}
public I18nIntegerTextBox(String keyTitle, int maxLength) {
this(keyTitle, maxLength, "");
}
public I18nIntegerTextBox(String keyTitle, int maxLength, String ... substitutions) {
super(keyTitle, maxLength, substitutions);
}
// ...
}
所以我只是不明白出了什么问题!
最佳答案
好的,所以我们发现了问题。本质上,this()
调用使GWT编译器感到困惑。这不是javac错误,但是我有一种感觉,当GWT将Java转换为Javascript时,对于我们要指代的this()
(父类(super class)或子类)感到困惑。该错误有点神秘,所以我不确定,但是我将构造函数更改为全部调用super()
(但是有许多参数是合适的)。现在的代码如下所示:
public class I18nTextBox extends I18nAbstractTextBox<String> {
public I18nTextBox() {
super();
}
public I18nTextBox(String keyTitle) {
super(keyTitle);
}
public I18nTextBox(String keyTitle, int maxLength, String ... substitutions) {
super(keyTitle, maxLength, substitutions);
}
//...
}
https://stackoverflow.com/questions/17876581/
相关文章:
wpf - 当应用程序类型为类库时,未定义的CLR namespace
vba - Excel VBA : Compiler Errors
c++ - 使用 ANDROID NDK 在 Cplusplus 中调用 ffmpeg1.2.1 时
c++ - Googletest 编译错误 : ‘xyzTest’ was not declared
android - 使用二进制文字数字时出错。为什么要使用旧的JDK?
python - Python反转计数器: slice indicies error