@Target(value={CONSTRUCTOR,FIELD,METHOD}) @Retention(value=RUNTIME) public static @interface HostAccess.Export
HostAccess.EXPLICIT
access policy to mark public
constructors, methods and fields in public classes that should be accessible by the guest
application.
Example using a Java object from JavaScript:
public class JavaRecord { @HostAccess.Export public int x; @HostAccess.Export public String name() { return "foo"; } } try (Context context = Context.create()) { JavaRecord record = new JavaRecord(); context.getBindings("js").putMember("javaRecord", record); context.eval("js", "javaRecord.x = 42"); context.eval("js", "javaRecord.name()").asString().equals("foo"); }
Context.Builder.allowHostAccess(HostAccess)
,
HostAccess.EXPLICIT