gwt gwt反射java
欢迎, 我对“GWTENT”反射有问题
如何使用反射创建类
我试过这个:
try {
ClassType ct = TypeOracle.Instance.getClassType(Klient.class);
ct.invoke(null, "Klient", null);
} catch (ReflectionRequiredException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
`
给全班同学打电话:
package pl.cba.lukaszbaczek.client.Test;
import com.extjs.gxt.ui.client.widget.Window;
import com.google.gwt.user.client.Element;
import com.gwtent.reflection.client.Reflectable;
import com.gwtent.reflection.client.Reflection;
@Reflectable
public class Klient extends Window implements Reflection {
@Override
protected void onRender(Element parent, int index) {
super.onRender(parent, index);
setHeading("Klient");
setSize(600, 600);
}
public Klient(){
super();
show();
}
}
但由于错误而失败:
17:30:59.129 [ERROR] [makerbase] Uncaught exception escaped
com.gwtent.reflection.client.NotFoundException: Klient not found or unimplement?
# 1 楼答案
如果您在编译成javascript的客户端,则不能使用反射。你可以使用GWT。创建(Clazz.class),但必须在编译时知道类签名。这是javascript编译器的要求
下面是一个使用生成器进行反射的链接 Can you use Java Reflection api in GWT client