Top Description Inners Fields Constructors Methods
org.graalvm.polyglot

public final Class PolyglotAccess

extends Object
Class Inheritance
Imports
java.util.Arrays, .LinkedHashMap, .Map, .Objects, .Set, org.graalvm.collections.EconomicMap, .EconomicSet, .Equivalence, .MapCursor, .UnmodifiableEconomicSet

Represents an access policy for polyglot builtins in the guest languages.

If the two predefined access policies NONE and ALL are not sufficient then a custom access configuration may be created using newBuilder(). This allows to grant individual access rights between the language.

The following access rights may be granted:

Access to polyglot evaluation and bindings builtins are always enabled when access policy ALL is used. In this mode polyglot evaluation builtins are available even if there is just one installed language available.
Since
19.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public class
PolyglotAccess.Builder

A builder for a polyglot access configuration.

Field Summary

Modifier and TypeField and Description
public static final PolyglotAccess
ALL

Provides guest languages full access to other languages using polyglot evaluation and binding builtins.

private final boolean
private final EconomicSet<String>
private final EconomicMap<String, UnmodifiableEconomicSet<String>>
public static final PolyglotAccess
NONE

Provides guest languages no access to other languages using polyglot builtins evaluation and binding builtins.

Constructor Summary

AccessConstructor and Description
pack-priv
PolyglotAccess(boolean allAccess, EconomicMap<String, EconomicSet<String>> access, EconomicSet<String> bindingsAccess)

Method Summary

Modifier and TypeMethod and Description
private static EconomicMap<String, UnmodifiableEconomicSet<String>>
pack-priv Set<String>
pack-priv Set<String>
pack-priv Map<String, Set<String>>
public static PolyglotAccess.Builder
newBuilder()

Creates a new custom polyglot access configuration builder.

pack-priv static String
pack-priv String
validate(Set<String> availableLanguages)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ALLback to summary
public static final PolyglotAccess ALL

Provides guest languages full access to other languages using polyglot evaluation and binding builtins.

Since
19.0
allAccessback to summary
private final boolean allAccess
bindingsAccessback to summary
private final EconomicSet<String> bindingsAccess
evalAccessback to summary
private final EconomicMap<String, UnmodifiableEconomicSet<String>> evalAccess
NONEback to summary
public static final PolyglotAccess NONE

Provides guest languages no access to other languages using polyglot builtins evaluation and binding builtins.

Since
19.0

Constructor Detail

PolyglotAccessback to summary
pack-priv PolyglotAccess(boolean allAccess, EconomicMap<String, EconomicSet<String>> access, EconomicSet<String> bindingsAccess)

Method Detail

copyMapback to summary
private static EconomicMap<String, UnmodifiableEconomicSet<String>> copyMap(EconomicMap<String, EconomicSet<String>> values)
getBindingsAccessback to summary
pack-priv Set<String> getBindingsAccess()
getEvalAccessback to summary
pack-priv Set<String> getEvalAccess(String language)
getEvalAccessback to summary
pack-priv Map<String, Set<String>> getEvalAccess()
newBuilderback to summary
public static PolyglotAccess.Builder newBuilder()

Creates a new custom polyglot access configuration builder. A polyglot access builder starts with no access rights.

Since
19.2
toStringSetback to summary
pack-priv static String toStringSet(UnmodifiableEconomicSet<String> set)
validateback to summary
pack-priv String validate(Set<String> availableLanguages)
org.graalvm.polyglot back to summary

public final Class PolyglotAccess.Builder

extends Object
Class Inheritance

A builder for a polyglot access configuration. Builder instances are not thread-safe.
Since
19.2

Field Summary

Modifier and TypeField and Description
private EconomicSet<String>
private EconomicMap<String, EconomicSet<String>>

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public PolyglotAccess.Builder
allowBindingsAccess(String language)

Allows access to polyglot bindings for a language.

public PolyglotAccess.Builder
allowEval(String from, String to)

Allows evaluation of code by one language of another.

public PolyglotAccess.Builder
allowEvalBetween(String... languages)

Allows bidirectional evaluation of code between the given languages.

public PolyglotAccess
build()

Creates an instance of the custom polyglot access configuration.

public PolyglotAccess.Builder
denyBindingsAccess(String language)

Denies access to polyglot bindings for a language.

public PolyglotAccess.Builder
denyEval(String from, String to)

Denies evaluation of code by one language of another.

public PolyglotAccess.Builder
denyEvalBetween(String... languages)

Denies bidirectional evaluation of code between the given languages.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bindingsAccessback to summary
private EconomicSet<String> bindingsAccess
evalAccessback to summary
private EconomicMap<String, EconomicSet<String>> evalAccess

Constructor Detail

Builderback to summary
pack-priv Builder()

Method Detail

allowBindingsAccessback to summary
public PolyglotAccess.Builder allowBindingsAccess(String language)

Allows access to polyglot bindings for a language. The names of the guest language builtins to access polyglot bindings are language specific. In JavaScript they are called Polyglot.import and Polyglot.export.

Since
19.2
See Also
denyBindingsAccess(String)
allowEvalback to summary
public PolyglotAccess.Builder allowEval(String from, String to)

Allows evaluation of code by one language of another. This method only allows one-way evaluation access. Every language always has implicitly access to itself. If a language has access to one ore more different languages then the guest application will have access to polyglot evaluation builtins. If a language has no access granted to another language then access to polyglot evaluation builtins is denied.

Since
19.2
See Also
allowEvalBetween(String...)
allowEvalBetweenback to summary
public PolyglotAccess.Builder allowEvalBetween(String... languages)

Allows bidirectional evaluation of code between the given languages. When called with language "A" and language "B", this is equivalent to calling allowEval("A", "B") and allowEval("B", "A"). If called with more than two then all language evaluation combinations will be allowed. This method potentially overrides already configured access rights with allowEval(String, String) or denyEval(String, String). The given language array must be null and individual languages must not be null.

Since
19.2
See Also
allowEval(String, String)
buildback to summary
public PolyglotAccess build()

Creates an instance of the custom polyglot access configuration. This method may be called multiple times to create more than one independent instances.

Since
19.2
denyBindingsAccessback to summary
public PolyglotAccess.Builder denyBindingsAccess(String language)

Denies access to polyglot bindings for a language. The provided language must not be null.

Since
19.2
See Also
allowBindingsAccess(String)
denyEvalback to summary
public PolyglotAccess.Builder denyEval(String from, String to)

Denies evaluation of code by one language of another. This method only denies one-way evaluation. Every language has always evaluation access to itself. This access cannot be denied.

Since
19.2
See Also
denyEvalBetween(String...)
denyEvalBetweenback to summary
public PolyglotAccess.Builder denyEvalBetween(String... languages)

Denies bidirectional evaluation of code between the given languages. When called with language "A" and language "B", this is equivalent to calling denyEval("A", "B") and denyEval("B", "A"). If called with more than two then all language access combinations will be denied. This method potentially overrides already configured access rights with allowEval(String, String) or denyEval(String, String). The given language array must be null and individual languages must not be null.

Since
19.2
See Also
denyEval(String, String)