public class EqualityNormalizer extends Object
Rewrite Java ==
so that it will execute correctly in JavaScript.
After this pass, Java's ==
is considered equivalent to
JavaScript's ===
.
Whenever possible, a Java ==
is replaced by a JavaScript
==
. This is shorter than ===
, and it avoids any
complication due to GWT treating both null
and
undefined
as a valid translation of a Java null
.
However, whenever something that may be an unboxed type is compared to something
that may not be a unboxed type, use ===
. A Java object
compared to a string should always yield false, but that's not true when
comparing in JavaScript using ==
. The cases where
===
must be used are:
(a == null) & (b == null)
.
Since null !== undefined
, it is also necessary to normalize
null
vs. undefined
if it's possible for one side to
be null
and the other to be undefined
.
An "unboxed type" is a String, Boolean, or Double that is represented as a naked raw JS type.
Modifier and Type | Method and Description |
---|---|
static void |
exec(JProgram program) |
public static void exec(JProgram program)
Copyright © 2018. All rights reserved.