[gwt-contrib] Re: Fix initialization of non-final fields (issue1618807)

2011-12-23 Thread cromwellian


http://gwt-code-reviews.appspot.com/1618807/diff/1/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java
File dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java
(right):

http://gwt-code-reviews.appspot.com/1618807/diff/1/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java#newcode873
dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java:873:
// setup the default value, see Issue 380
LGTM. One TODO for future reference: I wonder if we could actually
tighten this up a bit, that is, if every possible constructor writes to
this field, then the default value isn't needed, since it will always be
written. This may be moot if the Closure Compiler handles it.

http://gwt-code-reviews.appspot.com/1618807/

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors


[gwt-contrib] Re: Fix initialization of non-final fields (issue1618807)

2011-12-23 Thread stephen . haberman

I wasn't sure where I should add tests for this; there is not a
GenerateJavaScriptASTTest, which is the first/only place I've looked for
so far.

http://gwt-code-reviews.appspot.com/1618807/

--
http://groups.google.com/group/Google-Web-Toolkit-Contributors


[gwt-contrib] Fix initialization of non-final fields (issue1618807)

2011-12-23 Thread stephen . haberman

Reviewers: cromwellian,



Please review this at http://gwt-code-reviews.appspot.com/1618807/

Affected files:
  M dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java


Index: dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java
diff --git  
a/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java  
b/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java
index  
b059bd8440f05e2c8193124d6a5565ff7e3ef192..91e991c77b1d725348d6d951eef448647692f4ce  
100644

--- a/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java
+++ b/dev/core/src/com/google/gwt/dev/jjs/impl/GenerateJavaScriptAST.java
@@ -829,10 +829,13 @@ public class GenerateJavaScriptAST {
   JsNameRef localRef = (JsNameRef) pop(); // localRef

   JVariable target = x.getVariableRef().getTarget();
-  if (target instanceof JField && ((JField)  
target).getLiteralInitializer() != null) {

-// Will initialize at top scope; no need to double-initialize.
-push(null);
-return;
+  if (target instanceof JField) {
+JField field = (JField) target;
+if (field.isFinal() && field.getLiteralInitializer() != null) {
+  // Will initialize at top scope; no need to double-initialize.
+  push(null);
+  return;
+}
   }

   JsBinaryOperation binOp =
@@ -863,8 +866,13 @@ public class GenerateJavaScriptAST {
 public void endVisit(JField x, Context ctx) {
   // if we need an initial value, create an assignment
   if (x.getLiteralInitializer() != null) {
-// setup the constant value
-accept(x.getLiteralInitializer());
+if (x.isFinal()) {
+  // setup the constant value
+  accept(x.getLiteralInitializer());
+} else {
+  // setup the default value, see Issue 380
+  accept(x.getType().getDefaultValue());
+}
   } else if (!x.hasInitializer() && x.getEnclosingType() !=  
program.getTypeJavaLangObject()) {

 // setup a default value
 accept(x.getType().getDefaultValue());


--
http://groups.google.com/group/Google-Web-Toolkit-Contributors


[gwt-contrib] ResourceOracleImpl.onRefresh Question

2011-12-23 Thread Joshb
Hi, I have a few questions surrounding ResourceOracleImpl.onRefresh. 
 Please excuse my ignorance in advance.

I have a rather large GWT project, with a lot of dependencies.  Currently, 
it takes approximately 20-30 seconds to refresh the browser (my machine is 
an i7 with 8GB of RAM).  It seems that the time is taken up traversing 
through the entire classpath each time I press refresh, and my question is 
why this is necessary.


   - Could the GPE theoretically listen for changes to the classpath and 
   update the resource oracle specifically when they change (eliminating the 
   need to refresh when browser-refresh is called)?
   - Theoretically, could the resourceOracle be instructed to only listen 
   to GWT based projects (some sort of whitelist)?
   
I recognize that perhaps some of these issues could have been avoided with 
better architecture on my part, but we have a pretty large application that 
isn't going to be refactored anytime soon.

Thanks for your time and consideration.  I hope this makes some sense,

Josh

-- 
http://groups.google.com/group/Google-Web-Toolkit-Contributors