PropertyChangeSupport in GWT

1.1k views Asked by At

In my gwt application somebody developed a module which uses java.beans.PropertyChangeSupport. Recently I have started using that module and getting The import java.beans cannot be resolved error when I run. But application runs well. Why am I getting compiler error in gwt dev mode window? Any ideas?

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

There are 2 answers

0
morisil On BEST ANSWER

AutoBeans mentioned by BobV are great new feature of GWT, however refactoring of your existing code would be required in order to use them. If your application already uses PropertyChangeSupport, the gwtx project provides GWT emulation of java.beans.PropertyChange* classes.

0
BobV On

GWT only implements a subset of the JRE types. The reason that DevMode works is that it compiles your Java source against the system's JRE types for better runtime performance. When running the production-mode compile, it uses the files in gwt-user.jar at com/google/gwt/emul/java/....

General-purpose reflection is incompatible with dead-code stripping and many forms of monolithic optimization, so the GWT compiler doesn't implement runtime reflection. The GWT Generator system has access to the module's entire typesystem at compile-time, so you can implement enough "static" reflection to suit your needs.

If you're building a system based on "bags of state" you might want to look at the AutoBeans framework, which provides lightweight property reflection through a visitor pattern.