GWT compiler question(s)

73 views
Skip to first unread message

David Vree

unread,
Nov 28, 2011, 10:11:13 AM11/28/11
to Google Web Toolkit
Is there any kind of a reference doc that shows what the GWT compiler
creates in Javascript for various kinds of Java code?

Specifically, I am curious what the GWT compiler generates for an
anonymous inner classes in Java?

Paul Robinson

unread,
Nov 28, 2011, 11:18:49 AM11/28/11
to google-we...@googlegroups.com
Compile in PRETTY mode, and then you can read the generated javascript.

David Vree

unread,
Nov 28, 2011, 5:15:59 PM11/28/11
to google-we...@googlegroups.com
Got it -- thanks.  Any way to get GWT to compile pretty in development mode?  I only found the switch for that in the UI for the GWT compiler in Eclipse...

Thomas Broyer

unread,
Nov 29, 2011, 5:32:29 AM11/29/11
to google-we...@googlegroups.com
DevMode does *not* compile; that's the whole point of it: it runs your Java code, directly in Java, in a Java VM, so you can use a standard Java debugger to debug it (set breakpoints, inspect variables, etc.)

András Csányi

unread,
Nov 29, 2011, 5:44:56 AM11/29/11
to google-we...@googlegroups.com

I'm asking the experts, it's possible to develop in dev mode with
netbeans? I would like to take the advantages of the debugging
mentioned by Thomas.

Thanks in advance!

--
- -
--  Csanyi Andras (Sayusi Ando)  -- http://sayusi.hu --
http://facebook.com/andras.csanyi
--  ""Trust in God and keep your gunpowder dry!" - Cromwell

Thomas Klöber

unread,
Nov 29, 2011, 5:55:39 AM11/29/11
to google-we...@googlegroups.com
Am 29.11.2011 11:44, schrieb Andr�s Cs�nyi:
> On 29 November 2011 11:32, Thomas Broyer<t.br...@gmail.com> wrote:
>> DevMode does *not* compile; that's the whole point of it: it runs your Java
>> code, directly in Java, in a Java VM, so you can use a standard Java
>> debugger to debug it (set breakpoints, inspect variables, etc.)
> I'm asking the experts, it's possible to develop in dev mode with
> netbeans? I would like to take the advantages of the debugging
> mentioned by Thomas.
yes, I do it all the time, you the gwt4nb plugin: gwt4nb.dev.java.net

--
Intelligent Communication Software Vertriebs GmbH
Firmensitz: Kistlerhof Str. 111, 81379 M�nchen
Registergericht: Amtsgericht M�nchen, HRB 88283
Gesch�ftsf�hrer: Albert Fuss

András Csányi

unread,
Nov 29, 2011, 5:58:28 AM11/29/11
to google-we...@googlegroups.com
On 29 November 2011 11:55, Thomas Klöber <klo...@ics.de> wrote:

> Am 29.11.2011 11:44, schrieb András Csányi:
>>
>> On 29 November 2011 11:32, Thomas Broyer<t.br...@gmail.com>  wrote:
>>>
>>> DevMode does *not* compile; that's the whole point of it: it runs your
>>> Java
>>> code, directly in Java, in a Java VM, so you can use a standard Java
>>> debugger to debug it (set breakpoints, inspect variables, etc.)
>>
>> I'm asking the experts, it's possible to develop in dev mode with
>> netbeans? I would like to take the advantages of the debugging
>> mentioned by Thomas.
>
> yes, I do it all the time, you the gwt4nb plugin: gwt4nb.dev.java.net

Thanks, it's great! :) I found it because I used google. But really
thank you and your patience! :)

David Vree

unread,
Nov 29, 2011, 8:42:10 AM11/29/11
to google-we...@googlegroups.com
That still blows my mind.  I get that Java code can be compiled into Javascript, but I don't get how Java code running in a JVM manipulates the DOM of a browser. It's like magic -- and I hate magic!

Alfredo Quiroga

unread,
Nov 29, 2011, 9:03:40 AM11/29/11
to google-we...@googlegroups.com
Not really magic. It goes something like this:

Dev Mode Server (Your environment) <=> Browser Plugin

<=> Is a socket bi-directional channel.

That's an over simplification, but the Browser Plugin receives JS which it typically evals and loads/executes in the browser. So the JS is interpreted in the browser. The java code is not injected there, but JS. So what is manipulating the DOM at the end of the day is JS.

Regards,

Alfredo

On Nov 29, 2011, at 8:42 AM, David Vree wrote:

That still blows my mind.  I get that Java code can be compiled into Javascript, but I don't get how Java code running in a JVM manipulates the DOM of a browser. It's like magic -- and I hate magic!

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/RU70V2arl24J.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Thomas Broyer

unread,
Nov 29, 2011, 9:08:32 AM11/29/11
to google-we...@googlegroups.com
There's no magic: http://code.google.com/webtoolkit/doc/latest/DevGuideCompilingAndDebugging.html#DevGuideDevMode

JSNI code (which obviously includes everything manipulating the DOM) is sent to the browser (from the DevMode java app –a.k.a. "code server"– to the Dev Plugin running in your browser) to be evaluated (as JavaScript), the browser then keeps references to these functions to call them later.
Every time your code calls one such JSNI method, the DevMode java app asks the browser Dev plugin to call the function; the result is sent back to the DevMode java app.
Similarly, when you call Java methods from your JSNI, or when there's an even in the browser that has to be routed to Java code, the Dev browser plugin asks the DevMode to run the code in Java; and he result is sent back to the Dev browser plugin.
JS objects ("extends JavaScriptObject") are kept in the browser and assigned a "client ID"; the DevMode java app only knows about their "client ID". Similarly, Java objects (most of your code) is kept on the Java side and the browser only sees "opaque" objects with a "server ID" assigned by the DevMode java app.
That way, JS code is run in the browser, and subject to browser bugs and features, and Java code runs in Java.

And what's great is that you can run the DevMode "code server" on one machine and the browser with the Dev plugin on another one, or within a VM; this allows to develop in, say, Linux, and test in DevMode in IE (on another machine or in VirtualBox).
AFAICT, the GWT team runs all the GWT unit tests in a bunch of browsers (Firefox, Safari, IE6/7/8/9, etc. on Linux, MacOSX, Windows; I don't exactly) using this "remote testing" recipe; automatically as part of their continuous build.

David Vree

unread,
Nov 29, 2011, 10:10:10 AM11/29/11
to google-we...@googlegroups.com
Wow -- that helps a lot.  Thanks. There must be a lot of technology in there to keep the two sides in sync wrt symbols, lines of code...various maps and such.

 I think I can also understand why the initial page refresh takes so long when the development server has just started. 

Is there is a way to see the Javascript being sent to the browser when running in development mode?

Alfredo Quiroga-Villamil

unread,
Nov 29, 2011, 10:22:59 AM11/29/11
to google-we...@googlegroups.com
You should be able to use wireshark. The port being used by Dev Mode and the Browser Plugin is the last number that appears in your URL when you are running in DEV mode. That if my memory serves me right.

Disclaimer: I haven't tried it this.

Regards,

Alfredo


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.

To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



--
Alfredo Quiroga-Villamil

AOL/Yahoo/Gmail/MSN IM:  lawwton


Thomas Klöber

unread,
Nov 29, 2011, 10:27:34 AM11/29/11
to google-we...@googlegroups.com
On Tue, Nov 29, 2011 at 10:10 AM, David Vree <david....@gmail.com> wrote:
Is there is a way to see the Javascript being sent to the browser when running in development mode?
if you user Firefox you can use Firebug to see all the Javascript Code loaded (makes things very slow though!)
-- 
Intelligent Communication Software Vertriebs GmbH
Firmensitz: Kistlerhof Str. 111, 81379 München
Registergericht: Amtsgericht München, HRB 88283
Geschäftsführer: Albert Fuss

David Vree

unread,
Nov 29, 2011, 10:49:54 AM11/29/11
to google-we...@googlegroups.com, klo...@ics.de
Thanks.  Will check that out.

András Csányi

unread,
Dec 9, 2011, 5:45:40 AM12/9/11
to google-we...@googlegroups.com
On 29 November 2011 11:55, Thomas Klöber <klo...@ics.de> wrote:
> Am 29.11.2011 11:44, schrieb András Csányi:
>
>> On 29 November 2011 11:32, Thomas Broyer<t.br...@gmail.com>  wrote:
>>>
>>> DevMode does *not* compile; that's the whole point of it: it runs your
>>> Java
>>> code, directly in Java, in a Java VM, so you can use a standard Java
>>> debugger to debug it (set breakpoints, inspect variables, etc.)
>>
>> I'm asking the experts, it's possible to develop in dev mode with
>> netbeans? I would like to take the advantages of the debugging
>> mentioned by Thomas.
>
> yes, I do it all the time, you the gwt4nb plugin: gwt4nb.dev.java.net

Thomas, may I ask how can you do it? I think I'm confused and a little
bit lost between the tools. May I get a short step-by-step description
how can do it? I'm appreciating your kind help!

Reply all
Reply to author
Forward
0 new messages