简体   繁体   中英

GWT runtime Java emulation

I am interesting in GWT implementation JRE libraries emulation technology.

How GWT emulate Java library?

How effectively implemented HashMap in JavaScript? Is it implemented in pure JavaScript or it is compile as Java source if used in code?

I understand some implementation exists in gwt-dev library for development(hosted) mode. Is it same implementation for production code?

You can check what are the emulated JRE libraries here . For most of them GWT will use the JavaScript counterparts, but there are cases where GWT will have it's own JavaScript implementation version.

In HashMaps's case, since the build-in JavaScript versions offers only String->value map, GWT will use it's own implementation that will support Object->Object map. You can find some more details here .

Also to understand what are the differences between production (compiled) and development modes (debug), you can check Compile & Debug section.

You can browse the code online, eg HashMap , or more interestingly AbstractHashMap . As you can see, there are some JSNI methods (the ones with the native keyword, and the /*-{ ... }-*/ syntax). But many methods in the emulation code build on top of the JSNI methods: They are written as "higher level" Java methods.

This emulation code is really simply GWT code as you would write your own (but of course the percentage of JSNI code is higher, statistically). And it uses the <super-source> mechanism: This way, the client code for the same class can be different in production mode compared to development mode.

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