if (engine == null) {
System.out.println("Warning: No js engine engine found; test vacuously passes."); return;
}
// don't define any function.
engine.eval("");
Runnable runnable = ((Invocable)engine).getInterface(Runnable.class); if (runnable != null) { thrownew RuntimeException("runnable is not null!");
}
// now define "run"
engine.eval("function run() { print('this is run function'); }");
runnable = ((Invocable)engine).getInterface(Runnable.class); // should not return null now!
runnable.run();
// define only one method of "Foo2"
engine.eval("function bar() { print('bar function'); }");
Foo2 foo2 = ((Invocable)engine).getInterface(Foo2.class); if (foo2 != null) { thrownew RuntimeException("foo2 is not null!");
}
// now define other method of "Foo2"
engine.eval("function bar2() { print('bar2 function'); }");
foo2 = ((Invocable)engine).getInterface(Foo2.class);
foo2.bar();
foo2.bar2();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.