tags:

views:

466

answers:

2

GWT compiles the Java source into Javascript, and names the files according to a hash of their contents. I'm getting a new set of files every compile, because the javascript contents are changing, even when I don't change the source at all.

The files are different for OBF and PRETTY output, but if I set it to DETAILED, they're no longer different every compile. In PRETTY, I can see that all/most of the differences between compiles are in the value parameters for typeId. For example, a funciton called initValues() is called with different values for it's typeId parameter.

A: 

As far as I know, GWT will compile a new version every time you compile it, this is a feature ;)

You can use ant to control it though, so that it only builds the GWT section of your application if it's actually changed:

http://wiki.shiftyjelly.com/index.php/GWT#Use_The_Power_of_Ant_to_Build_Changes_Only

rustyshelf
My issue isn't that it's compiling every time, it's that the compiler output is different every time for the same source. This is directly against how GWT is stated to work, and removes the whole point of the strong-hash-named cache.html and cache.js files.
Steve Armstrong
Incidentally, we're already using Maven, and it's an interaction between the maven release process and a compile we do with GCJ that's bringing out this problem. I've got a workaround already in place but I want to know why GWT does this anyways.
Steve Armstrong
+1  A: 

In PRETTY mode, the differences you see are allocation of Java Classes to TypeIds. It's how GWT manages run time type checking. You'll notice a table at the bottom of each script essentially mapping each typeId to all compatible superclasses. This is how GWT can still throw ClassCastException in JavaScript (though you should run into this very rarely!).

In OBF mode, the differences are due to the allocation of minified function names.

In both cases, it's due to the order the compiler is processing the code. Some internal symbol tables might be using a non-ordered collection store symbols for processing. It can happen for lots of reasons.

Mark Renouf
So GWT just doesn't use a deterministic method for converting the classes into TypeIds? That makes sense with the differences I'm seeing (typeIds in both PRETTY and OBF, as the function names are the same), but it's surprising they wouldn't use a consistent method.
Steve Armstrong