2011-02-09 20 views
0

在我的gwt應用程序中,有人開發了一個使用java.beans.PropertyChangeSupport的模塊。最近我已經開始使用該模塊,並得到運行時導入java.beans不能解決錯誤。但應用程序運行良好。爲什麼我在gwt dev模式窗口中收到編譯器錯誤?有任何想法嗎?GWT中的PropertyChangeSupport

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 

回答

2

AutoBeans BobV提到的是GWT的一個很棒的新功能,但是爲了使用它們,需要重構現有的代碼。如果您的應用程序已經使用PropertyChangeSupportgwtx項目提供了java.beans.PropertyChange*類的GWT仿真。

2

GWT只實現了subset of the JRE types。 DevMode的工作原理是,它將Java源代碼與系統的JRE類型進行編譯,以獲得更好的運行時性能。在運行生產模式編譯時,它使用的gwt-user.jar中的文件。

通用反射與死代碼剝離和許多形式的單片優化不兼容,所以GWT編譯器不實現運行時反射。 GWT Generator system可以在編譯時訪問模塊的整個類型系統,因此您可以實現足夠的「靜態」反射來滿足您的需求。

如果您正在構建基於「行包狀態」的系統,則可能需要查看AutoBeans框架,該框架通過訪問者模式提供輕量級屬性反射。