| commit | 6e4351e37c0ab6a30f22659c53d63139f9b98eca | [log] [tgz] |
|---|---|---|
| author | rdayal@google.com <rdayal@google.com@8db76d5a-ed1c-0410-87a9-c151d255dfc7> | Mon Apr 09 15:32:10 2012 +0000 |
| committer | rdayal@google.com <rdayal@google.com@8db76d5a-ed1c-0410-87a9-c151d255dfc7> | Mon Apr 09 15:32:10 2012 +0000 |
| tree | eb65185e7eaf21b78a157f515c7d53c5a48f5e38 | |
| parent | 2265e62c45664647d52d05672ba1cb23a31dce23 [diff] |
Fix this->window confusion in DevMode (issue #3069). Review at: http://gwt-code-reviews.appspot.com/1620805 Patch by: stephenh Review by: scottb@google.com git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@10944 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/shell/JavaScriptHost.java b/dev/core/src/com/google/gwt/dev/shell/JavaScriptHost.java index 17a1b5c..8f3ecad 100644 --- a/dev/core/src/com/google/gwt/dev/shell/JavaScriptHost.java +++ b/dev/core/src/com/google/gwt/dev/shell/JavaScriptHost.java
@@ -23,6 +23,19 @@ private static ShellJavaScriptHost sHost; + /** + * Throws {@code NullPointerException} if {@code o} is null. + *<p> + * Used by {@code RewriteJsniMethods} to ensure JSO instance methods + * are not called against null instances. + */ + public static Object checkNotNull(Object o) { + if (o == null) { + throw new NullPointerException("JSO instance was null"); + } + return o; + } + public static void exceptionCaught(Object exception) { sHost.exceptionCaught(exception); }
diff --git a/dev/core/src/com/google/gwt/dev/shell/rewrite/RewriteJsniMethods.java b/dev/core/src/com/google/gwt/dev/shell/rewrite/RewriteJsniMethods.java index da8a029..9760f06 100644 --- a/dev/core/src/com/google/gwt/dev/shell/rewrite/RewriteJsniMethods.java +++ b/dev/core/src/com/google/gwt/dev/shell/rewrite/RewriteJsniMethods.java
@@ -255,6 +255,13 @@ visitInsn(Opcodes.ACONST_NULL); } else { loadThis(); + // Ensure the instance method is not invoked against null, otherwise + // JS's apply will turn it into the window object. See Issue 3069. + visitMethodInsn( + Opcodes.INVOKESTATIC, + "com/google/gwt/dev/shell/JavaScriptHost", + "checkNotNull", + "(Ljava/lang/Object;)Ljava/lang/Object;"); } // Stack is at 2