Heisenberg
Heisenberg

Reputation: 3193

Google Web Toolkit Autobeans

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?

Upvotes: 0

Views: 107

Answers (1)

Colin Alworth
Colin Alworth

Reputation: 18346

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.

Upvotes: 1

Related Questions