Skip to content

Commit

Permalink
Migrate to Java 21
Browse files Browse the repository at this point in the history
  • Loading branch information
warunalakshitha committed Sep 26, 2024
1 parent 8d1fa0f commit 95a0752
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ This repository only contains the source code for the module.

### 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/)

Expand Down
6 changes: 3 additions & 3 deletions build-config/resources/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ icon = "icon.png"
license = ["Apache-2.0"]
distribution = "2201.8.0"

[platform.java17]
[platform.java21]
graalvmCompatible = true

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "io-native"
path = "../native/build/libs/[email protected]@.jar"
version = "@toml.version@"


[[platform.java17.dependency]]
[[platform.java21.dependency]]
path = "../test-utils/build/libs/[email protected]@.jar"
scope = "testOnly"
version = "@project.version@"
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
org.gradle.caching=true
group=io.ballerina.stdlib
version=1.6.2-SNAPSHOT
ballerinaLangVersion=2201.8.0
ballerinaLangVersion=2201.10.0-SNAPSHOT
puppycrawlCheckstyleVersion=10.12.0
testngVersion=7.6.1
slf4jVersion=1.7.30
jacocoVersion=0.8.10
githubSpotbugsVersion=5.0.14
githubSpotbugsVersion=6.0.18
githubJohnrengelmanShadowVersion=8.1.1
underCouchDownloadVersion=5.4.0
researchgateReleaseVersion=2.8.0
Expand Down
7 changes: 5 additions & 2 deletions native/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@ jacocoTestReport {
}

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")
ignoreFailures = true
effort = "max"
reportLevel = "low"
effort = SpotBugsEffort.MAX
reportLevel = SpotBugsConfidence.LOW
reportsDir = file("$project.buildDir/reports/spotbugs")
def excludeFile = file("${rootDir}/build-config/spotbugs-exclude.xml")
if (excludeFile.exists()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
package io.ballerina.stdlib.io.nativeimpl;

import io.ballerina.runtime.api.Environment;
import io.ballerina.runtime.api.Future;
import io.ballerina.runtime.api.creators.ErrorCreator;
import io.ballerina.runtime.api.utils.StringUtils;
import io.ballerina.runtime.api.values.BString;

import java.io.PrintStream;
import java.nio.charset.Charset;
import java.util.Scanner;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.CompletableFuture;

/**
* Extern function ballerina/io:readln.
Expand All @@ -36,15 +36,20 @@ public class ReadlnAny {

private static final Scanner sc = new Scanner(System.in, Charset.defaultCharset().displayName());
private static final PrintStream printStream = System.out;
private static final ExecutorService executor = Executors.newSingleThreadExecutor();

private ReadlnAny() {}

public static void readln(Environment env, Object result) {
public static BString readln(Environment env, Object result) {
if (result != null) {
printStream.print(result);
}
Future balFuture = env.markAsync();
executor.execute(() -> balFuture.complete(StringUtils.fromString(sc.nextLine())));
env.markAsync();
CompletableFuture<BString> future = new CompletableFuture<>();
Thread.startVirtualThread(() -> future.complete(StringUtils.fromString(sc.nextLine())));
try {
return future.get();
} catch (Throwable e) {
throw ErrorCreator.createError(e);
}
}
}
7 changes: 5 additions & 2 deletions test-utils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ dependencies {
}

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")
ignoreFailures = true
effort = "max"
reportLevel = "low"
effort = SpotBugsEffort.MAX
reportLevel = SpotBugsConfidence.LOW
reportsDir = file("$project.buildDir/reports/spotbugs")
def excludeFile = file("${rootDir}/build-config/spotbugs-exclude.xml")
if (excludeFile.exists()) {
Expand Down

0 comments on commit 95a0752

Please sign in to comment.