- 2201.10.0 (Swan Lake Update 10)
- 2201.9.3 (Swan Lake Update 9)
- 2201.9.2 (Swan Lake Update 9)
- 2201.9.1 (Swan Lake Update 9)
- 2201.9.0 (Swan Lake Update 9)
- 2201.8.8 (Swan Lake Update 8)
- 2201.8.7 (Swan Lake Update 8)
- 2201.8.6 (Swan Lake Update 8)
- 2201.8.5 (Swan Lake Update 8)
- 2201.8.4 (Swan Lake Update 8)
- 2201.8.3 (Swan Lake Update 8)
- 2201.8.2 (Swan Lake Update 8)
- 2201.8.1 (Swan Lake Update 8)
- 2201.8.0 (Swan Lake Update 8)
- 2201.7.5 (Swan Lake Update 7)
- 2201.7.4 (Swan Lake Update 7)
- 2201.7.3 (Swan Lake Update 7)
- 2201.7.2 (Swan Lake Update 7)
- 2201.7.1 (Swan Lake Update 7)
- 2201.7.0 (Swan Lake Update 7)
- 2201.6.3 (Swan Lake Update 6)
- 2201.6.2 (Swan Lake Update 6)
- 2201.6.1 (Swan Lake Update 6)
- 2201.6.0 (Swan Lake Update 6)
- 2201.5.5 (Swan Lake Update 5)
- 2201.5.4 (Swan Lake Update 5)
- 2201.5.3 (Swan Lake Update 5)
- 2201.5.2 (Swan Lake Update 5)
- 2201.5.1 (Swan Lake Update 5)
- 2201.5.0 (Swan Lake Update 5)
- 2201.4.3 (Swan Lake Update 4)
- 2201.4.2 (Swan Lake Update 4)
- 2201.4.1 (Swan Lake Update 4)
- 2201.4.0 (Swan Lake Update 4)
- 2201.3.5 (Swan Lake Update 3)
- 2201.3.4 (Swan Lake Update 3)
- 2201.3.3 (Swan Lake Update 3)
- 2201.3.2 (Swan Lake Update 3)
- 2201.3.1 (Swan Lake Update 3)
- 2201.3.0 (Swan Lake Update 3)
- 2201.2.4 (Swan Lake Update 2)
- 2201.2.3 (Swan Lake Update 2)
- 2201.2.2 (Swan Lake Update 2)
- 2201.2.1 (Swan Lake Update 2)
- 2201.2.0 (Swan Lake Update 2)
- 2201.1.2 (Swan Lake Update 1)
- 2201.1.1 (Swan Lake Update 1)
- 2201.1.0 (Swan Lake Update 1)
- 2201.0.5 (Swan Lake)
- 2201.0.4 (Swan Lake)
- 2201.0.3 (Swan Lake)
- 2201.0.2 (Swan Lake)
- 2201.0.1 (Swan Lake)
- 2201.0.0 (Swan Lake)
- Swan Lake Beta6
- Swan Lake Beta5
- Swan Lake Beta4
- Swan Lake Beta3
- Swan Lake Beta2
- Swan Lake Beta1
- Swan Lake Alpha5
- Swan Lake Alpha4
- Swan Lake Alpha3
- Swan Lake Alpha2
- Swan Lake Alpha1
- Swan Lake Preview 8
- Swan Lake Preview 7
- Swan Lake Preview 6
- Swan Lake Preview 5
- Swan Lake Preview 4
- Swan Lake Preview 3
- Swan Lake Preview 2
- Swan Lake Preview 1
- 1.2.54
- 1.2.53
- 1.2.52
- 1.2.51
- 1.2.50
- 1.2.49
- 1.2.48
- 1.2.47
- 1.2.46
- 1.2.45
- 1.2.44
- 1.2.43
- 1.2.42
- 1.2.41
- 1.2.40
- 1.2.39
- 1.2.38
- 1.2.37
- 1.2.36
- 1.2.35
- 1.2.34
- 1.2.33
- 1.2.32
- 1.2.31
- 1.2.30
- 1.2.29
- 1.2.28
- 1.2.27
- 1.2.26
- 1.2.25
- 1.2.24
- 1.2.23
- 1.2.22
- 1.2.21
- 1.2.20
- 1.2.19
- 1.2.18
- 1.2.17
- 1.2.16
- 1.2.15
- 1.2.14
- 1.2.13
- 1.2.12
- 1.2.11
- 1.2.10
- 1.2.9
- 1.2.8
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
Overview of Ballerina Swan Lake Update 10 (2201.10.0)
Swan Lake Update 10 (2201.10.0) is the tenth update release of Ballerina Swan Lake, and it includes a new set of features and significant improvements to the compiler, runtime, Ballerina library, and developer tooling. It is based on the 2024R1 version of the Language Specification.
Update Ballerina
Update your current Ballerina installation directly to 2201.10.0 using the Ballerina Update Tool as follows.
- Run
bal update
to get the latest version of the Update Tool. - Run
bal dist update
to update to this latest distribution.
Install Ballerina
If you have not installed Ballerina, download the installers to install.
Language updates
Bug fixes
- A bug that caused an invalid static type to be set for an additive expression with operands of an XML and string subtype has been fixed.
public function main() { xml<xml:Element> x = xml `<bar/>`; string s1 = "foo"; // Used to result in an incompatible types error, allowed now. xml<xml:Element|xml:Text> r1 = x + s1; "foo"|"bar" s2 = "foo"; // Compile-time error now. xml<xml:Element|xml:Comment> r2 = x + s2; }
To view bug fixes, see the GitHub milestone for Swan Lake Update 10 (2201.10.0).
Runtime updates
Improvements
Added support for the shift
, unshift
, pop
, and remove
functions with tuples
The runtime now supports the shift
, unshift
, pop
, and remove
operations on tuples similar to arrays, as long as they do not violate inherent type or mutability constraints.
The following are now allowed.
[int, int...] tuple1 = [1, 2]; int val1 = tuple1.shift(); // 1 [int, string, float...] tuple2 = [7, "hello", 67.5, 89.7]; int|string|float val2 = tuple2.remove(2); // 67.5
The following examples will result in errors.
[string, string...] tuple1 = ["hello"]; tuple1.unshift(154); // Compile-time error. [int, string, float...] tuple2 = [7, "hello", 67.5, 89.7]; int|string|float val2 = tuple2.remove(1); // Panics.
New runtime Java APIs
A runtime Java API to check if remote management is enabled
A new runtime Java API is added to check if remote management is enabled via a build option.
boolean isRemoteManagementEnabled();
The above API can be called via a Ballerina Environment
instance as follows.
import io.ballerina.runtime.api.Repository; import io.ballerina.runtime.api.Environment; Repository repository = env.getRepository(); boolean isRemoteManagementEnabled = repository.isRemoteManagementEnabled();
Bug fixes
To view bug fixes, see the GitHub milestone for Swan Lake Update 10 (2201.10.0).
Ballerina library updates
New features
data.jsondata
package
- Introduced constraint validation support, allowing validation of the output against constraints specified in the target type.
- Introduced support for parsing JSON with union types as expected types.
data.xmldata
package
- Introduced constraint validation support, allowing validation of the output against constraints specified in the target type.
- Introduced support for parsing XML with record types with default values as the expected type, using the default values where required (i.e., if a value corresponding to the record field is not present in the XML value).
- Introduced the option to choose between semantic and syntactic equality of XML elements and attributes.
data.yaml
package
- The
data.yaml
package has been introduced to parse YAML as Ballerinaanydata
values with data projection and to serialize Ballerina values to YAML format.
import ballerina/data.yaml; import ballerina/io; type ServerConfig record {| string host; int port; int[2] remotePorts; DatabaseConfig database; |}; type DatabaseConfig record {| string dbName; string username; |}; public function main() returns error? { // Similar to content read from a YAML file. string yamlString = string ` host: "localhost" port: 8080 remotePorts: [9000, 9001, 9002, 9003] protocol: "http" database: dbName: "testdb" username: "dbuser" password: "dbpassword"`; // Based on the expected type, it parses the YAML string to selectively construct the record value. ServerConfig serverConfig = check yaml:parseString(yamlString); io:println(serverConfig); }
graphql
package
- Added support for GraphQL query complexity analysis, which can be used to enhance GraphQL service security by mitigating the risk of denial-of-service attacks. With this update, the
graphql:ServiceConfig
annotation now includes a new field namedqueryComplexityConfig
to configure query complexity analysis.
http
package
- Introduced support for server-sent events.
- Introduced service contract types.
- Introduced the default status code response record type.
ldap
package
- Added support for the main operation types in LDAP.
persist
package
- Introduced support for the H2 data store, mirroring the functionality provided for other supported SQL data stores like MySQL, MSSQL, and PostgreSQL.
Improvements
http
package
- Added connection eviction support for the HTTP listener.
- Enhanced the configurability of Ballerina access logging by introducing multiple configuration options.
jwt
package
-
Added support to directly provide
crypto:PrivateKey
andcrypto:PublicKey
values in JWT signature configurations. With this update, theconfig
field ofjwt:IssuerSignatureConfig
now allowscrypto:PrivateKey
, and thecertFile
field ofjwt:ValidatorSignatureConfig
now allowscrypto:PublicKey
.Previous
jwt:IssuerSignatureConfig
record:public type IssuerSignatureConfig record {| // ... other fields record {| crypto:KeyStore keyStore; string keyAlias; string keyPassword; |} | record {| string keyFile; string keyPassword?; |}|string config?; |};
New
jwt:IssuerSignatureConfig
record:public type IssuerSignatureConfig record {| // ... other fields record {| crypto:KeyStore keyStore; string keyAlias; string keyPassword; |} | record {| string keyFile; string keyPassword?; |}|crypto:PrivateKey|string config?; |};
Previous
jwt:ValidatorSignatureConfig
record:public type ValidatorSignatureConfig record {| // ... other fields string certFile?; |};
New
jwt:ValidatorSignatureConfig
record:public type ValidatorSignatureConfig record {| // ... other fields string|crypto:PublicKey certFile?; |};
Note: This feature may break existing code if the relevant fields are referred to using the previous types.
java.jdbc
package
- Updated the
datasourceName
andproperties
fields in thejdbc:Options
record to be optional fields instead of fields of optional types, to allow users to use thejdbc:Options
type in configurable variables.
xslt
package
- Added parameter passing support for XSLT transformations.
Connector updates
New versions of the following connectors have been released with major updates, as part of the Ballerina connector revamp initiative. All listed connectors have been released under new major versions, featuring significant API and functionality changes, along with improved documentation and examples.
asb
package
- Introduced support for listener-service-based async message consumption functionality.
dayforce
package
- Introduced as a new connector with support for the Dayforce REST API v1.
discord
package
- Introduced as a new connector with support for the Discord REST API v10.
salesforce
package
- Introduced the Salesforce listener with support for the Streaming API for real-time data synchronization and event-driven workflows.
- Added support for base types with the
salesforce.types
submodule. - Reorganized Salesforce clients for better usability.
sap
package
- Added support for invoking any OData endpoint in S/4HANA.
- Added support for automatic CSRF token authentication for enhanced security and usability.
sap.jco
package
- Enabled invocation of RFC modules with improved type binding.
- Added support for sending and receiving iDocs.
sap.s4hana.sales
packages
- Provided a high-level interface for APIs related to Sales and Distribution (SD) in S/4HANA.
- Provided operations for sales order management, delivery processing, and billing.
slack
package
- Replaced existing remote method-based APIs with resource method-based APIs.
- Added support for the latest Slack REST API.
stripe
package
- Replaced existing remote method-based APIs with resource method-based APIs.
- Added support for the latest Stripe REST API v1.
twitter (X)
package
- Added support for the Twitter (X) REST API v2.
- Replaced existing remote method-based APIs with resource method-based APIs.
Deprecations
xmldata
package
- The
xmldata
package has been deprecated and will no longer be maintained or updated. Instead, it is recommended to use theballerina/data.xmldata
library for continued support and updates. For more information, see the new XML to Record conversion example and XML to record conversion with projection example.
Bug fixes
To view bug fixes, see the GitHub milestone for Swan Lake Update 10 (2201.10.0).
Developer tools updates
New features
Language Server
- Introduced the
Convert to configurable
code action to convert a module-level variable into a configurable variable. - Introduced the
Extract to configurable
code action to extract expressions or function arguments into configurable variables. - Introduced the
Add to Config.toml
code action to add configurable variables to theConfig.toml
file.
CLI
-
Introduced auto-restarting of services with the
bal run
command as an experimental feature.$ bal run --watch
OpenAPI tool
-
Added support to generate a mock client for OpenAPI specifications (OAS) that include examples. To generate a mock client, use the
--mock
flag in the OpenAPI client generation CLI command.$ bal openapi -i <yml file> --mode client --mock
-
Provided an option to generate a single Ballerina file with the client or the service code. To generate code in a single file, use the
--single-file
flag in the OpenAPI client/service generation CLI command.$ bal openapi -i <yml file> --mode <client|service> --single-file
-
Added support to generate the Ballerina service contract object type for a given OAS. To generate the service contract object type, use the
--with-service-contract
flag along with the OpenAPI CLI client/service generation command.$ bal openapi -i <yml file> --mode <client|service> --with-service-contract
-
Introduced example annotations in the OpenAPI package. This feature will enable rendering example schemas in the generated OpenAPI specification.
For example,
Using the
openapi:Example
annotation@openapi:Example { value: { id: 10, name: "Jessica Smith" } } type User record { int id; string name }
Using the
openapi:Examples
annotation@openapi:Examples { Jessica: { // Example 1 value: { id: 10, name: "Jessica Smith" } }, Ron: { // Example 2 value: { id: 11, name: "Ron Stewart" } } } type User record { int id; string name }
-
Provided a flag to generate the Ballerina client/service adhering to Ballerina naming conventions. To enable this feature, use the
--use-sanitized-oas
flag in the OpenAPI client/service CLI command. This an experimental feature.$ bal openapi -i <yml file> --mode <client|service> --use-sanitized-oas
Persist tool
-
Introduced a new option to the
persist generate
command to provide a test datastore. This will generate a separate client which can be used to mock the actual client. The possible values areh2
for SQL datastores andinmemory
for non-SQL datastores.$ bal persist generate --datastore mysql --module db --test-datastore h2
-
Introduced a new option to the
persist add
command to provide a test datastore. This will generate a separate client which can be used to mock the actual client. The possible values areh2
for SQL datastores andinmemory
for non-SQL datastores.$ bal persist add --datastore mysql --module db --test-datastore h2
-
Added introspection support for
mssql
andpostgres
databases to facilitate the generation of the persist data model.
Improvements
Language Server
- Added navigation and reference-finding support for object
init
functions.
OpenAPI tool
- Added support for Server-sent events (SSE) in Ballerina client generation.
- Added support to specify the path to an example file in JSON format as the
examples
field in the@openapi:ResourceInfo
annotation. - Added support for request body example mapping via the
@openapi:ResourceInfo
annotation.
Bug fixes
To view bug fixes, see the GitHub milestone for Swan Lake Update 10 (2201.10.0) of the repositories below.
Ballerina packages updates
Improvements
-
Resources are now expected at the package level, and module-level resources are no longer supported. Resources that were previously included at module-level have to be moved from modules to the package root to continue to be identified as resources.
Note: Any resources within the current package, as well as those exported from package dependencies, can be accessed via an external function.
- Old package structure
. ├── Ballerina.toml ├── main.bal ├── resources └── modules └── util ├── Module.md ├── tests │ └── lib_test.bal ├── resources │ └── open-api-spec.json └── util.bal
- New package structure
. ├── Ballerina.toml ├── main.bal ├── resources │ └── open-api-spec.json └── modules └── util ├── Module.md ├── tests │ └── lib_test.bal └── util.bal
-
Added support to mark a Java dependency as GraalVM compatible in the
Ballerina.toml
file as follows.[[platform.java11.dependency]] groupId = "" artifactId = " " version = " " graalvmCompatible = true -
Introduced an experimental build option to enable memory-efficient compilation for large packages to prevent out-of-memory issues that can happen during the initial compilation which happens with a clean Central cache.
$ bal build --optimize-dependency-compilation
Backward-incompatible changes
Language changes
A bug that caused an invalid static type to be set for optional XML attribute access on xml:Element
has been fixed for compliance with the specification. The static type now includes error
.
public function main() { xml:Element xe = xml `<x attr="e"/>`; string? attr = xe?.attr; // Compile-time error now. }