Annotation Interface TruffleLanguage.Registration
- Enclosing class:
TruffleLanguage<C>
Polyglot
API
. By annotating your implementation of TruffleLanguage
by this annotation the
language can be discovered on the class path.- Since:
- 0.8 or earlier
-
Optional Element Summary
Modifier and TypeOptional ElementDescriptionString[]
List of MIME types supported by this language which sources should be interpreted asbyte
based sources.String[]
List of MIME types supported by this language which sources should be interpreted ascharacter
based sources.Defines the supported policy for reusinglanguages
per context.Returns the default MIME type of this language.String[]
Specifies a list of languages that this language depends on.Class<? extends TruffleFile.FileTypeDetector>[]
Declarative list ofTruffleFile.FileTypeDetector
classes provided by this language.Unique id of your language.Unique name of your language implementation.boolean
Specifies if the language is suitable for interactive evaluation ofsources
.boolean
Returnstrue
if this language is intended for internal use only.Class<? extends InternalResource>[]
Declarative list ofInternalResource
classes that is associated with this language.Unique name of your language.boolean
Deprecated.Specifies the most strict sandbox policy in which the language can be used.Class<?>[]
Declarative list of classes this language is known to provide.Unique string identifying the language version.A link to a website with more information about the language.
-
Element Details
-
id
String idUnique id of your language. This id will be exposed to users via the getter. It is used as group identifier for options of the language.- Returns:
- identifier of your language
- Since:
- 0.8 or earlier
- Default:
""
-
name
String nameUnique name of your language. This name will be exposed to users via theLanguage.getName()
getter.- Returns:
- identifier of your language
- Since:
- 0.8 or earlier
- Default:
""
-
implementationName
String implementationNameUnique name of your language implementation.- Returns:
- the implementation name of your language
- Since:
- 0.8 or earlier
- Default:
""
-
version
String versionUnique string identifying the language version. This name will be exposed to users via theLanguage.getVersion()
getter. It inherits fromEngine.getVersion()
by default.- Returns:
- version of your language
- Since:
- 0.8 or earlier
- Default:
"inherit"
-
defaultMimeType
String defaultMimeTypeReturns the default MIME type of this language. The default MIME type allows embedders and other language or instruments to find out how content is interpreted if no MIME type was specified. The default MIME type must be specified in the list of supportedcharacter
orbyte
based MIME types.The default MIME type is mandatory if more than one supported MIME type was specified. If no default MIME type and no supported MIME types were specified then all sources for this language will be interpreted as
character
based sources.- Since:
- 19.0
- See Also:
- Default:
""
-
characterMimeTypes
String[] characterMimeTypesList of MIME types supported by this language which sources should be interpreted ascharacter
based sources. Languages may use MIME types to differentiate supported source kinds. If a MIME type is declared as supported then the language needs to be able toparse
sources of this kind. If only one supported MIME type was specified by a language then it will be used asdefault
MIME type. If no supported character and byte based MIME types are specified then all sources will be interpreted ascharacter
based.- Returns:
- array of MIME types assigned to your language files
- Since:
- 19.0
- See Also:
- Default:
{}
-
byteMimeTypes
String[] byteMimeTypesList of MIME types supported by this language which sources should be interpreted asbyte
based sources. Languages may use MIME types to differentiate supported source kinds. If a MIME type is declared as supported then the language needs to be able toparse
sources of this kind. If only one supported MIME type was specified by a language then it will be used asdefault
MIME type. If no supported character and byte based MIME types are specified then all sources will be interpreted ascharacter
based.- Returns:
- array of MIME types assigned to your language files
- Since:
- 19.0
- See Also:
- Default:
{}
-
interactive
boolean interactiveSpecifies if the language is suitable for interactive evaluation ofsources
.Interactive
languages should be displayed in interactive environments and presented to the user. The default value of this attribute istrue
assuming majority of the languages is interactive. Change the value tofalse
to opt-out and turn your language into non-interactive one.- Returns:
true
if the language should be presented to end-user in an interactive environment- Since:
- 0.22
- Default:
true
-
internal
boolean internalReturnstrue
if this language is intended for internal use only. Internal languages cannot be used in the host environment directly, they can only be used from other languages or from instruments.- Since:
- 0.27
- Default:
false
-
dependentLanguages
String[] dependentLanguagesSpecifies a list of languages that this language depends on. Languages are referenced using theirid()
. This has the following effects:- This language always has access to dependent languages if this language is
accessible. Languages may not be accessible if language access is
restricted
. - This language is finalized before dependent language contexts are
finalized
. - This language is disposed before dependent language contexts are
disposed
.
Non-internal
languages implicitly depend on all internal languages. Therefore by default non-internal languages are disposed and finalized before internal languages.Dependent languages should be parsed with
TruffleLanguage.Env.parseInternal(Source, String...)
as the embedder might choose to disable access to it forTruffleLanguage.Env.parsePublic(Source, String...)
.Dependent languages references are optional. If a dependent language is not installed and the language needs to fail in such a case then the language should fail on
context initialization
. Cycles in dependencies will cause anIllegalStateException
when one of the cyclic languages isinitialized
.- Since:
- 0.30
- Default:
{}
- This language always has access to dependent languages if this language is
accessible. Languages may not be accessible if language access is
-
contextPolicy
TruffleLanguage.ContextPolicy contextPolicyDefines the supported policy for reusinglanguages
per context. I.e. the policy specifies the degree of sharing that is allowed between multiple language contexts. The default policy isexclusive
. Every language is encouraged to try to support a context policy that is as permissive as possible, whereexclusive
is the least andshared
is the most permissive policy.Parse caching
is scoped perlanguage
instance, therefore the context policy influences its behavior.The context policy applies to contexts that were created using the
polyglot API
as well as forinner contexts
. The context policy does not apply to nodes that were created using the Truffle interop protocol. Therefore, interop message nodes always need to be prepared to be used with policyTruffleLanguage.ContextPolicy.SHARED
.- Since:
- 19.0
- See Also:
- Default:
EXCLUSIVE
-
services
Class<?>[] servicesDeclarative list of classes this language is known to provide. The language is supposed to override itscreateContext
method and instantiate andregister
all here in defined services.Languages automatically get created but not yet initialized when their registered
service is requested
.- Returns:
- list of service types that this language can provide
- Since:
- 19.0
- Default:
{}
-
fileTypeDetectors
Class<? extends TruffleFile.FileTypeDetector>[] fileTypeDetectorsDeclarative list ofTruffleFile.FileTypeDetector
classes provided by this language.The language has to support all MIME types recognized by the registered
file type detectors
.- Returns:
- list of file type detectors
- Since:
- 19.0
- Default:
{}
-
needsAllEncodings
Deprecated.To enable allTruffleString
encodings, it is sufficient to add theorg.graalvm.shadowed.jcodings
module to the language's module-inforequires
and ensure it is on the module path when languages are loaded. If the module can be found, and at least one languages requires it, all encodings are automatically enabled. When languages are loaded from the class path (i.e. as an unnamed module), having jcodings on the class path is enough to enable it.Returnstrue
if the language usesTruffleString
s with encodings not present in the following list.UTF-8
UTF-16
UTF-32
ISO-8859-1
US-ASCII
BYTES
- Since:
- 22.1
- Default:
false
-
website
String websiteA link to a website with more information about the language. Will be shown in the help text of GraalVM launchers.The link can contain the following substitutions:
${graalvm-version}
- the current GraalVM version. Optionally, a format string can be provided for the
version using
${graalvm-version:format}
. SeeVersion.format(java.lang.String)
. ${graalvm-website-version}
- the current GraalVM version in a format suitable for links to the GraalVM reference manual. The exact format may change without notice.
- Returns:
- URL for language website.
- Since:
- 22.1.0
- Default:
""
-
sandbox
SandboxPolicy sandboxSpecifies the most strict sandbox policy in which the language can be used. The language can be used in a context with the specified sandbox policy or a weaker one. For example, if a language specifiesISOLATED
policy, it can be used in a context configured with sandbox policyTRUSTED
,CONSTRAINED
orISOLATED
. But it cannot be used in a context configured with theUNTRUSTED
sandbox policy.- Since:
- 23.0
- See Also:
- Default:
TRUSTED
-
internalResources
Class<? extends InternalResource>[] internalResourcesDeclarative list ofInternalResource
classes that is associated with this language. Use theinternalResources
attribute solely for registering required internal resources. Optional internal resources should provide the associated language identifier using theInternalResource.Id.componentId()
method. To unpack all resources of a language embedders may useEngine.copyResources(Path, String...)
.- Since:
- 23.1
- See Also:
- Default:
{}
-
TruffleString
encodings, it is sufficient to add theorg.graalvm.shadowed.jcodings
module to the language's module-inforequires
and ensure it is on the module path when languages are loaded.