A metadata directive can appear as a prefix to any Slice definition. Metadata directives appear in a pair of square brackets and contain one or more string literals separated by commas. For example, the following is a syntactically valid metadata directives containing two strings:
Metadata directives are not part of the Slice language per se: the presence of a metadata directive has no effect on the client–server contract, that is, metadata directives do not change the Slice type system in any way. Instead, metadata directives are targeted at specific back-ends, such as the code generator for a particular language mapping. In the preceding example, the
java: prefix indicates that the directive is targeted at the Java code generator.
Metadata directives permit you to provide supplementary information that does not change the Slice types being defined, but somehow influences how the compiler will generate code for these definitions. For example, a metadata directive
java:type:java.util.LinkedList instructs the Java code generator to map a sequence to a linked list instead of an array (which is the default).
Note that a global metadata directive is enclosed by double square brackets, whereas a local metadata directive (one that is attached to a specific definition) is enclosed by single square brackets. Global metadata directives are used to pass instructions that affect the entire compilation unit. For example, the preceding metadata directive instructs the Java code generator to generate the contents of the source file into the Java package
com.acme. Global metadata directives must precede any definitions in a file (but can appear following any
#include directives).