Annotations -
java
-
Binding
ObjectData
objecttype
-
Describes the Java class representing a Ballerina binding.
@java:Binding { class: "java.io.File" }
-
Constructor
ConstructorData
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 asexternal, 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
newJavaLinkedListBallerina function's implementation is provided by the default constructor of thejava.util.LinkedListclass.function newJavaLinkedList() returns handle = @java:Constructor { class: "java.util.LinkedList" } external;
-
FieldGet
FieldData
external
-
Describes a Java Field access, which provides an implementation of a Ballerina function of which the body is marked as
external.function getError() returns handle = @java:FieldGet { name:"err", class:"java/lang/System" } external;
-
FieldSet
FieldData
external
-
Describes a Java Field mutate, which provides an implementation of a Ballerina function of which the body is marked as
external.function setContractId(handle contractId) = @java:FieldSet { name:"contractId", class:"org/lang/impl/JavaFieldAccessMutate" } external;
-
Method
MethodData
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 asexternal, 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
getUUIDBallerina function's implementation is provided by thejava.util.UUID.randomUUIDstatic method.function getUUID() returns handle = @java:Method { name: "randomUUID", class: "java.util.UUID" } external;The
namefield is optional. If it is not provided, the name of the Java method is inferred from the Ballerina function.