diff --git a/src/main/markdown/doc/latest/RefJreEmulation.md b/src/main/markdown/doc/latest/RefJreEmulation.md index 4f10e85f1..17d5fc6d2 100644 --- a/src/main/markdown/doc/latest/RefJreEmulation.md +++ b/src/main/markdown/doc/latest/RefJreEmulation.md @@ -64,8 +64,14 @@ Note that in some cases, only a subset of methods is supported for a given type.
Type | -Property and Description | -
---|---|
static boolean |
-isDebugIdAs
-Gets the value of the property debugIdAsProperty.
- |
-
static boolean
isDebugIdAsProperty()
-public static boolean isDebugIdAsProperty-
Type | -Property and Description | -
---|---|
(package private) Style |
-assertCanAddStyle
-Assert that the builder is in a state where a style property can be added.
- |
-
Style assertCanAddStyleProperty-
Style assertCanAddStyleProperty()
Style
on which the property can be set@Retention(value=RUNTIME)
+ @Target(value=METHOD)
+ @Documented
+public @interface JsAsync
+Adding this annotation to a method adds an async
keyword to the generated JavaScript
+ function.
+
+
There are some limitations apply on JsAsync to make the annotation practical: + +
null
.
+ This is an EXPERIMENTAL annotation and only works in J2CL.
@Retention(value=RUNTIME)
+ @Target(value=TYPE)
+ @Documented
+public @interface JsEnum
+The underlying type of the Closure enum can be specified via hasCustomValue()
and
+ declaring an instance field named "value" of the desired type.
+
+
If the JsEnum is non-native and has custom values, a constructor is required to allow + specifying the values for the enum constants, as in the following example + +
+ @JsEnum(hasCustomValue=true)
+ enum IntJsEnum {
+ TEN(10),
+ TWENTY(20);
+
+ int value;
+
+ IntJsEnum(int value) { this.value = value; }
+ }
+
+
+ If the JsEnum is native and has custom values, the value field is still required but + constructors are not needed nor allowed. + +
JsEnums do not support the full Java semantics: + +
value
,
+ Enum.name()
and values()
are not supported.
+ Enum.ordinal()
is supported only for non-native JsEnums that don't have custom
+ values.
+ The JavaScript namespace and name can be specified in a manner similar to JsTypes via namespace()
and name()
respectively.
+
+
Methods and fields declared in the JsEnum are only accessible in Java code. Only the enum + constants are accessible from JavaScript code. + +
This annotation is only supported by J2CL.
Modifier and Type | +Optional Element and Description | +
---|---|
boolean |
+hasCustomValue
+When set to
+true , this JsEnum will have a custom value defined by a field named
+ 'value'. |
+
boolean |
+isNative
+When set to
+true , this JsEnum is a native Closure enum type. |
+
java.lang.String |
+name
+Customizes the name of the type in generated JavaScript.
+ |
+
java.lang.String |
+namespace
+Customizes the namespace of the type in generated JavaScript.
+ |
+
public abstract java.lang.String name+
public abstract java.lang.String namespace+
public abstract boolean isNative+
true
, this JsEnum is a native Closure enum type.public abstract boolean hasCustomValue+
true
, this JsEnum will have a custom value defined by a field named
+ 'value'. The only allowed types for the value field are String and primitive types with the
+ exception of long.There are some limitations exists on JsFunction to make them practical and efficient:
JsType
(directly or
- indirectly).
- JsOverlay
and
- cannot be overridden by the implementations.
+ JsType
(directly or
+ indirectly).
+ JsOverlay
and
+ cannot be overridden by the implementations.
As a best practice, we also recommend marking JsFunction interfaces with FunctionalInterface @@ -136,11 +136,11 @@
This is particularly useful when JsType
is applied to a class and some members need
- to be ignored as they don't comply with restrictions (e.g. overloading) or shouldn't be exported
- for other reasons.
This is particularly useful when JsType
is applied to a class and some members need to
+ be ignored as they don't comply with restrictions (e.g. overloading) or shouldn't be exported for
+ other reasons.
- Note: In JavaScript, instance members are defined on the prototype and class members are defined - on the constructor function of the type.
Note: In JavaScript, instance members are defined on the prototype and class members are + defined on the constructor function of the type.
@Retention(value=RUNTIME)
+ @Target(value=TYPE_USE)
+ @Documented
+public @interface JsNonNull
+null
value.
+
+ Note that JsNonNull can only be used in a JsConstructor, a JsMethod, a JsProperty or a + JsFunction method. + +
This annotation is informational in the GWT compiler but other compilers or tools might use it + for example to annotate types in the output JavaScript program.
@Retention(value=RUNTIME)
+ @Target(value=TYPE_USE)
+ @Documented
+public @interface JsNullable
+null
value.
+
+ Note that JsNullable can only be used on type variables in the context of a JsConstructor, a + JsMethod, a JsProperty or a JsFunction method. + +
This annotation is informational in the GWT compiler but other compilers or tools might use it + for example to annotate types in the output JavaScript program.
Note that JsOptional can only be used in a JsConstructor, a JsMethod or a JsFunction method. - An optional argument cannot precede a non-optional argument (a vararg is considered an - optional argument). + An optional argument cannot precede a non-optional argument (a vararg is considered an optional + argument).
This annotation is informational in the GWT compiler but other compilers or tools might use it for example to annotate types in the output JavaScript program.
@JsProperty getX()
or @JsProperty isX()
translates as this.x
- @JsProperty setX(int y)
translates as this.x=y
+ @JsProperty getX()
or @JsProperty isX()
translates as this.x
+ @JsProperty setX(int y)
translates as this.x=y
Note: In JavaScript, instance members are defined on the prototype and class members are @@ -169,8 +169,8 @@
Name collisions must be avoided by providing custom names (e.g. JsProperty.name()
) or by
@@ -118,9 +118,8 @@
JsProperty
/JsMethod
/JsConstructor
unless they are
explicitly marked with JsOverlay
.
- For native interfaces with no particular JavaScript type associated with them (e.g.
- structural types) it is recommeded to use namespace = JsPackage.GLOBAL
and
- name = '?'
.
+
For native interfaces with no particular JavaScript type associated with them (e.g. structural
+ types) it is recommeded to use namespace = JsPackage.GLOBAL
and name = '?'
.
Instanceof and Castability: @@ -129,9 +128,9 @@
All non-native JsTypes will follow regular Java semantics in terms of castability.
null
value.null
value.