GWT 中的 PropertyChangeSupport
Posted
技术标签:
【中文标题】GWT 中的 PropertyChangeSupport【英文标题】:PropertyChangeSupport in GWT 【发布时间】:2011-02-09 10:56:43 【问题描述】:在我的 gwt 应用程序中,有人开发了一个使用 java.beans.PropertyChangeSupport 的模块。最近我开始使用该模块并在运行时收到 无法解析导入 java.beans 错误。但应用程序运行良好。为什么我在 gwt 开发模式窗口中出现编译器错误?有什么想法吗?
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
【问题讨论】:
【参考方案1】:BobV 提到的AutoBeans 是 GWT 的重要新功能,但是需要重构现有代码才能使用它们。如果您的应用程序已经使用PropertyChangeSupport
,则gwtx 项目提供java.beans.PropertyChange*
类的GWT 模拟。
【讨论】:
【参考方案2】:GWT 仅实现 subset of the JRE types。 DevMode 工作的原因是它根据系统的 JRE 类型编译 Java 源代码以获得更好的运行时性能。运行生产模式编译时,它使用gwt-user.jar
com/google/gwt/emul/java/...
中的文件。
通用反射与死代码剥离和许多形式的整体优化不兼容,因此 GWT 编译器不实现运行时反射。 GWT Generator system 可以在编译时访问模块的整个类型系统,因此您可以实现足够的“静态”反射来满足您的需求。
如果您正在构建基于“状态袋”的系统,您可能需要查看AutoBeans 框架,它通过访问者模式提供轻量级属性反射。
【讨论】:
以上是关于GWT 中的 PropertyChangeSupport的主要内容,如果未能解决你的问题,请参考以下文章