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 a String is compared to something
that may not be a String
, 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:
String
status.String
and one side is definitely !
String
. (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
.
Modifier and Type | Method and Description |
---|---|
static void |
exec(JProgram program) |
public static void exec(JProgram program)
Copyright © 2018. All rights reserved.