Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 422830 - toString for @Data should not use reflection for GWT compatiblity
Summary: toString for @Data should not use reflection for GWT compatiblity
Status: CLOSED WONTFIX
Alias: None
Product: Xtend
Classification: Tools
Component: Core (show other bugs)
Version: 2.4.3   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard: v2.7
Keywords:
Depends on: 437498 437509
Blocks:
  Show dependency tree
 
Reported: 2013-11-29 04:38 EST by Max Berger CLA
Modified: 2015-09-04 09:35 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Max Berger CLA 2013-11-29 04:38:34 EST
when trying to use the @Data annotation in a GWT project the resulting code generates a toString method which uses toStringHelper. ToStringHelper uses reflection to generate a string, and uses threadlocal, both which are unavailable in gwt.

instead, tostring could manually list the fields -> the same way this is done in hashcode and equals; this would make it both slightly faster and GWT compatible.

Workaround: use @Data, but write a manual toString method.
Comment 1 Sven Efftinge CLA 2013-11-29 05:28:08 EST
Another workaround would be to build your own GWT compatible version of @Data.
Comment 2 Stefan Oehme CLA 2014-06-16 11:36:31 EDT
The new @ValueObject annotation will work without reflection in the toString method.
Comment 3 Stefan Oehme CLA 2014-06-18 03:42:56 EDT
We can't change this for @Data, since reflection is the only way to get at the superclass fields and @Data allows inheritance.

I have removed @GWTCompatible from @Data.
Comment 4 Norbert Sándor CLA 2015-09-04 09:35:35 EDT
Is it supported that @Data classes are inherited from non-@Data classes?
If not (which sounds logical) then a chainable toString() implementation may do the trick...