Due to curiosity, I checked how autobeans
are generated. I found it uses sun.misc.ProxyGenerator
class to generate autobean
proxies
and that it uses reflections
. But I do not understand, how does it work on client-side. Are those methods that use reflections
compiled to javascript
? Does it mean that I can use reflections myself on the client?
Asked
Active
Viewed 80 times
0

Heisenberg
- 3,153
- 3
- 27
- 55
1 Answers
1
Proxy instances are only used on the server, in a real JVM, where reflection works. You are correct that GWT code cannot use general reflection.
To generate them on the client, a GWT Generator is used instead. This does all of the reflection while the GWT Compiler is still running, and so is in a real JVM, and creates new classes that implements your autobean interfaces and factories.
The com.google.web.bindery.autobean.gwt.rebind.AutoBeanGenerator
class is mostly responsible for this work, and the contents of the com.google.web.bindery.autobean.gwt.rebind.model
package (and, to a degree, com.google.web.bindery.autobean.shared
) assist in this work.

Colin Alworth
- 17,801
- 2
- 26
- 39
-
Thanks! Checked in debugger autobean implementation classes, they sure do not use proxies on the client! – Heisenberg Aug 12 '15 at 08:48