Annotation Interface HostAccess.Export
- Enclosing class:
HostAccess
Annotation used by the predefined
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");
}
- Since:
- 19.0
- See Also: