Final doesn't do much on classes or methods, since the compiler already detects when a method or class isn't overridden by anything else.
Final on fields and parameters however is effective, because it lets the compiler assume those fields aren't written after the first assignment, which means they can be constant-propagated and folded. -Ray On Thu, Jan 19, 2012 at 4:09 AM, John Tamplin <j...@google.com> wrote: > On Thu, Jan 19, 2012 at 4:41 AM, Alexander Orlov <alexander.or...@loxal.net> > wrote: >> >> In Java, Integer is an object and can be set to null whereas int is a >> primitive and cannot be set to null. >> >> In RequestFactory only the wrapped versions of primitives (= objects) are >> allowed. So you might use Boolean and Integer but not boolean and int. In >> GWT you can use both but does is affect the generated JavaScript code >> whether you use Integer or int? > > > Just like in Java, the primitive is more efficient than the object wrapper. > However, whenever you use them as a type parameter to a generic type, you > have to use the wrapper type. > > It might be possible to replace the object wrapper with the primitive in > some cases in the generated code, but I don't know if the compiler currently > does or under what circumstances. > >> >> In Java final is used to declare immutable values. Often it has a positive >> impact on the execution performance. Also the usage of final enforces good >> programming style (values cannot be reassigned which makes the code easier >> to comprehend & maintain). But which impact does the usage of final has on >> the generated JavaScript code? > > JS doesn't have an equivalent of final so it makes no direct difference in > the generated JS, but it could affect optimizations done by the compiler > which would lead to different generated code. > > -- > John A. Tamplin > Software Engineer (GWT), Google > > -- > http://groups.google.com/group/Google-Web-Toolkit-Contributors -- http://groups.google.com/group/Google-Web-Toolkit-Contributors