Annotation Interface HostAccess.Export

Enclosing class:
HostAccess

@Target({CONSTRUCTOR,FIELD,METHOD}) @Retention(RUNTIME) public static @interface HostAccess.Export
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: