- 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 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 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.
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 by
clause 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
collect
clause 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
ID
scalar type. - Added support for the input constraint validation.
persist
package
- Added support for the
mssql
data store.
Deprecations
http
package
- Deprecated the usage of adding interceptors in the
http:ListenerConfiguration
record.http:InterceptableService
should 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
workspaceProjects
to 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-binding
flag 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 this
code 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
--native
flag to--graalvm
. - Introduced the
--graalvm-build-options
build 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-
isolated
function type in a function or method call expression within anisolated
function 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.bar
module in theConfig.toml
file, 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]'