Skip to content

Commit

Permalink
Merge pull request #544 from ravinperera00/java21_sync
Browse files Browse the repository at this point in the history
Migrate to Java 21
  • Loading branch information
warunalakshitha authored Nov 18, 2024
2 parents a388b71 + 950b630 commit fc91ba3
Show file tree
Hide file tree
Showing 14 changed files with 52 additions and 119 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,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/)
Expand Down
18 changes: 9 additions & 9 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
[package]
org = "ballerina"
name = "file"
version = "1.10.0"
version = "1.10.1"
authors = ["Ballerina"]
keywords = ["file", "path", "directory", "filepath"]
repository = "https://github.com/ballerina-platform/module-ballerina-file"
icon = "icon.png"
license = ["Apache-2.0"]
distribution = "2201.10.0"
distribution = "2201.11.0-20241112-214900-6b80ab87"

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

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "file-native"
version = "1.10.0"
path = "../native/build/libs/file-native-1.10.0.jar"
version = "1.10.1"
path = "../native/build/libs/file-native-1.10.1-SNAPSHOT.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
path = "./lib/org.wso2.transport.local-file-system-6.0.55.jar"

[[platform.java17.dependency]]
path = "../test-utils/build/libs/file-test-utils-1.10.0.jar"
[[platform.java21.dependency]]
path = "../test-utils/build/libs/file-test-utils-1.10.1-SNAPSHOT.jar"
scope = "testOnly"
2 changes: 1 addition & 1 deletion ballerina/CompilerPlugin.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ id = "file-compiler-plugin"
class = "io.ballerina.stdlib.file.compiler.FileCompilerPlugin"

[[dependency]]
path = "../compiler-plugin/build/libs/file-compiler-plugin-1.10.0.jar"
path = "../compiler-plugin/build/libs/file-compiler-plugin-1.10.1-SNAPSHOT.jar"
10 changes: 5 additions & 5 deletions ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

[ballerina]
dependencies-toml-version = "2"
distribution-version = "2201.10.0"
distribution-version = "2201.11.0-20241112-214900-6b80ab87"

[[package]]
org = "ballerina"
name = "file"
version = "1.10.0"
version = "1.10.1"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"},
Expand All @@ -27,7 +27,7 @@ modules = [
[[package]]
org = "ballerina"
name = "io"
version = "1.6.0"
version = "1.6.2"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.value"}
Expand Down Expand Up @@ -114,7 +114,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "os"
version = "1.8.0"
version = "1.8.1"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"}
Expand All @@ -140,7 +140,7 @@ modules = [
[[package]]
org = "ballerina"
name = "time"
version = "2.4.0"
version = "2.6.0"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]
Expand Down
10 changes: 5 additions & 5 deletions build-config/resources/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ keywords = ["file", "path", "directory", "filepath"]
repository = "https://github.com/ballerina-platform/module-ballerina-file"
icon = "icon.png"
license = ["Apache-2.0"]
distribution = "2201.10.0"
distribution = "2201.11.0-20241112-214900-6b80ab87"

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

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

[[platform.java17.dependency]]
[[platform.java21.dependency]]
path = "./lib/[email protected]@.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
path = "../test-utils/build/libs/[email protected]@.jar"
scope = "testOnly"
7 changes: 5 additions & 2 deletions compiler-plugin-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,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
Expand Down
7 changes: 5 additions & 2 deletions compiler-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,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
Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
org.gradle.caching=true
group=io.ballerina.stdlib
version=1.10.1-SNAPSHOT
ballerinaLangVersion=2201.10.0
ballerinaLangVersion=2201.11.0-20241112-214900-6b80ab87

testngVersion=7.6.1
checkstylePluginVersion=10.12.0
slf4jVersion=1.7.30
ballerinaGradlePluginVersion=2.0.1
githubSpotbugsVersion=5.0.14
githubSpotbugsVersion=6.0.18
githubJohnrengelmanShadowVersion=8.1.1
underCouchDownloadVersion=5.4.0
researchgateReleaseVersion=2.8.0

transportVersion=6.0.55
stdlibTimeVersion=2.4.0
stdlibIoVersion=1.6.0
stdlibLogVersion=2.10.0
stdlibOsVersion=1.8.0
observeVersion=1.3.0
observeInternalVersion=1.3.0
stdlibTimeVersion=2.6.0-20241113-073800-201b904
stdlibIoVersion=1.6.2-20241112-233100-995cf5f
stdlibLogVersion=2.10.1-20241113-120000-4577868
stdlibOsVersion=1.8.1-20241113-122000-cca973b
observeVersion=1.4.0-20241113-092000-b83ae74
observeInternalVersion=1.3.1-20241113-101700-265054d
7 changes: 5 additions & 2 deletions native/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@

package io.ballerina.stdlib.file.nativeimpl;

import io.ballerina.runtime.api.PredefinedTypes;
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.ArrayType;
import io.ballerina.runtime.api.types.Field;
import io.ballerina.runtime.api.types.PredefinedTypes;
import io.ballerina.runtime.api.types.RecordType;
import io.ballerina.runtime.api.types.Type;
import io.ballerina.runtime.api.utils.StringUtils;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,76 +18,39 @@

package io.ballerina.stdlib.file.service;

import io.ballerina.runtime.api.PredefinedTypes;
import io.ballerina.runtime.api.Runtime;
import io.ballerina.runtime.api.async.StrandMetadata;
import io.ballerina.runtime.api.creators.ValueCreator;
import io.ballerina.runtime.api.types.MethodType;
import io.ballerina.runtime.api.types.ObjectType;
import io.ballerina.runtime.api.utils.StringUtils;
import io.ballerina.runtime.api.utils.TypeUtils;
import io.ballerina.runtime.api.values.BMap;
import io.ballerina.runtime.api.values.BObject;
import io.ballerina.runtime.api.values.BString;
import io.ballerina.stdlib.file.utils.FileConstants;
import io.ballerina.stdlib.file.utils.ModuleUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.wso2.transport.localfilesystem.server.connector.contract.LocalFileSystemEvent;
import org.wso2.transport.localfilesystem.server.connector.contract.LocalFileSystemListener;

import java.util.HashMap;
import java.util.Map;

import static io.ballerina.stdlib.file.service.DirectoryListenerConstants.FILE_SYSTEM_EVENT;
import static io.ballerina.stdlib.file.service.DirectoryListenerConstants.RESOURCE_NAME_ON_MESSAGE;

/**
* File System connector listener for Ballerina.
*/
public class FSListener implements LocalFileSystemListener {

private static final Logger log = LoggerFactory.getLogger(FSListener.class);
private Runtime runtime;
private Map<BObject, Map<String, MethodType>> serviceRegistry = new HashMap<>();
private static final StrandMetadata ON_MESSAGE_METADATA = new StrandMetadata(ModuleUtils.getModule().getOrg(),
ModuleUtils.getModule().getName(), ModuleUtils.getModule().getVersion(), RESOURCE_NAME_ON_MESSAGE);

public FSListener(Runtime runtime) {
this.runtime = runtime;
}

@Override
public void onMessage(LocalFileSystemEvent fileEvent) {
Object[] parameters = getJvmSignatureParameters(fileEvent);
for (Map.Entry<BObject, Map<String, MethodType>> serviceEntry: serviceRegistry.entrySet()) {
MethodType serviceFunction = serviceEntry.getValue().get(fileEvent.getEvent());
if (serviceFunction != null) {
String functionName = serviceFunction.getName();
BObject service = serviceEntry.getKey();
ObjectType type = (ObjectType) TypeUtils.getReferredType(TypeUtils.getType(service));
if (type.isIsolated() && type.isIsolated(functionName)) {
runtime.invokeMethodAsyncConcurrently(service, functionName, null,
ON_MESSAGE_METADATA, new DirectoryCallback(), null, PredefinedTypes.TYPE_NULL,
parameters);
} else {
runtime.invokeMethodAsyncSequentially(service, functionName, null,
ON_MESSAGE_METADATA, new DirectoryCallback(), null, PredefinedTypes.TYPE_NULL,
parameters);
}
runtime.callMethod(service, functionName, null);
}
}
}

private Object[] getJvmSignatureParameters(LocalFileSystemEvent fileEvent) {
BMap<BString, Object> eventStruct = ValueCreator.createRecordValue(ModuleUtils.getModule(), FILE_SYSTEM_EVENT);
eventStruct.put(StringUtils.fromString(FileConstants.FILE_EVENT_NAME),
StringUtils.fromString(fileEvent.getFileName()));
eventStruct.put(StringUtils.fromString(FileConstants.FILE_EVENT_OPERATION),
StringUtils.fromString(fileEvent.getEvent()));
return new Object[] { eventStruct, true };
}

public void addService(BObject service, Map<String, MethodType> attachedFunctions) {
this.serviceRegistry.put(service, attachedFunctions);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static Object getMetaData(File inputFile) throws IOException {
public static String getSystemProperty(String key) {
String value = System.getProperty(key);
if (value == null) {
return io.ballerina.runtime.api.PredefinedTypes.TYPE_STRING.getZeroValue();
return io.ballerina.runtime.api.types.PredefinedTypes.TYPE_STRING.getZeroValue();
}
return value;
}
Expand Down
7 changes: 5 additions & 2 deletions test-utils/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,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
Expand Down

0 comments on commit fc91ba3

Please sign in to comment.