@Retention(value=CLASS) @Target(value={METHOD,CONSTRUCTOR}) public @interface JavaScriptBody
Visit an on-line demo
to play with JavaScriptBody annotation for real.
public abstract String body
this.args() and possibly
thispublic abstract boolean javacall
@ followed by fully qualified
package name of the class. Now followed by :: and a method in
the class followed by its parameters enclosed inside (...).
This is the syntax one can use to call run()
method of Runnable:
r.@java.lang.Runnable::run()(). One can also call static methods. Just use:
var ten = @java.lang.Integer::parseInt(Ljava/lang/String;)("10")public abstract boolean wait4js
Some implementations that recognize the JavaScriptBody annotation
need to reschedule the JavaScript execution into different thread and
then it is easier for them to perform the execution asynchronously
and not wait for the result of the execution. This may however be
unexpected (for example when one awaits a callback into Java)
and as such it has to be explicitly allowed by specifying
wait4js = false. Such methods need to return void.
Implementations that execute the JavaScript synchronously may ignore this attribute.
Implementations that delay execution of JavaScript need to guarantee the order of snippets. Those that were submitted sooner, need to be executed sooner. Each snippet need to be executed in a timely manner (e.g. by a second, or so) even if there are no other calls made in the main program.
false in case one allows asynchronous execution
of the JavaScript snippetCopyright © 2014 NetBeans. All Rights Reserved.