Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Java 21 #61

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ import ballerinax/ibm.ibmmq;
Add `com.ibm.mq.allclient` as a platform dependency to the `Ballerina.toml`.

```toml
[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "com.ibm.mq"
artifactId = "com.ibm.mq.allclient"
version = "9.3.4.0"
Expand Down Expand Up @@ -169,7 +169,7 @@ This repository only contains the source code for the library.

### 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
14 changes: 7 additions & 7 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,40 @@ keywords = ["ibm.ibmmq", "client", "messaging", "network", "pubsub"]
repository = "https://github.com/ballerina-platform/module-ballerinax-ibm.ibmmq"
icon = "icon.png"
license = ["Apache-2.0"]
distribution = "2201.9.0"
distribution = "2201.11.0-20241117-133400-a3054b77"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "ibm.ibmmq-native"
version = "1.2.0"
path = "../native/build/libs/ibm.ibmmq-native-1.2.0.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.json"
artifactId = "json"
version = "20231013"
path = "./lib/json-20231013.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "com.ibm.mq"
artifactId = "com.ibm.mq.allclient"
version = "9.3.4.0"
path = "./lib/com.ibm.mq.allclient-9.3.4.0.jar"
scope = "provided"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "com.fasterxml.jackson.core"
artifactId = "jackson-annotations"
version = "2.15.3"
path = "./lib/jackson-annotations-2.15.3.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "com.fasterxml.jackson.core"
artifactId = "jackson-core"
version = "2.15.3"
path = "./lib/jackson-core-2.15.3.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "com.fasterxml.jackson.core"
artifactId = "jackson-databind"
version = "2.15.3"
Expand Down
2 changes: 1 addition & 1 deletion ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

[ballerina]
dependencies-toml-version = "2"
distribution-version = "2201.9.0"
distribution-version = "2201.11.0-20241117-133400-a3054b77"

[[package]]
org = "ballerina"
Expand Down
14 changes: 7 additions & 7 deletions build-config/resources/Ballerina.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,40 @@ keywords = ["ibm.ibmmq", "client", "messaging", "network", "pubsub"]
repository = "https://github.com/ballerina-platform/module-ballerinax-ibm.ibmmq"
icon = "icon.png"
license = ["Apache-2.0"]
distribution = "2201.9.0"
distribution = "2201.11.0-20241117-133400-a3054b77"

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

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.json"
artifactId = "json"
version = "@json.version@"
path = "./lib/[email protected]@.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "com.ibm.mq"
artifactId = "com.ibm.mq.allclient"
version = "@ibmmq.version@"
path = "./lib/[email protected]@.jar"
scope = "provided"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "com.fasterxml.jackson.core"
artifactId = "jackson-annotations"
version = "@jackson.version@"
path = "./lib/[email protected]@.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "com.fasterxml.jackson.core"
artifactId = "jackson-core"
version = "@jackson.version@"
path = "./lib/[email protected]@.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "com.fasterxml.jackson.core"
artifactId = "jackson-databind"
version = "@jackson.version@"
Expand Down
20 changes: 10 additions & 10 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@ org.gradle.caching=true
group=io.ballerina.lib
version=1.2.1-SNAPSHOT

ballerinaLangVersion=2201.9.0
ballerinaLangVersion=2201.11.0-20241117-133400-a3054b77
checkstylePluginVersion=10.12.1
spotbugsPluginVersion=5.0.14
spotbugsPluginVersion=6.0.18
shadowJarPluginVersion=8.1.1
downloadPluginVersion=5.4.0
releasePluginVersion=2.8.0
ballerinaGradlePluginVersion=2.0.1

# IBM MQ dependencies
ibmMQVersion=9.3.4.0
ibmMQVersion=9.4.1.0
jsonVersion=20231013
jacksonVersion=2.15.3

#stdlib dependencies

# Level 01
stdlibTimeVersion=2.4.0
stdlibIoVersion=1.6.0
stdlibTimeVersion=2.6.0-20241113-073800-201b904
stdlibIoVersion=1.6.2-20241112-233100-995cf5f

# Level 02
stdlibLogVersion=2.9.0
stdlibCryptoVersion=2.7.2
stdlibLogVersion=2.10.1-20241113-120000-4577868
stdlibCryptoVersion=2.7.3-20241113-081400-d015a39

# Level 03
stdlibUuidVersion=1.7.0
stdlibUuidVersion=1.8.1-20241113-154400-443c67b

observeVersion=1.2.0
observeInternalVersion=1.2.0
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 @@ -45,8 +45,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 @@ -27,13 +27,13 @@
import io.ballerina.lib.ibm.ibmmq.config.GetMessageOptions;
import io.ballerina.lib.ibm.ibmmq.config.MatchOptions;
import io.ballerina.lib.ibm.ibmmq.headers.MQRFH2Header;
import io.ballerina.runtime.api.PredefinedTypes;
import io.ballerina.runtime.api.Runtime;
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.flags.SymbolFlags;
import io.ballerina.runtime.api.types.ArrayType;
import io.ballerina.runtime.api.types.PredefinedTypes;
import io.ballerina.runtime.api.utils.StringUtils;
import io.ballerina.runtime.api.values.BArray;
import io.ballerina.runtime.api.values.BError;
Expand Down

This file was deleted.

37 changes: 10 additions & 27 deletions native/src/main/java/io/ballerina/lib/ibm.ibmmq/Queue.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,82 +26,65 @@
import com.ibm.mq.constants.CMQC;
import io.ballerina.lib.ibm.ibmmq.config.GetMessageOptions;
import io.ballerina.runtime.api.Environment;
import io.ballerina.runtime.api.Future;
import io.ballerina.runtime.api.values.BError;
import io.ballerina.runtime.api.values.BMap;
import io.ballerina.runtime.api.values.BObject;
import io.ballerina.runtime.api.values.BString;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import static io.ballerina.lib.ibm.ibmmq.CommonUtils.createError;
import static io.ballerina.lib.ibm.ibmmq.Constants.IBMMQ_ERROR;

/**
* Representation of {@link com.ibm.mq.MQQueue} with utility methods to invoke as inter-op functions.
*/
public class Queue {
private static final ExecutorService QUEUE_EXECUTOR_SERVICE = Executors.newCachedThreadPool(
new MQThreadFactory("balx-ibmmq-queue-client-network-thread"));

public static Object put(Environment environment, BObject queueObject, BMap<BString, Object> message,
long options) {
MQQueue queue = (MQQueue) queueObject.getNativeData(Constants.NATIVE_QUEUE);
MQMessage mqMessage = CommonUtils.getMqMessageFromBMessage(message);
Future future = environment.markAsync();
QUEUE_EXECUTOR_SERVICE.execute(() -> {
return environment.yieldAndRun(() -> {
try {
MQPutMessageOptions pmo = new MQPutMessageOptions();
pmo.options = (int) options;
queue.put(mqMessage, pmo);
future.complete(null);
return null;
} catch (MQException e) {
BError bError = createError(IBMMQ_ERROR,
return createError(IBMMQ_ERROR,
String.format("Error occurred while putting a message to the queue: %s", e.getMessage()), e);
future.complete(bError);
}
});
return null;
}

public static Object get(Environment environment, BObject queueObject, BMap<BString, Object> bGetMsgOptions) {
MQQueue queue = (MQQueue) queueObject.getNativeData(Constants.NATIVE_QUEUE);
GetMessageOptions getMsgOptions = new GetMessageOptions(bGetMsgOptions);
MQMessage mqMessage = CommonUtils.getMqMessage(getMsgOptions.matchOptions());
MQGetMessageOptions mqGetMsgOptions = CommonUtils.getMqGetMsgOptions(getMsgOptions);
Future future = environment.markAsync();
QUEUE_EXECUTOR_SERVICE.execute(() -> {
return environment.yieldAndRun(() -> {
try {
queue.get(mqMessage, mqGetMsgOptions);
future.complete(CommonUtils.getBMessageFromMQMessage(environment.getRuntime(), mqMessage));
return CommonUtils.getBMessageFromMQMessage(environment.getRuntime(), mqMessage);
} catch (MQException e) {
if (e.reasonCode == CMQC.MQRC_NO_MSG_AVAILABLE) {
future.complete(null);
return null;
} else {
BError bError = createError(IBMMQ_ERROR,
return createError(IBMMQ_ERROR,
String.format("Error occurred while getting a message from the queue: %s",
e.getMessage()), e);
future.complete(bError);
}
}
});
return null;
}

public static Object close(Environment env, BObject queueObject) {
MQQueue queue = (MQQueue) queueObject.getNativeData(Constants.NATIVE_QUEUE);
Future future = env.markAsync();
QUEUE_EXECUTOR_SERVICE.execute(() -> {
return env.yieldAndRun(() -> {
try {
queue.close();
future.complete(null);
return null;
} catch (MQException e) {
BError bError = createError(IBMMQ_ERROR,
return createError(IBMMQ_ERROR,
String.format("Error occurred while closing the queue: %s", e.getMessage()), e);
future.complete(bError);
}
});
return null;
}
}
Loading
Loading