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
Optional ElementsModifier and TypeOptional ElementDescriptionString[]List of MIME types supported by this language which sources should be interpreted asbytebased sources.String[]List of MIME types supported by this language which sources should be interpreted ascharacterbased sources.Defines the supported policy for reusinglanguagesper 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.FileTypeDetectorclasses provided by this language.Unique id of your language.Unique name of your language implementation.booleanSpecifies if the language is suitable for interactive evaluation ofsources.booleanReturnstrueif this language is intended for internal use only.Class<? extends InternalResource>[]Declarative list ofInternalResourceclasses that is associated with this language.Unique name of your language.booleanDeprecated.String[]A declarative list of optionalInternalResourceidentifiers associated with this language.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 supportedcharacterorbytebased 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
characterbased sources.- Since:
- 19.0
- See Also:
- Default:
""
-
characterMimeTypes
String[] characterMimeTypesList of MIME types supported by this language which sources should be interpreted ascharacterbased 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 toparsesources of this kind. If only one supported MIME type was specified by a language then it will be used asdefaultMIME type. If no supported character and byte based MIME types are specified then all sources will be interpreted ascharacterbased.- 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 asbytebased 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 toparsesources of this kind. If only one supported MIME type was specified by a language then it will be used asdefaultMIME type. If no supported character and byte based MIME types are specified then all sources will be interpreted ascharacterbased.- 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.Interactivelanguages should be displayed in interactive environments and presented to the user. The default value of this attribute istrueassuming majority of the languages is interactive. Change the value tofalseto opt-out and turn your language into non-interactive one.- Returns:
trueif the language should be presented to end-user in an interactive environment- Since:
- 0.22
- Default:
true
-
internal
boolean internalReturnstrueif 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-internallanguages 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 anIllegalStateExceptionwhen 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 reusinglanguagesper 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, whereexclusiveis the least andsharedis the most permissive policy.Parse cachingis scoped perlanguageinstance, therefore the context policy influences its behavior.The context policy applies to contexts that were created using the
polyglot APIas 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 itscreateContextmethod and instantiate andregisterall 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.FileTypeDetectorclasses 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 allTruffleStringencodings, it is sufficient to add theorg.graalvm.shadowed.jcodingsmodule to the language's module-inforequiresand 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.Returnstrueif the language usesTruffleStrings with encodings not present in the following list.UTF-8UTF-16UTF-32ISO-8859-1US-ASCIIBYTES
- 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(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 specifiesISOLATEDpolicy, it can be used in a context configured with sandbox policyTRUSTED,CONSTRAINEDorISOLATED. But it cannot be used in a context configured with theUNTRUSTEDsandbox policy.- Since:
- 23.0
- See Also:
- Default:
TRUSTED
-
internalResources
Class<? extends InternalResource>[] internalResourcesDeclarative list ofInternalResourceclasses that is associated with this language. Use theinternalResourcesattribute 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:
{}
-
optionalResources
String[] optionalResourcesA declarative list of optionalInternalResourceidentifiers associated with this language. It is recommended to register all optional resource identifiers here. Specifying the resource identifier allows the language use the resource even if its implementation was omitted at runtime. To use the resource when its implementation was omitted thepolyglot.engine.resourcePath.languageIdsystem property must be specified and point to a path with the resources. This allows to omit the resource implementation class in standalone distributions.- Since:
- 25.0
- See Also:
- Default:
{}
-
TruffleStringencodings, it is sufficient to add theorg.graalvm.shadowed.jcodingsmodule to the language's module-inforequiresand ensure it is on the module path when languages are loaded.