This API documentation is for Ballerina 1.2.0. View API documentation for the latest release.

Module : java

Module Overview

This module provides the API for Java interoperability in Ballerina. It includes a set of Ballerina annotations with which Java constructors, methods, and fields can provide implementations of Ballerina functions with external function bodies.

For information on the operations, which you can perform with the Java module, see the below Functions. For examples on the usage of the operations, see the following.

Records

ArrayType

Represents a Java array type.

ConstructorData

Describes a Java constructor.

FieldData

Describes a Java field.

MethodData

Describes a Java method.

ObjectData

Describes a Java class that corresponds to a Ballerina object.

Objects

JObject

The Ballerina abstract object which is to be extended by Ballerina objects representing Ballerina bindings for Java classes.

Functions

cast

Returns an JObject|error, which is obtained after casting the provided JObject instance to the given JObject type depending on assignability.

createNull

Returns a handle, which refers to Java null.

fromString

Returns a handle, which refers to the Java string representation of the Ballerina string.

getClass

Returns a handle, which refers to the Java Class object associated with the class or interface with the given string name.

isNull

Returns true if this handle refers to Java null.

jObjToString

Returns the string representation of a Java object stored in a handle reference.

toString

Returns a Ballerina string representation of the Java object referred by the handle.

Annotations

Binding

Describes the Java class representing a Ballerina binding.

Constructor

Describes a Java constructor, which provides an implementation of a Ballerina function of which the body is marked as external.

FieldGet

Describes a Java Field access, which provides an implementation of a Ballerina function of which the body is marked as external.

FieldSet

Describes a Java Field mutate, which provides an implementation of a Ballerina function of which the body is marked as external.

Method

Describes a Java method, which provides an implementation of a Ballerina function of which the body is marked as external.