- 2201.12.10 (Swan Lake Update 12)
- 2201.12.9 (Swan Lake Update 12)
- 2201.12.8 (Swan Lake Update 12)
- 2201.12.7 (Swan Lake Update 12)
- 2201.12.6 (Swan Lake Update 12)
- 2201.12.5 (Swan Lake Update 12)
- 2201.12.4 (Swan Lake Update 12)
- 2201.12.3 (Swan Lake Update 12)
- 2201.12.2 (Swan Lake Update 12)
- 2201.12.1 (Swan Lake Update 12)
- 2201.12.0 (Swan Lake Update 12)
- 2201.8.10 (Swan Lake Update 8)
- 2201.8.9 (Swan Lake Update 8)
- 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)
- 1.2.62
- 1.2.61
- 1.2.60
- 1.2.59
- 1.2.58
- 1.2.57
- 1.2.56
- 1.2.55
- 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 2201.7.0
2201.7.0 (Swan Lake Update 7) is the seventh update release of Ballerina Swan Lake, and it includes a new set of features and significant improvements to the compiler, runtime, standard library, and developer tooling. It is based on the 2023R1 version of the Language Specification.
Update Ballerina
Update your current Ballerina installation directly to 2201.7.0 using the Ballerina Update Tool as follows.
- Run
bal updateto get the latest version of the Update Tool. - Run
bal dist updateto update to this latest distribution.
Install Ballerina
If you have not installed Ballerina, download the installers to install.
Info: From this release onwards, you can verify Ballerina artifacts using the Cosign CLI and Rekor APIs. For more information, see Verify Ballerina artifacts.
Platform updates
Official support for generating GraalVM native executables
Ballerina now officially supports generating GraalVM native executables and the language and the standard libraries are compatible with the GraalVM native executable generation. In addition to that, GraalVM incompatibility warnings will be printed for any incompatible modules in the application. To explore more on this support, see Build a GraalVM executable.
Language updates
New features
Introduction of the group by and collect clauses
The language now supports the features below for query expressions and query actions.
-
The
group byclause is used to group a collection based on a grouping-key. The grouping-key will be unique to each group.import ballerina/io; type Order record {| string name; float price; |}; public function main() { Order[] orders = [{name: "Rich Dad Poor Dad", price: 16.0}, {name: "Becoming", price: 22.5}, {name: "Rich Dad Poor Dad", price: 16.4}, {name: "Becoming", price: 22.6}]; var averages = from var {name, price} in orders group by name select {name, avg: avg(price)}; io:println(averages); // [{"name":"Rich Dad Poor Dad","avg":16.2},{"name":"Becoming","avg":22.55}] } -
The
collectclause is used to group a collection into one group.import ballerina/io; type Order record {| string name; float price; |}; public function main() { Order[] orders = [ {name: "Rich Dad Poor Dad", price: 16.0}, {name: "Becoming", price: 22.6}, {name: "Rich Dad Poor Dad", price: 16.4}, {name: "Becoming", price: 22.5} ]; var average = from var {price} in orders collect avg(price); io:println(average); // 19.375 }
Improvements
Support for constant declarations without a type descriptor
Constants can now be declared without specifying a type descriptor. Previously, it was required to specify a type descriptor except with numeric and string literal expressions.
Both of the following cases are allowed now.
const map<string> HTTP_OK = {httpCode: "200", message: "OK"}; const HTTP_BAD_REQUEST = {httpCode: "400", message: "BAD REQUEST"};
Support for unions as type descriptors in constant declarations
Constant declarations with unions as type descriptors are now supported.
const float|decimal TOTAL = 1 + 2.0;
Support for more recursive type definitions
The type definition resolution logic has been improved to support more recursive type definitions.
type A [A]; type B [B] & readonly;
Bug fixes
To view bug fixes, see the GitHub milestone for 2201.7.0 (Swan Lake).
Runtime updates
Bug fixes
To view bug fixes, see the GitHub milestone for 2201.7.0 (Swan Lake).
Standard library updates
New features
graphql package
- Added support for the
IDscalar type. - Added support for the input constraint validation.
persist package
- Added support for the
mssqldata store.
Deprecations
http package
- Deprecated the usage of adding interceptors in the
http:ListenerConfigurationrecord.http:InterceptableServiceshould be used instead.
Improvements
http package
- Improved the default error format and message.
graphql package
- Improved the validation of duplicate fields with different arguments.
Bug fixes
To view bug fixes, see the GitHub milestone for 2201.7.0 (Swan Lake).
Developer tools updates
New features
Language Server
- Added a new API named
workspaceProjectsto the workspace manager to get the projects loaded onto the workspace.
OpenAPI Tool
- Added support to generate low-level service skeletons without any data-binding logic. This mode can be enabled by adding the
--without-data-bindingflag to the OpenAPI to Ballerina service generation command. This new generation mode will be useful for generating pass-through and proxy services based on a provided OpenAPI contract.
Improvements
Language Server
- Improved the order of the completion items in the client resource access action context.
- Improved the documentation generated by the
Document thiscode action to follow Ballerina coding conventions. - Improved the placeholder support provided for the completion items of the service-template snippets.
OpenAPI tool
- Added auto-generated file headers for all the generated Ballerina files in the OpenAPI to Ballerina service and client generations. Also, the users will have the option to replace the auto-generated headers with their license using the
--license <license-file-path>command option. - Added support for object-typed query parameters in the OpenAPI to Ballerina service generation.
CLI commands
- Renamed the
--nativeflag to--graalvm. - Introduced the
--graalvm-build-optionsbuild option to support passing additional arguments for the GraalVM native image generation.
Bug fixes
To view bug fixes, see the GitHub milestone for 2201.7.0 (Swan Lake) of the repositories below.
Backward-incompatible changes
-
A bug that allowed using a function reference of a non-
isolatedfunction type in a function or method call expression within anisolatedfunction or method has been fixed.type Employee record {| string name; int id; string department; |}; isolated function createEmployee(string[] name, function () returns int idFunction, string department) returns Employee => { name: string:'join(" ", ...name), // Compilation error now, since `idFunction` is not `isolated`. id: idFunction(), department }; -
A bug that caused the broader type to be used instead of the singleton type when a constant is used as a type descriptor has been fixed.
This may result in compilation errors that were previously not identified.
const int CONST = 1 + 7; CONST num = 2; // Compilation error now.This results in a compilation error now since
num, which is of typeCONST, can only be integer8. -
A bug that resulted in compilation errors not being logged for duplicate keys via computed name fields of a mapping constructor in a mapping constant declaration has been fixed. This previously resulted in a panic at runtime instead.
const MESSAGE = "message"; const map<string> HTTP_OK = {httpCode: "200", message: "OK", [MESSAGE] : "BAD REQUEST"}; // Compilation error now. -
Fixed a bug in the configurable TOML syntax validation for the module structure. The error message for an invalid TOML module structure is now improved to provide the variable name.
For example, consider a non-default module named
foo.bar, which contains the following configurable variables.configurable int intVar = ?; configurable string stringVar = ?;If an invalid TOML structure is found for the
foo.barmodule in theConfig.tomlfile, it results in the following error messages.[Config.toml:(1:1,2:23)] invalid TOML structure found for module 'foo.bar' with variable 'intVar'. Please provide the module name as '[foo.bar]' [Config.toml:(1:1,2:23)] invalid TOML structure found for module 'foo.bar' with variable 'stringVar'. Please provide the module name as '[foo.bar]'