]> source.dussan.org Git - gwtquery.git/commitdiff
making reject and resolve helper classes public, so as they work in very nested funct...
authorManuel Carrasco Moñino <manuel.carrasco.m@gmail.com>
Wed, 24 Apr 2013 19:12:27 +0000 (21:12 +0200)
committerManuel Carrasco Moñino <manuel.carrasco.m@gmail.com>
Wed, 24 Apr 2013 19:12:27 +0000 (21:12 +0200)
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/Deferred.java
gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/deferred/FunctionDeferred.java
gwtquery-core/src/test/java/com/google/gwt/query/client/deferred/DeferredTest.java

index c804784f59ae8c0e7025dd0ecf0b95960791037a..402f3efbeabe42c49fdcb8a50bd1c78c6686ee2a 100644 (file)
@@ -104,7 +104,7 @@ public class Deferred implements Promise.Deferred {
      * }
      * </pre>
      */
-    protected Function resolve = new Function() {
+    public Function resolve = new Function() {
       public void f() {
         dfd.resolve(arguments);
       };
@@ -123,7 +123,7 @@ public class Deferred implements Promise.Deferred {
      * }
      * </pre>
      */
-    protected Function reject = new Function() {
+    public Function reject = new Function() {
       public void f() {
         dfd.reject(arguments);
       };
index f4ef1396fbcfaa2b32bba742acaf645077fe0603..3b40fdce52f9d36adc9e2f956b89e4a3a619ad75 100644 (file)
@@ -42,6 +42,7 @@ import com.google.gwt.query.client.Promise.Deferred;
 public abstract class FunctionDeferred extends Function {
   
   protected Deferred dfd;
+  public Function resolve, reject;
   
   /**
    * This function is called once the the previous promise in the
@@ -58,6 +59,8 @@ public abstract class FunctionDeferred extends Function {
   public final Object f(Object... args) {
     return new PromiseFunction() {
       public void f(Deferred dfd) {
+        FunctionDeferred.this.resolve = resolve;
+        FunctionDeferred.this.reject = reject;
         FunctionDeferred.this.dfd = dfd;
         FunctionDeferred.this.f(dfd);
       }
index 62e30fd7fbfcd5e30b1f02ea6ae26452ba9b3f5e..7620685621f4720acedb098fdb1b129f0b29c9d8 100644 (file)
@@ -231,4 +231,32 @@ public class DeferredTest extends GWTTestCase {
       });
   }
 
+
+  public void testProtected() {
+    delayTestFinish(20);
+    GQuery.when(new PromiseFunction() {
+      public void f(final Deferred dfd) {
+        GQuery.when(new Function() {
+          public void f() {
+            // This causes an '...IllegalAccessError: tried to access class ...Deferred$DeferredPromiseImpl ...'
+            // in dev-mode when resolve is protected. It works in JRE and production though.
+            resolve.f();
+          }
+        });
+      }
+    }).then(new FunctionDeferred() {
+      protected void f(Deferred dfd) {
+        GQuery.when(new Function() {
+          public void f() {
+            resolve.f();
+          }
+        });
+      }
+    }).done(new Function() {
+      public void f() {
+        finishTest();
+      }
+    });
+  }
+
 }