Annotations

  • Binding ObjectData class
  • Describes the Java class representing a Ballerina binding.

    1@java:Binding {
    2 'class: "java.io.File"
    3}
  • Constructor ConstructorData source external
  • Describes a Java constructor, which provides an implementation of a Ballerina function of which the body is marked as external. If the Ballerina function body is marked as external, it means that the implementation of the function is not provided in the Ballerina source module.

    The following code snippet shows an example usage of this annotation. Here, the newJavaLinkedList Ballerina function's implementation is provided by the default constructor of the java.util.LinkedList class.

    1function newJavaLinkedList() returns handle = @java:Constructor {
    2 'class: "java.util.LinkedList"
    3} external;
  • FieldGet FieldData source external
  • Describes a Java Field access, which provides an implementation of a Ballerina function of which the body is marked as external.

    1function getError() returns handle = @java:FieldGet {
    2 name:"err",
    3 'class:"java/lang/System"
    4} external;
  • FieldSet FieldData source external
  • Describes a Java Field mutate, which provides an implementation of a Ballerina function of which the body is marked as external.

    1function setContractId(handle contractId) = @java:FieldSet {
    2 name:"contractId",
    3 'class:"org/lang/impl/JavaFieldAccessMutate"
    4} external;
  • Method MethodData source external
  • Describes a Java method, which provides an implementation of a Ballerina function of which the body is marked as external. If the Ballerina function body is marked as external, it means that the implementation of the function is not provided in the Ballerina source module.

    The following code snippet shows an example usage of this annotation. Here, the getUUID Ballerina function's implementation is provided by the java.util.UUID.randomUUID static method.

    1function getUUID() returns handle = @java:Method {
    2 name: "randomUUID",
    3 'class: "java.util.UUID"
    4} external;

    The name field is optional. If it is not provided, the name of the Java method is inferred from the Ballerina function.