Annotations -
java
-
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, thenewJavaLinkedList
Ballerina function's implementation is provided by the default constructor of thejava.util.LinkedList
class.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, thegetUUID
Ballerina function's implementation is provided by thejava.util.UUID.randomUUID
static method.
Thefunction getUUID() returns handle = @java:Method { name: "randomUUID", class: "java.util.UUID" } external;
name
field is optional. If it is not provided, the name of the Java method is inferred from the Ballerina function.