Class HostAccess
java.lang.Object
org.graalvm.polyglot.HostAccess
Represents the host access policy of a polyglot context. The host access policy specifies which
methods and fields are accessible to the guest application, whenever Java host objects are
accessed.
There are three predefined instances of host access policies:
EXPLICIT- Java host methods or fields, must be public and be annotated with@Exportto make them accessible to the guest language.SCOPED- Java host methods or fields, must be public and be annotated with@Exportto make them accessible to the guest language. Guest-to-host callback parameter validity is scoped to the duration of the callback by default.NONE- Does not allow any access to methods or fields of host objects. Java host objects may still be passed into a context, but they cannot be accessed.ALL- Does allow full unrestricted access to public methods or fields of host objects. Note that this policy allows unrestricted access to reflection. It is highly discouraged from using this policy in environments where the guest application is not fully trusted.CONSTRAINEDhost access policy suitable for a context withCONSTRAINEDsandbox policy.ISOLATEDhost access policy suitable for a context withISOLATEDsandbox policy.UNTRUSTEDhost access policy suitable for a context withUNTRUSTEDsandbox policy.
newBuilder(). The builder allows to
specify a custom export annotation and allowed and denied methods or fields.- Since:
- 19.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal classBuilder to create a customhost access policy.static @interfaceIfSCOPEDis used, placing this annotation on an exported host function excludes it from parameter scoping, i.e.static @interfaceAnnotation used by the predefinedEXPLICITaccess policy to mark public constructors, methods and fields in public classes that should be accessible by the guest application.static @interfaceAllows guest language to implement a Java type.static enumList of default host object mappings of mutable target types available inValue.as(Class).static enumRepresents the precedence of a target type mapping. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final HostAccessPredefined host access policy that allows full unrestricted access to public methods or fields of public host classes.static final HostAccessPredefined host access policy used by Context with aSandboxPolicy.CONSTRAINEDsandbox policy when the host access policy is not explicitly specified by the embedder.static final HostAccessPredefined host access policy that allows access to public host methods or fields that were annotated with @Export and were declared in public class.static final HostAccessPredefined host access policy used by Context with anSandboxPolicy.ISOLATEDsandbox policy when the host access policy is not explicitly specified by the embedder.static final HostAccessPredefined host access policy that disallows any access to public host methods or fields.static final HostAccessPredefined host access policy that is the same as EXPLICIT and enables method scoping of callback parameter values on top.static final HostAccessPredefined host access policy used by Context with anSandboxPolicy.UNTRUSTEDsandbox policy when the host access policy is not explicitly specified by the embedder. -
Method Summary
Modifier and TypeMethodDescriptionbooleaninthashCode()static HostAccess.BuilderCreates a new builder that allows to create a custom host access policy.static HostAccess.BuildernewBuilder(HostAccess conf) Creates a new builder that allows to create a custom host access policy based of a preset configuration.toString()
-
Field Details
-
EXPLICIT
Predefined host access policy that allows access to public host methods or fields that were annotated with @Export and were declared in public class. This is the default configuration ifContext.Builder.allowAllAccess(boolean)isfalse.Equivalent of using the following builder configuration:
HostAccess.newBuilder().allowAccessAnnotatedBy(HostAccess.Export.class). allowImplementationsAnnotatedBy(HostAccess.Implementable.class). allowImplementationsAnnotatedBy(FunctionalInterface.class). .build();- Since:
- 19.0
-
SCOPED
Predefined host access policy that is the same as EXPLICIT and enables method scoping of callback parameter values on top. Methods that are annotated withHostAccess.DisableMethodScopingare exempt from scoping.Equivalent of using the following builder configuration:
HostAccess.newBuilder().allowAccessAnnotatedBy(HostAccess.Export.class). allowImplementationsAnnotatedBy(HostAccess.Implementable.class). allowImplementationsAnnotatedBy(FunctionalInterface.class). methodScoping(true). disableMethodScopingAnnotatedBy(HostAccess.DisableMethodScoping.class) .build();- Since:
- 21.3
-
ALL
Predefined host access policy that allows full unrestricted access to public methods or fields of public host classes. Note that this policy allows unrestricted access to reflection. It is highly discouraged from using this policy in environments where the guest application is not fully trusted. This is the default configuration ifContext.Builder.allowAllAccess(boolean)istrue.Equivalent of using the following builder configuration:
HostAccess.newBuilder() allowPublicAccess(true). allowAllImplementations(true). allowAllClassImplementations(true). allowArrayAccess(true). allowListAccess(true). allowBufferAccess(true). allowIterableAccess(true). allowIteratorAccess(true). allowMapAccess(true). allowAccessInheritance(true). .build();- Since:
- 19.0
-
NONE
Predefined host access policy that disallows any access to public host methods or fields.Equivalent of using the following builder configuration:
HostAccess.newBuilder().build();
- Since:
- 19.0
-
CONSTRAINED
Predefined host access policy used by Context with aSandboxPolicy.CONSTRAINEDsandbox policy when the host access policy is not explicitly specified by the embedder.Equivalent of using the following builder configuration:
HostAccess.newBuilder(). allowAccessAnnotatedBy(Export.class). allowImplementationsAnnotatedBy(Implementable.class). allowMutableTargetMappings().build();- Since:
- 23.0
-
ISOLATED
Predefined host access policy used by Context with anSandboxPolicy.ISOLATEDsandbox policy when the host access policy is not explicitly specified by the embedder.Equivalent of using the following builder configuration:
HostAccess.newBuilder(CONSTRAINED). methodScoping(true).build();- Since:
- 23.0
-
UNTRUSTED
Predefined host access policy used by Context with anSandboxPolicy.UNTRUSTEDsandbox policy when the host access policy is not explicitly specified by the embedder.Equivalent of using the following builder configuration:
HostAccess.newBuilder(). allowAccessAnnotatedBy(Export.class). allowMutableTargetMappings(). methodScoping(true).build();- Since:
- 23.0
-
-
Method Details
-
equals
-
hashCode
-
newBuilder
Creates a new builder that allows to create a custom host access policy. The builder configuration needs to be completed using themethod.- Since:
- 19.0
-
newBuilder
Creates a new builder that allows to create a custom host access policy based of a preset configuration. The preset configuration is copied and used as a template for the returned buidler. The builder configuration needs to be completed using themethod.- Since:
- 19.0
-
toString
-