Skip to content

Commit

Permalink
Merge pull request #854 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 70a8f4e + f2d058c commit 4d56eac
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 81 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,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/)

Expand Down
24 changes: 12 additions & 12 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
[package]
org = "ballerina"
name = "email"
version = "2.10.0"
version = "2.10.1"
authors = ["Ballerina"]
keywords = ["email", "SMTP", "POP", "POP3", "IMAP", "mail"]
repository = "https://github.com/ballerina-platform/module-ballerina-email"
icon = "icon.png"
license = ["Apache-2.0"]
distribution = "2201.10.0"

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

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "com.sun.mail"
artifactId = "javax.mail"
version = "1.6.2"
path = "./lib/javax.mail-1.6.2.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "com.icegreen"
artifactId = "greenmail"
version = "1.5.11"
path = "./lib/greenmail-1.5.11.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.jvnet.mimepull"
artifactId = "mimepull"
version = "1.9.11"
path = "./lib/mimepull-1.9.11.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "javax.activation"
artifactId = "activation"
version = "1.1.1"
path = "./lib/activation-1.1.1.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "email-native"
version = "2.10.0"
path = "../native/build/libs/email-native-2.10.0.jar"
version = "2.10.1"
path = "../native/build/libs/email-native-2.10.1-SNAPSHOT.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "email-test-utils"
version = "2.10.0"
path = "../test-utils/build/libs/email-test-utils-2.10.0.jar"
version = "2.10.1"
path = "../test-utils/build/libs/email-test-utils-2.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 = "email-compiler-plugin"
class = "io.ballerina.stdlib.email.compiler.EmailCompilerPlugin"

[[dependency]]
path = "../compiler-plugin/build/libs/email-compiler-plugin-2.10.0.jar"
path = "../compiler-plugin/build/libs/email-compiler-plugin-2.10.1-SNAPSHOT.jar"
16 changes: 8 additions & 8 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 = "email"
version = "2.10.0"
version = "2.10.1"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "lang.runtime"},
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 @@ -129,7 +129,7 @@ dependencies = [
[[package]]
org = "ballerina"
name = "log"
version = "2.10.0"
version = "2.10.1"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"},
Expand All @@ -143,7 +143,7 @@ modules = [
[[package]]
org = "ballerina"
name = "mime"
version = "2.10.0"
version = "2.10.2"
dependencies = [
{org = "ballerina", name = "io"},
{org = "ballerina", name = "jballerina.java"},
Expand All @@ -157,15 +157,15 @@ modules = [
[[package]]
org = "ballerina"
name = "observe"
version = "1.3.0"
version = "1.4.0"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]

[[package]]
org = "ballerina"
name = "task"
version = "2.5.0"
version = "2.5.1"
dependencies = [
{org = "ballerina", name = "jballerina.java"},
{org = "ballerina", name = "time"}
Expand All @@ -191,7 +191,7 @@ modules = [
[[package]]
org = "ballerina"
name = "time"
version = "2.4.0"
version = "2.6.0"
dependencies = [
{org = "ballerina", name = "jballerina.java"}
]
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 @@ -9,40 +9,40 @@ icon = "icon.png"
license = ["Apache-2.0"]
distribution = "2201.10.0"

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

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "com.sun.mail"
artifactId = "javax.mail"
version = "1.6.2"
path = "./lib/javax.mail-1.6.2.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "com.icegreen"
artifactId = "greenmail"
version = "1.5.11"
path = "./lib/greenmail-1.5.11.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "org.jvnet.mimepull"
artifactId = "mimepull"
version = "1.9.11"
path = "./lib/mimepull-1.9.11.jar"

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "javax.activation"
artifactId = "activation"
version = "1.1.1"
path = "./lib/activation-1.1.1.jar"

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

[[platform.java17.dependency]]
[[platform.java21.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "email-test-utils"
version = "@toml.version@"
Expand Down
4 changes: 4 additions & 0 deletions build-config/spotbugs-exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@
<Class name="io.ballerina.stdlib.email.server.EmailConsumer"/>
<Bug pattern="EI_EXPOSE_REP2" />
</Match>
<Match>
<Class name="io.ballerina.stdlib.email.server.EmailConsumer"/>
<Bug pattern="CT_CONSTRUCTOR_THROW" />
</Match>
</FindBugsFilter>
7 changes: 5 additions & 2 deletions compiler-plugin-tests/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 @@ tasks.withType(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
22 changes: 11 additions & 11 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ mimepullVersion=1.9.11
javaxActivationVersion=1.1.1
puppycrawlCheckstyleVersion=10.12.0
checkstylePluginVersion=10.12.0
githubSpotbugsVersion=5.0.14
githubSpotbugsVersion=6.0.18
githubJohnrengelmanShadowVersion=8.1.1
underCouchDownloadVersion=5.4.0
researchgateReleaseVersion=2.8.0
ballerinaGradlePluginVersion=2.0.1

ballerinaLangVersion=2201.10.0
stdlibTaskVersion=2.5.0
stdlibMimeVersion=2.10.0
stdlibFileVersion=1.10.0
stdlibTimeVersion=2.4.0
stdlibLogVersion=2.10.0
stdlibOsVersion=1.8.0
stdlibIoVersion=1.6.0
observeVersion=1.3.0
observeInternalVersion=1.3.0
ballerinaLangVersion=2201.11.0-20241112-214900-6b80ab87
stdlibTaskVersion=2.5.1-20241113-123500-f905281
stdlibMimeVersion=2.10.2-20241113-154200-d953747
stdlibFileVersion=1.10.1-20241113-151700-e1a2e38
stdlibTimeVersion=2.6.0-20241113-073800-201b904
stdlibLogVersion=2.10.1-20241113-120000-4577868
stdlibOsVersion=1.8.1-20241113-122000-cca973b
stdlibIoVersion=1.6.2-20241112-233100-995cf5f
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 @@ -42,8 +42,11 @@ dependencies {

spotbugsMain {
ignoreFailures = true
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")
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 @@ -19,23 +19,20 @@
package io.ballerina.stdlib.email.server;

import io.ballerina.runtime.api.Runtime;
import io.ballerina.runtime.api.async.StrandMetadata;
import io.ballerina.runtime.api.types.ObjectType;
import io.ballerina.runtime.api.utils.TypeUtils;
import io.ballerina.runtime.api.values.BError;
import io.ballerina.runtime.api.values.BObject;
import io.ballerina.stdlib.email.util.EmailConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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

import static io.ballerina.stdlib.email.util.EmailConstants.ON_CLOSE_METADATA;
import static io.ballerina.stdlib.email.util.EmailConstants.ON_ERROR_METADATA;
import static io.ballerina.stdlib.email.util.EmailConstants.ON_CLOSE;
import static io.ballerina.stdlib.email.util.EmailConstants.ON_ERROR;
import static io.ballerina.stdlib.email.util.EmailConstants.ON_MESSAGE;
import static io.ballerina.stdlib.email.util.EmailConstants.ON_MESSAGE_METADATA;

/**
* Email connector listener for Ballerina.
Expand Down Expand Up @@ -68,7 +65,7 @@ public boolean onMessage(EmailEvent emailEvent) {
if (runtime != null) {
Set<Map.Entry<String, BObject>> services = registeredServices.entrySet();
for (Map.Entry<String, BObject> service : services) {
invokeAsyncCall(service.getValue(), ON_MESSAGE, ON_MESSAGE_METADATA, email);
runtime.callMethod(service.getValue(), ON_MESSAGE, null, email);
}
} else {
log.error("Runtime should not be null.");
Expand All @@ -85,7 +82,7 @@ public void onError(Object error) {
if (runtime != null) {
Set<Map.Entry<String, BObject>> services = registeredServices.entrySet();
for (Map.Entry<String, BObject> service : services) {
invokeAsyncCall(service.getValue(), EmailConstants.ON_ERROR, ON_ERROR_METADATA, error);
runtime.callMethod(service.getValue(), ON_ERROR, null, error);
}
} else {
log.error("Runtime should not be null.");
Expand All @@ -103,7 +100,7 @@ public void onClose(Object error) {
if (runtime != null) {
Set<Map.Entry<String, BObject>> services = registeredServices.entrySet();
for (Map.Entry<String, BObject> service : services) {
invokeAsyncCall(service.getValue(), EmailConstants.ON_CLOSE, ON_CLOSE_METADATA, error);
runtime.callMethod(service.getValue(), ON_CLOSE, null, error);
}
} else {
log.error("Runtime should not be null.");
Expand All @@ -119,15 +116,4 @@ protected void addService(BObject service) {
}
}

private void invokeAsyncCall(BObject service, String methodName, StrandMetadata metadata, Object arg) {
ObjectType serviceType = (ObjectType) TypeUtils.getReferredType(TypeUtils.getType(service));
if (serviceType.isIsolated() && serviceType.isIsolated(methodName)) {
runtime.invokeMethodAsyncConcurrently(service, methodName,
null, metadata, null, null, null, arg, true);
} else {
runtime.invokeMethodAsyncSequentially(service, methodName,
null, metadata, null, null, null, arg, true);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

package io.ballerina.stdlib.email.server;

import io.ballerina.runtime.api.Runtime;
import io.ballerina.runtime.api.Environment;
import io.ballerina.runtime.api.values.BMap;
import io.ballerina.runtime.api.values.BObject;
import io.ballerina.runtime.api.values.BString;
Expand All @@ -45,9 +45,9 @@ private EmailListenerHelper() {}
* @param serviceEndpointConfig Email server endpoint configuration
* @throws EmailConnectorException If the given protocol is invalid
*/
public static Object init(BObject emailListener, BMap<BString, Object> serviceEndpointConfig,
BMap<BString, Object> protocolConfig, BString protocol) {
final EmailListener listener = new EmailListener(Runtime.getCurrentRuntime());
public static Object init(Environment env, BObject emailListener, BMap<BString, Object> serviceEndpointConfig,
BMap<BString, Object> protocolConfig, BString protocol) {
final EmailListener listener = new EmailListener(env.getRuntime());
Map<String, Object> paramMap = getServerConnectorParamMap(serviceEndpointConfig, protocolConfig,
protocol.getValue());
EmailConnector emailConnector = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

import com.sun.mail.imap.IMAPMessage;
import com.sun.mail.pop3.POP3Message;
import io.ballerina.runtime.api.PredefinedTypes;
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.PredefinedTypes;
import io.ballerina.runtime.api.types.Type;
import io.ballerina.runtime.api.utils.JsonUtils;
import io.ballerina.runtime.api.utils.StringUtils;
Expand Down
Loading

0 comments on commit 4d56eac

Please sign in to comment.