在我的gwt应用程序中,有人开发了一个使用java.beans.PropertyChangeSupport的模块。最近我开始使用该模块并在运行时获取导入java.beans无法解决错误。但应用程序运行良好。为什么我在gwt dev模式窗口中遇到编译器错误?有什么想法吗?
00:17:33.079 [ERROR] Errors in 'file:/D:/workspace/App/src/main/java/com/abc/def/client/extract/pojos/ClientData.java'
00:17:33.079 [ERROR] Line 3: The import java.beans cannot be resolved
00:17:33.079 [ERROR] Line 4: The import java.beans cannot be resolved
00:17:33.079 [ERROR] Line 11: PropertyChangeSupport cannot be resolved to a type
00:17:33.079 [ERROR] Line 14: PropertyChangeSupport cannot be resolved to a type
00:17:33.079 [ERROR] Line 14: PropertyChangeSupport cannot be resolved to a type
00:17:33.079 [ERROR] Line 17: PropertyChangeListener cannot be resolved to a type
00:17:33.079 [ERROR] Line 18: PropertyChangeSupport cannot be resolved to a type
00:17:33.079 [ERROR] Line 21: PropertyChangeListener cannot be resolved to a type
00:17:33.079 [ERROR] Line 22: PropertyChangeSupport cannot be resolved to a type
00:17:33.079 [ERROR] Line 25: PropertyChangeListener cannot be resolved to a type
00:17:33.079 [ERROR] Line 26: PropertyChangeSupport cannot be resolved to a type
00:17:33.079 [ERROR] Line 30: PropertyChangeListener cannot be resolved to a type
00:17:33.079 [ERROR] Line 31: PropertyChangeSupport cannot be resolved to a type
00:17:33.079 [ERROR] Line 36: PropertyChangeListener cannot be resolved to a type
00:17:33.079 [ERROR] Line 36: PropertyChangeSupport cannot be resolved to a type
答案 0 :(得分:2)
GWT仅实现subset of the JRE types。 DevMode工作的原因是它将Java源代码编译为系统的JRE类型,以获得更好的运行时性能。运行生产模式编译时,它使用gwt-user.jar
中com/google/gwt/emul/java/...
的文件。
通用反射与死代码剥离和多种形式的单片优化不兼容,因此GWT编译器不实现运行时反射。 GWT Generator system可以在编译时访问模块的整个类型系统,因此您可以实现足够的“静态”反射以满足您的需求。
如果您正在构建基于“状态包”的系统,您可能需要查看AutoBeans框架,该框架通过访问者模式提供轻量级属性反射。
答案 1 :(得分:2)