On 2011/02/09 02:46:03, scottb wrote:
as I can tell, changing isJavaObject() will cause "null.equals()" to
inappropriately dispatch to JavaScriptObject.equals() instead of the
throwing
the NPE.

You're right, I think I meant JavaScriptObjectNormalizer when I said
JsoDevirtulizer.

- Details aside, it sounds like you're proposing to have a null
instance of a
dual-interface dispatch to the JSO version.  That seems... really
broken to me!

It is strange, then again, it is strange that a JSO that is null can
still be invoked. :) However, I think I've come back to sanity on
rethinking this. Since it is only used for a single use case in my Json
library (JsonNull), I think I'll just change the API slightly. I wanted
an "unwrapped" JsonNull to represent json nulls (most APIs use a Java
wrapper). Instead, I'll just use the real 'null', and add an extra
method to check for the difference between 'null' and undefined.


- It's not clear to me, with or without this patch, that the
conditionals that
get generated in JavaScriptObjectNormalizer (which runs before
optimizations)
will ever get properly cleaned up if the Java implementors all get
pruned.

This is a different issue, and my gut says they will only partially get
cleaned up. Consider:

Cast.isJavaObject(foo) ? foo.method() : Jso$foo$method();

If Foo is not instantiable, then it can be pruned. However, if the Cast
check can't be inlined, it will be treated as having side effects, so it
won't be pruned.  If it is inlinable, you still end up with code like
(guessing):

foo.typeMarker != nullMethod || Jso$Foo$method();

It would be nice somehow if we could detect the typeMarker check on
tightened interfaces that are not dual-impls and evaluate it at compile
time.


Anyway, I welcome suggestions for ensuring these normalized trampolines
get cleaned up.

http://gwt-code-reviews.appspot.com/1351801/diff/1/4
File

dev/core/super/com/google/gwt/dev/jjs/intrinsic/com/google/gwt/lang/Cast.java
(right):

http://gwt-code-reviews.appspot.com/1351801/diff/1/4#newcode68

dev/core/super/com/google/gwt/dev/jjs/intrinsic/com/google/gwt/lang/Cast.java:68:
if (src != null && isJavaObject(src)) {
Then remove the null check here.



http://gwt-code-reviews.appspot.com/1351801/show

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

Reply via email to