From 1b0e6953c5455c1917cbc659e4b8af441d82181b Mon Sep 17 00:00:00 2001 From: ravinperera00 Date: Wed, 20 Nov 2024 13:14:23 +0530 Subject: [PATCH] Migrate to Java 21 and new Runtime APIs --- .../workflows/build-timestamped-master.yml | 2 +- .../workflows/build-with-bal-test-graalvm.yml | 2 +- .github/workflows/central-publish.yml | 2 +- .github/workflows/publish-release.yml | 2 +- .github/workflows/pull-request.yml | 2 +- .github/workflows/trivy-scan.yml | 2 +- README.md | 2 +- .../Ballerina.toml | 6 +- .../Dependencies.toml | 8 +- ballerina-tests/csv-commons/Ballerina.toml | 2 +- ballerina-tests/csv-commons/Dependencies.toml | 4 +- .../parse-list-types-tests/Ballerina.toml | 6 +- .../parse-list-types-tests/Dependencies.toml | 8 +- .../parse-record-types-tests/Ballerina.toml | 6 +- .../Dependencies.toml | 8 +- .../Ballerina.toml | 6 +- .../Dependencies.toml | 8 +- .../Ballerina.toml | 6 +- .../Dependencies.toml | 8 +- .../type-compatible-tests/Ballerina.toml | 6 +- .../type-compatible-tests/Dependencies.toml | 10 +-- ballerina-tests/unicode-tests/Ballerina.toml | 6 +- .../unicode-tests/Dependencies.toml | 6 +- .../union-type-tests/Ballerina.toml | 6 +- .../union-type-tests/Dependencies.toml | 8 +- .../user-config-tests/Ballerina.toml | 6 +- .../user-config-tests/Dependencies.toml | 8 +- ballerina/Ballerina.toml | 18 ++--- ballerina/CompilerPlugin.toml | 2 +- ballerina/Dependencies.toml | 4 +- build-config/resources/Ballerina.toml | 8 +- build-config/resources/BallerinaTest.toml | 2 +- compiler-plugin-test/build.gradle | 7 +- compiler-plugin/build.gradle | 7 +- gradle.properties | 14 ++-- native/build.gradle | 7 +- .../lib/data/csvdata/FromString.java | 4 +- .../lib/data/csvdata/csv/CsvCreator.java | 4 +- .../lib/data/csvdata/csv/CsvParser.java | 4 +- .../lib/data/csvdata/csv/CsvTraversal.java | 4 +- .../lib/data/csvdata/csv/Native.java | 21 +++-- .../io/BallerinaByteBlockInputStream.java | 79 +++++++------------ .../lib/data/csvdata/io/DataReaderTask.java | 8 +- .../lib/data/csvdata/utils/CsvUtils.java | 2 +- 44 files changed, 166 insertions(+), 175 deletions(-) diff --git a/.github/workflows/build-timestamped-master.yml b/.github/workflows/build-timestamped-master.yml index 72d594a..6411caf 100644 --- a/.github/workflows/build-timestamped-master.yml +++ b/.github/workflows/build-timestamped-master.yml @@ -14,5 +14,5 @@ jobs: call_workflow: name: Run Build Workflow if: ${{ github.repository_owner == 'ballerina-platform' }} - uses: ballerina-platform/ballerina-library/.github/workflows/build-timestamp-master-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/build-timestamp-master-template.yml@java21 secrets: inherit diff --git a/.github/workflows/build-with-bal-test-graalvm.yml b/.github/workflows/build-with-bal-test-graalvm.yml index 77a583e..8919b1b 100644 --- a/.github/workflows/build-with-bal-test-graalvm.yml +++ b/.github/workflows/build-with-bal-test-graalvm.yml @@ -30,7 +30,7 @@ jobs: call_stdlib_workflow: name: Run StdLib Workflow if: ${{ github.event_name != 'schedule' || (github.event_name == 'schedule' && github.repository_owner == 'ballerina-platform') }} - uses: ballerina-platform/ballerina-library/.github/workflows/build-with-bal-test-graalvm-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/build-with-bal-test-graalvm-template.yml@java21 with: lang_tag: ${{ inputs.lang_tag }} lang_version: ${{ inputs.lang_version }} diff --git a/.github/workflows/central-publish.yml b/.github/workflows/central-publish.yml index 11922b5..ebe213e 100644 --- a/.github/workflows/central-publish.yml +++ b/.github/workflows/central-publish.yml @@ -15,7 +15,7 @@ jobs: call_workflow: name: Run Central Publish Workflow if: ${{ github.repository_owner == 'ballerina-platform' }} - uses: ballerina-platform/ballerina-library/.github/workflows/central-publish-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/central-publish-template.yml@java21 secrets: inherit with: environment: ${{ github.event.inputs.environment }} diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 0edaae9..638794b 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -9,7 +9,7 @@ jobs: call_workflow: name: Run Release Workflow if: ${{ github.repository_owner == 'ballerina-platform' }} - uses: ballerina-platform/ballerina-library/.github/workflows/release-package-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/release-package-template.yml@java21 secrets: inherit with: package-name: data.csv diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 06f4f56..f45c742 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -10,5 +10,5 @@ jobs: call_workflow: name: Run PR Build Workflow if: ${{ github.repository_owner == 'ballerina-platform' }} - uses: ballerina-platform/ballerina-library/.github/workflows/pull-request-build-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/pull-request-build-template.yml@java21 secrets: inherit diff --git a/.github/workflows/trivy-scan.yml b/.github/workflows/trivy-scan.yml index 2f7999d..684db29 100644 --- a/.github/workflows/trivy-scan.yml +++ b/.github/workflows/trivy-scan.yml @@ -9,5 +9,5 @@ jobs: call_workflow: name: Run Trivy Scan Workflow if: ${{ github.repository_owner == 'ballerina-platform' }} - uses: ballerina-platform/ballerina-library/.github/workflows/trivy-scan-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/trivy-scan-template.yml@java21 secrets: inherit diff --git a/README.md b/README.md index 4236cc1..8ea0566 100644 --- a/README.md +++ b/README.md @@ -162,7 +162,7 @@ This repository only contains the source code for the package. ### Set up the prerequisites -1. Download and install Java SE Development Kit (JDK) version 17 (from one of the following locations). +1. Download and install Java SE Development Kit (JDK) version 21 (from one of the following locations). * [Oracle](https://www.oracle.com/java/technologies/downloads/) * [OpenJDK](https://adoptium.net/) diff --git a/ballerina-tests/constraint-validation-tests/Ballerina.toml b/ballerina-tests/constraint-validation-tests/Ballerina.toml index 84093d9..c0150e4 100644 --- a/ballerina-tests/constraint-validation-tests/Ballerina.toml +++ b/ballerina-tests/constraint-validation-tests/Ballerina.toml @@ -1,15 +1,15 @@ [package] org = "ballerina" name = "constraint_validation_tests" -version = "0.1.0" +version = "0.1.1" [[dependency]] org = "ballerina" name = "csv_commons" repository = "local" -version = "0.1.0" +version = "0.1.1" -[platform.java17] +[platform.java21] graalvmCompatible = true [build-options] diff --git a/ballerina-tests/constraint-validation-tests/Dependencies.toml b/ballerina-tests/constraint-validation-tests/Dependencies.toml index 8c8f80d..ecb2d49 100644 --- a/ballerina-tests/constraint-validation-tests/Dependencies.toml +++ b/ballerina-tests/constraint-validation-tests/Dependencies.toml @@ -5,12 +5,12 @@ [ballerina] dependencies-toml-version = "2" -distribution-version = "2201.10.0" +distribution-version = "2201.11.0-20241117-133400-a3054b77" [[package]] org = "ballerina" name = "constraint" -version = "1.5.0" +version = "1.6.0" scope = "testOnly" dependencies = [ {org = "ballerina", name = "jballerina.java"} @@ -22,7 +22,7 @@ modules = [ [[package]] org = "ballerina" name = "constraint_validation_tests" -version = "0.1.0" +version = "0.1.1" dependencies = [ {org = "ballerina", name = "constraint"}, {org = "ballerina", name = "data.csv"}, @@ -35,7 +35,7 @@ modules = [ [[package]] org = "ballerina" name = "data.csv" -version = "0.1.0" +version = "0.1.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "jballerina.java"} diff --git a/ballerina-tests/csv-commons/Ballerina.toml b/ballerina-tests/csv-commons/Ballerina.toml index 13c0bc8..eab175e 100644 --- a/ballerina-tests/csv-commons/Ballerina.toml +++ b/ballerina-tests/csv-commons/Ballerina.toml @@ -1,7 +1,7 @@ [package] org = "ballerina" name = "csv_commons" -version = "0.1.0" +version = "0.1.1" [platform.java17] graalvmCompatible = true diff --git a/ballerina-tests/csv-commons/Dependencies.toml b/ballerina-tests/csv-commons/Dependencies.toml index 590645d..3e05d30 100644 --- a/ballerina-tests/csv-commons/Dependencies.toml +++ b/ballerina-tests/csv-commons/Dependencies.toml @@ -5,12 +5,12 @@ [ballerina] dependencies-toml-version = "2" -distribution-version = "2201.10.0" +distribution-version = "2201.11.0-20241117-133400-a3054b77" [[package]] org = "ballerina" name = "csv_commons" -version = "0.1.0" +version = "0.1.1" modules = [ {org = "ballerina", packageName = "csv_commons", moduleName = "csv_commons"} ] diff --git a/ballerina-tests/parse-list-types-tests/Ballerina.toml b/ballerina-tests/parse-list-types-tests/Ballerina.toml index 258e9ff..052ec8b 100644 --- a/ballerina-tests/parse-list-types-tests/Ballerina.toml +++ b/ballerina-tests/parse-list-types-tests/Ballerina.toml @@ -1,15 +1,15 @@ [package] org = "ballerina" name = "parse_list_types_tests" -version = "0.1.0" +version = "0.1.1" [[dependency]] org = "ballerina" name = "csv_commons" repository = "local" -version = "0.1.0" +version = "0.1.1" -[platform.java17] +[platform.java21] graalvmCompatible = true [build-options] diff --git a/ballerina-tests/parse-list-types-tests/Dependencies.toml b/ballerina-tests/parse-list-types-tests/Dependencies.toml index 64cbd67..c032f90 100644 --- a/ballerina-tests/parse-list-types-tests/Dependencies.toml +++ b/ballerina-tests/parse-list-types-tests/Dependencies.toml @@ -5,12 +5,12 @@ [ballerina] dependencies-toml-version = "2" -distribution-version = "2201.10.0" +distribution-version = "2201.11.0-20241117-133400-a3054b77" [[package]] org = "ballerina" name = "csv_commons" -version = "0.1.0" +version = "0.1.1" scope = "testOnly" modules = [ {org = "ballerina", packageName = "csv_commons", moduleName = "csv_commons"} @@ -19,7 +19,7 @@ modules = [ [[package]] org = "ballerina" name = "data.csv" -version = "0.1.0" +version = "0.1.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "jballerina.java"} @@ -72,7 +72,7 @@ scope = "testOnly" [[package]] org = "ballerina" name = "parse_list_types_tests" -version = "0.1.0" +version = "0.1.1" dependencies = [ {org = "ballerina", name = "csv_commons"}, {org = "ballerina", name = "data.csv"}, diff --git a/ballerina-tests/parse-record-types-tests/Ballerina.toml b/ballerina-tests/parse-record-types-tests/Ballerina.toml index 7cdb2d4..638105b 100644 --- a/ballerina-tests/parse-record-types-tests/Ballerina.toml +++ b/ballerina-tests/parse-record-types-tests/Ballerina.toml @@ -1,15 +1,15 @@ [package] org = "ballerina" name = "parse_record_types_tests" -version = "0.1.0" +version = "0.1.1" [[dependency]] org = "ballerina" name = "csv_commons" repository = "local" -version = "0.1.0" +version = "0.1.1" -[platform.java17] +[platform.java21] graalvmCompatible = true [build-options] diff --git a/ballerina-tests/parse-record-types-tests/Dependencies.toml b/ballerina-tests/parse-record-types-tests/Dependencies.toml index 1b805c0..e109db0 100644 --- a/ballerina-tests/parse-record-types-tests/Dependencies.toml +++ b/ballerina-tests/parse-record-types-tests/Dependencies.toml @@ -5,12 +5,12 @@ [ballerina] dependencies-toml-version = "2" -distribution-version = "2201.10.0" +distribution-version = "2201.11.0-20241117-133400-a3054b77" [[package]] org = "ballerina" name = "csv_commons" -version = "0.1.0" +version = "0.1.1" scope = "testOnly" modules = [ {org = "ballerina", packageName = "csv_commons", moduleName = "csv_commons"} @@ -19,7 +19,7 @@ modules = [ [[package]] org = "ballerina" name = "data.csv" -version = "0.1.0" +version = "0.1.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "jballerina.java"} @@ -72,7 +72,7 @@ scope = "testOnly" [[package]] org = "ballerina" name = "parse_record_types_tests" -version = "0.1.0" +version = "0.1.1" dependencies = [ {org = "ballerina", name = "csv_commons"}, {org = "ballerina", name = "data.csv"}, diff --git a/ballerina-tests/parse-string-array-types-tests/Ballerina.toml b/ballerina-tests/parse-string-array-types-tests/Ballerina.toml index d1d42fe..3cc8a31 100644 --- a/ballerina-tests/parse-string-array-types-tests/Ballerina.toml +++ b/ballerina-tests/parse-string-array-types-tests/Ballerina.toml @@ -1,15 +1,15 @@ [package] org = "ballerina" name = "parse_string_array_types_tests" -version = "0.1.0" +version = "0.1.1" [[dependency]] org = "ballerina" name = "csv_commons" repository = "local" -version = "0.1.0" +version = "0.1.1" -[platform.java17] +[platform.java21] graalvmCompatible = true [build-options] diff --git a/ballerina-tests/parse-string-array-types-tests/Dependencies.toml b/ballerina-tests/parse-string-array-types-tests/Dependencies.toml index 7e6f6c6..162bb19 100644 --- a/ballerina-tests/parse-string-array-types-tests/Dependencies.toml +++ b/ballerina-tests/parse-string-array-types-tests/Dependencies.toml @@ -5,12 +5,12 @@ [ballerina] dependencies-toml-version = "2" -distribution-version = "2201.10.0" +distribution-version = "2201.11.0-20241117-133400-a3054b77" [[package]] org = "ballerina" name = "csv_commons" -version = "0.1.0" +version = "0.1.1" scope = "testOnly" modules = [ {org = "ballerina", packageName = "csv_commons", moduleName = "csv_commons"} @@ -19,7 +19,7 @@ modules = [ [[package]] org = "ballerina" name = "data.csv" -version = "0.1.0" +version = "0.1.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "jballerina.java"} @@ -72,7 +72,7 @@ scope = "testOnly" [[package]] org = "ballerina" name = "parse_string_array_types_tests" -version = "0.1.0" +version = "0.1.1" dependencies = [ {org = "ballerina", name = "csv_commons"}, {org = "ballerina", name = "data.csv"}, diff --git a/ballerina-tests/parse-string-record-types-tests/Ballerina.toml b/ballerina-tests/parse-string-record-types-tests/Ballerina.toml index 795eb35..a037a40 100644 --- a/ballerina-tests/parse-string-record-types-tests/Ballerina.toml +++ b/ballerina-tests/parse-string-record-types-tests/Ballerina.toml @@ -1,15 +1,15 @@ [package] org = "ballerina" name = "parse_string_record_types_tests" -version = "0.1.0" +version = "0.1.1" [[dependency]] org = "ballerina" name = "csv_commons" repository = "local" -version = "0.1.0" +version = "0.1.1" -[platform.java17] +[platform.java21] graalvmCompatible = true [build-options] diff --git a/ballerina-tests/parse-string-record-types-tests/Dependencies.toml b/ballerina-tests/parse-string-record-types-tests/Dependencies.toml index 0714f9a..a407418 100644 --- a/ballerina-tests/parse-string-record-types-tests/Dependencies.toml +++ b/ballerina-tests/parse-string-record-types-tests/Dependencies.toml @@ -5,12 +5,12 @@ [ballerina] dependencies-toml-version = "2" -distribution-version = "2201.10.0" +distribution-version = "2201.11.0-20241117-133400-a3054b77" [[package]] org = "ballerina" name = "csv_commons" -version = "0.1.0" +version = "0.1.1" scope = "testOnly" modules = [ {org = "ballerina", packageName = "csv_commons", moduleName = "csv_commons"} @@ -19,7 +19,7 @@ modules = [ [[package]] org = "ballerina" name = "data.csv" -version = "0.1.0" +version = "0.1.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "jballerina.java"} @@ -72,7 +72,7 @@ scope = "testOnly" [[package]] org = "ballerina" name = "parse_string_record_types_tests" -version = "0.1.0" +version = "0.1.1" dependencies = [ {org = "ballerina", name = "csv_commons"}, {org = "ballerina", name = "data.csv"}, diff --git a/ballerina-tests/type-compatible-tests/Ballerina.toml b/ballerina-tests/type-compatible-tests/Ballerina.toml index d7661d9..73958e2 100644 --- a/ballerina-tests/type-compatible-tests/Ballerina.toml +++ b/ballerina-tests/type-compatible-tests/Ballerina.toml @@ -1,15 +1,15 @@ [package] org = "ballerina" name = "type_compatible_tests" -version = "0.1.0" +version = "0.1.1" [[dependency]] org = "ballerina" name = "csv_commons" repository = "local" -version = "0.1.0" +version = "0.1.1" -[platform.java17] +[platform.java21] graalvmCompatible = true [build-options] diff --git a/ballerina-tests/type-compatible-tests/Dependencies.toml b/ballerina-tests/type-compatible-tests/Dependencies.toml index adb9d3a..cb7c1e6 100644 --- a/ballerina-tests/type-compatible-tests/Dependencies.toml +++ b/ballerina-tests/type-compatible-tests/Dependencies.toml @@ -5,12 +5,12 @@ [ballerina] dependencies-toml-version = "2" -distribution-version = "2201.10.0" +distribution-version = "2201.11.0-20241117-133400-a3054b77" [[package]] org = "ballerina" name = "csv_commons" -version = "0.1.0" +version = "0.1.1" scope = "testOnly" modules = [ {org = "ballerina", packageName = "csv_commons", moduleName = "csv_commons"} @@ -19,7 +19,7 @@ modules = [ [[package]] org = "ballerina" name = "data.csv" -version = "0.1.0" +version = "0.1.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "jballerina.java"} @@ -31,7 +31,7 @@ modules = [ [[package]] org = "ballerina" name = "io" -version = "1.6.1" +version = "1.6.2" scope = "testOnly" dependencies = [ {org = "ballerina", name = "jballerina.java"}, @@ -108,7 +108,7 @@ modules = [ [[package]] org = "ballerina" name = "type_compatible_tests" -version = "0.1.0" +version = "0.1.1" dependencies = [ {org = "ballerina", name = "csv_commons"}, {org = "ballerina", name = "data.csv"}, diff --git a/ballerina-tests/unicode-tests/Ballerina.toml b/ballerina-tests/unicode-tests/Ballerina.toml index a2cadc0..a83df77 100644 --- a/ballerina-tests/unicode-tests/Ballerina.toml +++ b/ballerina-tests/unicode-tests/Ballerina.toml @@ -1,15 +1,15 @@ [package] org = "ballerina" name = "unicode_tests" -version = "0.1.0" +version = "0.1.1" [[dependency]] org = "ballerina" name = "csv_commons" repository = "local" -version = "0.1.0" +version = "0.1.1" -[platform.java17] +[platform.java21] graalvmCompatible = true [build-options] diff --git a/ballerina-tests/unicode-tests/Dependencies.toml b/ballerina-tests/unicode-tests/Dependencies.toml index 9d8e82b..7409c61 100644 --- a/ballerina-tests/unicode-tests/Dependencies.toml +++ b/ballerina-tests/unicode-tests/Dependencies.toml @@ -5,12 +5,12 @@ [ballerina] dependencies-toml-version = "2" -distribution-version = "2201.10.0" +distribution-version = "2201.11.0-20241117-133400-a3054b77" [[package]] org = "ballerina" name = "data.csv" -version = "0.1.0" +version = "0.1.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "jballerina.java"} @@ -77,7 +77,7 @@ modules = [ [[package]] org = "ballerina" name = "unicode_tests" -version = "0.1.0" +version = "0.1.1" dependencies = [ {org = "ballerina", name = "data.csv"}, {org = "ballerina", name = "test"} diff --git a/ballerina-tests/union-type-tests/Ballerina.toml b/ballerina-tests/union-type-tests/Ballerina.toml index 66da3f7..78d9cc8 100644 --- a/ballerina-tests/union-type-tests/Ballerina.toml +++ b/ballerina-tests/union-type-tests/Ballerina.toml @@ -1,15 +1,15 @@ [package] org = "ballerina" name = "union_type_tests" -version = "0.1.0" +version = "0.1.1" [[dependency]] org = "ballerina" name = "csv_commons" repository = "local" -version = "0.1.0" +version = "0.1.1" -[platform.java17] +[platform.java21] graalvmCompatible = true [build-options] diff --git a/ballerina-tests/union-type-tests/Dependencies.toml b/ballerina-tests/union-type-tests/Dependencies.toml index 8ab953e..067af5f 100644 --- a/ballerina-tests/union-type-tests/Dependencies.toml +++ b/ballerina-tests/union-type-tests/Dependencies.toml @@ -5,12 +5,12 @@ [ballerina] dependencies-toml-version = "2" -distribution-version = "2201.10.0" +distribution-version = "2201.11.0-20241117-133400-a3054b77" [[package]] org = "ballerina" name = "csv_commons" -version = "0.1.0" +version = "0.1.1" scope = "testOnly" modules = [ {org = "ballerina", packageName = "csv_commons", moduleName = "csv_commons"} @@ -19,7 +19,7 @@ modules = [ [[package]] org = "ballerina" name = "data.csv" -version = "0.1.0" +version = "0.1.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "jballerina.java"} @@ -86,7 +86,7 @@ modules = [ [[package]] org = "ballerina" name = "union_type_tests" -version = "0.1.0" +version = "0.1.1" dependencies = [ {org = "ballerina", name = "csv_commons"}, {org = "ballerina", name = "data.csv"}, diff --git a/ballerina-tests/user-config-tests/Ballerina.toml b/ballerina-tests/user-config-tests/Ballerina.toml index 7810c0a..2c89a7e 100644 --- a/ballerina-tests/user-config-tests/Ballerina.toml +++ b/ballerina-tests/user-config-tests/Ballerina.toml @@ -1,15 +1,15 @@ [package] org = "ballerina" name = "user_config_tests" -version = "0.1.0" +version = "0.1.1" [[dependency]] org = "ballerina" name = "csv_commons" repository = "local" -version = "0.1.0" +version = "0.1.1" -[platform.java17] +[platform.java21] graalvmCompatible = true [build-options] diff --git a/ballerina-tests/user-config-tests/Dependencies.toml b/ballerina-tests/user-config-tests/Dependencies.toml index 590aef2..979691d 100644 --- a/ballerina-tests/user-config-tests/Dependencies.toml +++ b/ballerina-tests/user-config-tests/Dependencies.toml @@ -5,12 +5,12 @@ [ballerina] dependencies-toml-version = "2" -distribution-version = "2201.10.0" +distribution-version = "2201.11.0-20241117-133400-a3054b77" [[package]] org = "ballerina" name = "csv_commons" -version = "0.1.0" +version = "0.1.1" scope = "testOnly" modules = [ {org = "ballerina", packageName = "csv_commons", moduleName = "csv_commons"} @@ -19,7 +19,7 @@ modules = [ [[package]] org = "ballerina" name = "data.csv" -version = "0.1.0" +version = "0.1.1" scope = "testOnly" dependencies = [ {org = "ballerina", name = "jballerina.java"} @@ -86,7 +86,7 @@ modules = [ [[package]] org = "ballerina" name = "user_config_tests" -version = "0.1.0" +version = "0.1.1" dependencies = [ {org = "ballerina", name = "csv_commons"}, {org = "ballerina", name = "data.csv"}, diff --git a/ballerina/Ballerina.toml b/ballerina/Ballerina.toml index 1aa9516..1c0c8f9 100644 --- a/ballerina/Ballerina.toml +++ b/ballerina/Ballerina.toml @@ -1,26 +1,26 @@ [package] org = "ballerina" name = "data.csv" -version = "0.1.0" +version = "0.1.1" authors = ["Ballerina"] keywords = ["csv"] repository = "https://github.com/ballerina-platform/module-ballerina-data.csv" license = ["Apache-2.0"] -distribution = "2201.9.0" +distribution = "2201.11.0-20241117-133400-a3054b77" export = ["data.csv"] readme = "Package.md" -[platform.java17] +[platform.java21] graalvmCompatible = true -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.ballerina.lib" artifactId = "data.csv-native" -version = "0.1.0" -path = "../native/build/libs/data.csv-native-0.1.0.jar" +version = "0.1.1" +path = "../native/build/libs/data.csv-native-0.1.1-SNAPSHOT.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.ballerina.stdlib" artifactId = "constraint-native" -version = "1.5.0" -path = "./lib/constraint-native-1.5.0.jar" +version = "1.6.0" +path = "./lib/constraint-native-1.6.0-20241113-090900-d276ad5.jar" diff --git a/ballerina/CompilerPlugin.toml b/ballerina/CompilerPlugin.toml index beabd70..ed30d28 100644 --- a/ballerina/CompilerPlugin.toml +++ b/ballerina/CompilerPlugin.toml @@ -3,4 +3,4 @@ id = "data.csv-compiler-plugin" class = "io.ballerina.lib.data.csvdata.compiler.CsvDataCompilerPlugin" [[dependency]] -path = "../compiler-plugin/build/libs/data.csv-compiler-plugin-0.1.0.jar" +path = "../compiler-plugin/build/libs/data.csv-compiler-plugin-0.1.1-SNAPSHOT.jar" diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index 61e4fbe..343d070 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -5,12 +5,12 @@ [ballerina] dependencies-toml-version = "2" -distribution-version = "2201.10.0" +distribution-version = "2201.11.0-20241117-133400-a3054b77" [[package]] org = "ballerina" name = "data.csv" -version = "0.1.0" +version = "0.1.1" dependencies = [ {org = "ballerina", name = "jballerina.java"} ] diff --git a/build-config/resources/Ballerina.toml b/build-config/resources/Ballerina.toml index d846308..919f4b6 100644 --- a/build-config/resources/Ballerina.toml +++ b/build-config/resources/Ballerina.toml @@ -6,20 +6,20 @@ authors = ["Ballerina"] keywords = ["csv"] repository = "https://github.com/ballerina-platform/module-ballerina-data.csv" license = ["Apache-2.0"] -distribution = "2201.9.0" +distribution = "2201.11.0-20241117-133400-a3054b77" export = ["data.csv"] readme = "Package.md" -[platform.java17] +[platform.java21] graalvmCompatible = true -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.ballerina.lib" artifactId = "data.csv-native" version = "@toml.version@" path = "../native/build/libs/data.csv-native-@project.version@.jar" -[[platform.java17.dependency]] +[[platform.java21.dependency]] groupId = "io.ballerina.stdlib" artifactId = "constraint-native" version = "@constraint.version@" diff --git a/build-config/resources/BallerinaTest.toml b/build-config/resources/BallerinaTest.toml index 5b44930..9234a3b 100644 --- a/build-config/resources/BallerinaTest.toml +++ b/build-config/resources/BallerinaTest.toml @@ -9,7 +9,7 @@ name = "@test.common@" repository = "local" version = "@toml.version@" -[platform.java17] +[platform.java21] graalvmCompatible = true [build-options] diff --git a/compiler-plugin-test/build.gradle b/compiler-plugin-test/build.gradle index 1ad7000..4c76cd2 100644 --- a/compiler-plugin-test/build.gradle +++ b/compiler-plugin-test/build.gradle @@ -49,8 +49,11 @@ checkstyle { checkstyleTest.dependsOn(":checkstyle:downloadCheckstyleRuleFiles") spotbugsTest { - effort "max" - reportLevel "low" + def classLoader = plugins["com.github.spotbugs"].class.classLoader + def SpotBugsConfidence = classLoader.findLoadedClass("com.github.spotbugs.snom.Confidence") + def SpotBugsEffort = classLoader.findLoadedClass("com.github.spotbugs.snom.Effort") + effort = SpotBugsEffort.MAX + reportLevel = SpotBugsConfidence.LOW reportsDir = file("$project.buildDir/reports/spotbugs") reports { html.enabled true diff --git a/compiler-plugin/build.gradle b/compiler-plugin/build.gradle index f30d515..fc3c673 100644 --- a/compiler-plugin/build.gradle +++ b/compiler-plugin/build.gradle @@ -47,8 +47,11 @@ checkstyle { checkstyleMain.dependsOn(":checkstyle:downloadCheckstyleRuleFiles") spotbugsMain { - effort "max" - reportLevel "low" + def classLoader = plugins["com.github.spotbugs"].class.classLoader + def SpotBugsConfidence = classLoader.findLoadedClass("com.github.spotbugs.snom.Confidence") + def SpotBugsEffort = classLoader.findLoadedClass("com.github.spotbugs.snom.Effort") + effort = SpotBugsEffort.MAX + reportLevel = SpotBugsConfidence.LOW reportsDir = file("$project.buildDir/reports/spotbugs") reports { html.enabled true diff --git a/gradle.properties b/gradle.properties index 76ad3b0..18f6d14 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,14 +1,14 @@ org.gradle.caching=true group=io.ballerina.lib version=0.1.1-SNAPSHOT -ballerinaLangVersion=2201.10.0 +ballerinaLangVersion=2201.11.0-20241117-133400-a3054b77 ballerinaTomlParserVersion=1.2.2 checkstyleToolVersion=10.12.0 puppycrawlCheckstyleVersion=10.12.0 testngVersion=7.6.1 slf4jVersion=2.0.7 -spotbugsVersion=5.0.14 +spotbugsVersion=6.0.18 shadowJarPluginVersion=8.1.1 downloadPluginVersion=4.0.4 releasePluginVersion=2.8.0 @@ -17,8 +17,8 @@ javaJsonPathVersion=2.9.0 javaJsonSmartVersion=2.4.11 javaAccessorsSmartVersion=2.4.7 -stdlibFileVersion=1.9.0 -stdlibIoVersion=1.6.0 -stdlibOsVersion=1.8.0 -stdlibTimeVersion=2.4.0 -stdlibConstraintVersion=1.5.0 +stdlibFileVersion=1.10.1-20241113-151700-e1a2e38 +stdlibIoVersion=1.6.2-20241112-233100-995cf5f +stdlibOsVersion=1.8.1-20241113-122000-cca973b +stdlibTimeVersion=2.6.0-20241113-073800-201b904 +stdlibConstraintVersion=1.6.0-20241113-090900-d276ad5 diff --git a/native/build.gradle b/native/build.gradle index 2fef0f3..1cb0ec1 100644 --- a/native/build.gradle +++ b/native/build.gradle @@ -50,9 +50,12 @@ tasks.withType(Checkstyle) { } spotbugsMain { + def classLoader = plugins["com.github.spotbugs"].class.classLoader + def SpotBugsConfidence = classLoader.findLoadedClass("com.github.spotbugs.snom.Confidence") + def SpotBugsEffort = classLoader.findLoadedClass("com.github.spotbugs.snom.Effort") + effort = SpotBugsEffort.MAX + reportLevel = SpotBugsConfidence.LOW enabled=false - effort "max" - reportLevel "low" reportsDir = file("$project.buildDir/reports/spotbugs") reports { html.enabled true diff --git a/native/src/main/java/io/ballerina/lib/data/csvdata/FromString.java b/native/src/main/java/io/ballerina/lib/data/csvdata/FromString.java index c831bf9..9fb6fb4 100644 --- a/native/src/main/java/io/ballerina/lib/data/csvdata/FromString.java +++ b/native/src/main/java/io/ballerina/lib/data/csvdata/FromString.java @@ -21,15 +21,15 @@ import io.ballerina.lib.data.csvdata.utils.Constants; import io.ballerina.lib.data.csvdata.utils.CsvConfig; import io.ballerina.lib.data.csvdata.utils.CsvUtils; -import io.ballerina.runtime.api.PredefinedTypes; -import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.creators.ErrorCreator; import io.ballerina.runtime.api.creators.TypeCreator; import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.types.FiniteType; import io.ballerina.runtime.api.types.IntersectionType; +import io.ballerina.runtime.api.types.PredefinedTypes; import io.ballerina.runtime.api.types.ReferenceType; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.types.TypeTags; import io.ballerina.runtime.api.types.UnionType; import io.ballerina.runtime.api.utils.StringUtils; import io.ballerina.runtime.api.utils.TypeUtils; diff --git a/native/src/main/java/io/ballerina/lib/data/csvdata/csv/CsvCreator.java b/native/src/main/java/io/ballerina/lib/data/csvdata/csv/CsvCreator.java index 7411e3e..23e35aa 100644 --- a/native/src/main/java/io/ballerina/lib/data/csvdata/csv/CsvCreator.java +++ b/native/src/main/java/io/ballerina/lib/data/csvdata/csv/CsvCreator.java @@ -23,15 +23,15 @@ import io.ballerina.lib.data.csvdata.utils.CsvUtils; import io.ballerina.lib.data.csvdata.utils.DiagnosticErrorCode; import io.ballerina.lib.data.csvdata.utils.DiagnosticLog; -import io.ballerina.runtime.api.PredefinedTypes; -import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.flags.SymbolFlags; import io.ballerina.runtime.api.types.ArrayType; import io.ballerina.runtime.api.types.Field; import io.ballerina.runtime.api.types.MapType; +import io.ballerina.runtime.api.types.PredefinedTypes; import io.ballerina.runtime.api.types.TupleType; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.types.TypeTags; import io.ballerina.runtime.api.utils.StringUtils; import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; diff --git a/native/src/main/java/io/ballerina/lib/data/csvdata/csv/CsvParser.java b/native/src/main/java/io/ballerina/lib/data/csvdata/csv/CsvParser.java index 1f9f650..0566cbc 100644 --- a/native/src/main/java/io/ballerina/lib/data/csvdata/csv/CsvParser.java +++ b/native/src/main/java/io/ballerina/lib/data/csvdata/csv/CsvParser.java @@ -24,8 +24,6 @@ import io.ballerina.lib.data.csvdata.utils.DataUtils; import io.ballerina.lib.data.csvdata.utils.DiagnosticErrorCode; import io.ballerina.lib.data.csvdata.utils.DiagnosticLog; -import io.ballerina.runtime.api.PredefinedTypes; -import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.creators.TypeCreator; import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.flags.SymbolFlags; @@ -33,9 +31,11 @@ import io.ballerina.runtime.api.types.Field; import io.ballerina.runtime.api.types.IntersectionType; import io.ballerina.runtime.api.types.MapType; +import io.ballerina.runtime.api.types.PredefinedTypes; import io.ballerina.runtime.api.types.RecordType; import io.ballerina.runtime.api.types.TupleType; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.types.TypeTags; import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BError; diff --git a/native/src/main/java/io/ballerina/lib/data/csvdata/csv/CsvTraversal.java b/native/src/main/java/io/ballerina/lib/data/csvdata/csv/CsvTraversal.java index cc80b24..b60c016 100644 --- a/native/src/main/java/io/ballerina/lib/data/csvdata/csv/CsvTraversal.java +++ b/native/src/main/java/io/ballerina/lib/data/csvdata/csv/CsvTraversal.java @@ -23,8 +23,6 @@ import io.ballerina.lib.data.csvdata.utils.DataUtils; import io.ballerina.lib.data.csvdata.utils.DiagnosticErrorCode; import io.ballerina.lib.data.csvdata.utils.DiagnosticLog; -import io.ballerina.runtime.api.PredefinedTypes; -import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.creators.TypeCreator; import io.ballerina.runtime.api.creators.ValueCreator; import io.ballerina.runtime.api.flags.SymbolFlags; @@ -32,9 +30,11 @@ import io.ballerina.runtime.api.types.Field; import io.ballerina.runtime.api.types.IntersectionType; import io.ballerina.runtime.api.types.MapType; +import io.ballerina.runtime.api.types.PredefinedTypes; import io.ballerina.runtime.api.types.RecordType; import io.ballerina.runtime.api.types.TupleType; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.types.TypeTags; import io.ballerina.runtime.api.types.UnionType; import io.ballerina.runtime.api.utils.StringUtils; import io.ballerina.runtime.api.utils.TypeUtils; diff --git a/native/src/main/java/io/ballerina/lib/data/csvdata/csv/Native.java b/native/src/main/java/io/ballerina/lib/data/csvdata/csv/Native.java index 619e01d..3364208 100644 --- a/native/src/main/java/io/ballerina/lib/data/csvdata/csv/Native.java +++ b/native/src/main/java/io/ballerina/lib/data/csvdata/csv/Native.java @@ -25,7 +25,6 @@ import io.ballerina.lib.data.csvdata.utils.DiagnosticErrorCode; import io.ballerina.lib.data.csvdata.utils.DiagnosticLog; import io.ballerina.runtime.api.Environment; -import io.ballerina.runtime.api.Future; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BError; import io.ballerina.runtime.api.values.BMap; @@ -38,6 +37,8 @@ import java.io.InputStreamReader; import java.io.StringReader; import java.nio.charset.Charset; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; /** * Csv conversion. @@ -76,12 +77,18 @@ public static Object parseStream(Environment env, BStream csv, BMap options, BTypedesc type) { try { final BObject iteratorObj = csv.getIteratorObj(); - final Future future = env.markAsync(); - DataReaderTask task = new DataReaderTask(env, iteratorObj, future, type, - CsvConfig.createParseOptions(options), - options.getStringValue(Constants.ConfigConstants.ENCODING)); - DataReaderThreadPool.EXECUTOR_SERVICE.submit(task); - return null; + return env.yieldAndRun(() -> { + CompletableFuture future = new CompletableFuture<>(); + DataReaderTask task = new DataReaderTask(env, iteratorObj, future, type, + CsvConfig.createParseOptions(options), + options.getStringValue(Constants.ConfigConstants.ENCODING)); + DataReaderThreadPool.EXECUTOR_SERVICE.submit(task); + try { + return future.get(); + } catch (BError | InterruptedException | ExecutionException bError) { + return bError; + } + }); } catch (BError e) { return e; } catch (Exception e) { diff --git a/native/src/main/java/io/ballerina/lib/data/csvdata/io/BallerinaByteBlockInputStream.java b/native/src/main/java/io/ballerina/lib/data/csvdata/io/BallerinaByteBlockInputStream.java index 63c3945..67ab3a5 100644 --- a/native/src/main/java/io/ballerina/lib/data/csvdata/io/BallerinaByteBlockInputStream.java +++ b/native/src/main/java/io/ballerina/lib/data/csvdata/io/BallerinaByteBlockInputStream.java @@ -20,10 +20,7 @@ import io.ballerina.lib.data.csvdata.utils.DiagnosticLog; import io.ballerina.runtime.api.Environment; -import io.ballerina.runtime.api.async.Callback; -import io.ballerina.runtime.api.async.StrandMetadata; import io.ballerina.runtime.api.types.MethodType; -import io.ballerina.runtime.api.types.Type; import io.ballerina.runtime.api.values.BArray; import io.ballerina.runtime.api.values.BError; import io.ballerina.runtime.api.values.BMap; @@ -33,7 +30,6 @@ import java.io.IOException; import java.io.InputStream; import java.util.Arrays; -import java.util.Map; import java.util.concurrent.Semaphore; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; @@ -48,10 +44,6 @@ public class BallerinaByteBlockInputStream extends InputStream { private final BObject iterator; private final Environment env; private final String nextMethodName; - private final Type returnType; - private final String strandName; - private final StrandMetadata metadata; - private final Map properties; private final AtomicBoolean done = new AtomicBoolean(false); private final MethodType closeMethod; private final Consumer futureResultConsumer; @@ -64,11 +56,7 @@ public BallerinaByteBlockInputStream(Environment env, BObject iterator, MethodTy this.env = env; this.iterator = iterator; this.nextMethodName = nextMethod.getName(); - this.returnType = nextMethod.getReturnType(); this.closeMethod = closeMethod; - this.strandName = env.getStrandName().orElse(""); - this.metadata = env.getStrandMetadata(); - this.properties = Map.of(); this.futureResultConsumer = futureResultConsumer; } @@ -99,18 +87,13 @@ public void close() throws IOException { super.close(); Semaphore semaphore = new Semaphore(0); if (closeMethod != null) { - env.getRuntime().invokeMethodAsyncSequentially(iterator, closeMethod.getName(), strandName, metadata, - new Callback() { - @Override - public void notifyFailure(BError bError) { - semaphore.release(); - } + try { + env.getRuntime().callMethod(iterator, closeMethod.getName(), null); + semaphore.release(); + } catch (BError bError) { + semaphore.release(); + } - @Override - public void notifySuccess(Object result) { - semaphore.release(); - } - }, properties, returnType); } try { semaphore.acquire(); @@ -125,41 +108,33 @@ private boolean hasBytesInCurrentChunk() { private boolean readNextChunk() throws InterruptedException { Semaphore semaphore = new Semaphore(0); - Callback callback = new Callback() { - - @Override - public void notifyFailure(BError bError) { - // Panic with an error + try { + Object result = env.getRuntime().callMethod(iterator, nextMethodName, null); + if (result == null) { done.set(true); - futureResultConsumer.accept(bError); currentChunk = new byte[0]; semaphore.release(); + return !done.get(); } - - @Override - public void notifySuccess(Object result) { - if (result == null) { - done.set(true); - currentChunk = new byte[0]; - semaphore.release(); - return; - } - if (result instanceof BMap) { - BMap valueRecord = (BMap) result; - final BString value = Arrays.stream(valueRecord.getKeys()).findFirst().get(); - final BArray arrayValue = valueRecord.getArrayValue(value); - currentChunk = arrayValue.getByteArray(); - semaphore.release(); - } else { - // Case where Completes with an error - done.set(true); - semaphore.release(); - } + if (result instanceof BMap) { + BMap valueRecord = (BMap) result; + final BString value = Arrays.stream(valueRecord.getKeys()).findFirst().get(); + final BArray arrayValue = valueRecord.getArrayValue(value); + currentChunk = arrayValue.getByteArray(); + semaphore.release(); + } else { + // Case where Completes with an error + done.set(true); + semaphore.release(); } + } catch (BError bError) { + // Panic with an error + done.set(true); + futureResultConsumer.accept(bError); + currentChunk = new byte[0]; + semaphore.release(); + } - }; - env.getRuntime().invokeMethodAsyncSequentially(iterator, nextMethodName, strandName, metadata, callback, - properties, returnType); semaphore.acquire(); return !done.get(); } diff --git a/native/src/main/java/io/ballerina/lib/data/csvdata/io/DataReaderTask.java b/native/src/main/java/io/ballerina/lib/data/csvdata/io/DataReaderTask.java index b4186bf..45741c3 100644 --- a/native/src/main/java/io/ballerina/lib/data/csvdata/io/DataReaderTask.java +++ b/native/src/main/java/io/ballerina/lib/data/csvdata/io/DataReaderTask.java @@ -21,7 +21,6 @@ import io.ballerina.lib.data.csvdata.utils.CsvConfig; import io.ballerina.lib.data.csvdata.utils.DiagnosticLog; import io.ballerina.runtime.api.Environment; -import io.ballerina.runtime.api.Future; import io.ballerina.runtime.api.types.MethodType; import io.ballerina.runtime.api.types.ObjectType; import io.ballerina.runtime.api.utils.TypeUtils; @@ -31,6 +30,7 @@ import java.io.InputStreamReader; import java.nio.charset.Charset; +import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; /** @@ -45,12 +45,12 @@ public class DataReaderTask implements Runnable { private final Environment env; private final BObject iteratorObj; - private final Future future; + private final CompletableFuture future; private final BTypedesc typed; private final CsvConfig config; private final BString encoding; - public DataReaderTask(Environment env, BObject iteratorObj, Future future, BTypedesc typed, + public DataReaderTask(Environment env, BObject iteratorObj, CompletableFuture future, BTypedesc typed, CsvConfig config, BString encoding) { this.env = env; this.iteratorObj = iteratorObj; @@ -105,7 +105,7 @@ public void run() { * @param future The future to complete * @since 0.1.0 */ - public record ResultConsumer(Future future) implements Consumer { + public record ResultConsumer(CompletableFuture future) implements Consumer { @Override public void accept(T t) { diff --git a/native/src/main/java/io/ballerina/lib/data/csvdata/utils/CsvUtils.java b/native/src/main/java/io/ballerina/lib/data/csvdata/utils/CsvUtils.java index 73f8dc1..06b3240 100644 --- a/native/src/main/java/io/ballerina/lib/data/csvdata/utils/CsvUtils.java +++ b/native/src/main/java/io/ballerina/lib/data/csvdata/utils/CsvUtils.java @@ -1,6 +1,5 @@ package io.ballerina.lib.data.csvdata.utils; -import io.ballerina.runtime.api.TypeTags; import io.ballerina.runtime.api.flags.SymbolFlags; import io.ballerina.runtime.api.types.ArrayType; import io.ballerina.runtime.api.types.Field; @@ -8,6 +7,7 @@ import io.ballerina.runtime.api.types.RecordType; import io.ballerina.runtime.api.types.TupleType; import io.ballerina.runtime.api.types.Type; +import io.ballerina.runtime.api.types.TypeTags; import io.ballerina.runtime.api.utils.StringUtils; import io.ballerina.runtime.api.utils.TypeUtils; import io.ballerina.runtime.api.utils.ValueUtils;