简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM