diff --git a/bom/pom.xml b/bom/pom.xml
index 3fc576fae329a..bc95cdf69a126 100644
--- a/bom/pom.xml
+++ b/bom/pom.xml
@@ -319,11 +319,6 @@ THE SOFTWARE.
symbol-annotation
1.1
-
- com.sun.mail
- jakarta.mail
- 1.6.5
-
diff --git a/core/pom.xml b/core/pom.xml
index 0b10a40a0d22f..28fbaaaf812bd 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -280,10 +280,6 @@ THE SOFTWARE.
org.apache.commons
commons-compress
-
- com.sun.mail
- jakarta.mail
-
jaxen
jaxen
diff --git a/core/src/main/java/jenkins/model/JenkinsLocationConfiguration.java b/core/src/main/java/jenkins/model/JenkinsLocationConfiguration.java
index 12aa35b0e5f61..b78d5f689e35a 100644
--- a/core/src/main/java/jenkins/model/JenkinsLocationConfiguration.java
+++ b/core/src/main/java/jenkins/model/JenkinsLocationConfiguration.java
@@ -14,12 +14,11 @@
import hudson.util.XStream2;
import java.io.File;
import java.io.IOException;
+import java.io.UncheckedIOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;
-import javax.mail.internet.AddressException;
-import javax.mail.internet.InternetAddress;
import javax.servlet.ServletContext;
import jenkins.util.SystemProperties;
import jenkins.util.UrlHelper;
@@ -211,10 +210,40 @@ public FormValidation doCheckUrl(@QueryParameter String value) {
public FormValidation doCheckAdminAddress(@QueryParameter String value) {
try {
- new InternetAddress(value);
+ Class> internetAddress = Jenkins.get().pluginManager.uberClassLoader.loadClass("javax.mail.internet.InternetAddress");
+ internetAddress.getDeclaredConstructor(String.class).newInstance(value);
return FormValidation.ok();
- } catch (AddressException e) {
- return FormValidation.error(e.getMessage());
+ } catch (ClassNotFoundException x) {
+ return FormValidation.ok();
+ } catch (NoSuchMethodException x) {
+ NoSuchMethodError e = new NoSuchMethodError(x.getMessage());
+ e.initCause(x);
+ throw e;
+ } catch (IllegalAccessException x) {
+ IllegalAccessError e = new IllegalAccessError(x.getMessage());
+ e.initCause(x);
+ throw e;
+ } catch (InstantiationException x) {
+ InstantiationError e = new InstantiationError(x.getMessage());
+ e.initCause(x);
+ throw e;
+ } catch (InvocationTargetException x) {
+ Throwable t = x.getCause();
+ if (t instanceof RuntimeException) {
+ throw (RuntimeException) t;
+ } else if (t instanceof IOException) {
+ throw new UncheckedIOException((IOException) t);
+ } else if (t instanceof Exception) {
+ if (t.getClass().getName().equals("javax.mail.internet.AddressException")) {
+ return FormValidation.error(t.getMessage());
+ } else {
+ throw new RuntimeException(t);
+ }
+ } else if (t instanceof Error) {
+ throw (Error) t;
+ } else {
+ throw new Error(x);
+ }
}
}
diff --git a/core/src/main/resources/jenkins/split-plugin-cycles.txt b/core/src/main/resources/jenkins/split-plugin-cycles.txt
index 3cec061d7eb09..17f997f98970a 100644
--- a/core/src/main/resources/jenkins/split-plugin-cycles.txt
+++ b/core/src/main/resources/jenkins/split-plugin-cycles.txt
@@ -32,3 +32,5 @@ junit jaxb
bouncycastle-api jaxb
command-launcher jaxb
jdk-tool jaxb
+
+javax-activation-api javax-mail-api
diff --git a/core/src/main/resources/jenkins/split-plugins.txt b/core/src/main/resources/jenkins/split-plugins.txt
index 0bb03189d9c87..eeab9467a13bc 100644
--- a/core/src/main/resources/jenkins/split-plugins.txt
+++ b/core/src/main/resources/jenkins/split-plugins.txt
@@ -34,3 +34,6 @@ trilead-api 2.184 1.0.4
# JENKINS-64107
sshd 2.281 3.0.1
+
+javax-activation-api 2.328 1.2.0-1
+javax-mail-api 2.328 1.6.2-1
diff --git a/test/pom.xml b/test/pom.xml
index 336a6e6322ed8..e3304968c32c0 100644
--- a/test/pom.xml
+++ b/test/pom.xml
@@ -121,6 +121,12 @@ THE SOFTWARE.
391.ve4a_38c1b_cf4b_
test
+
+ io.jenkins.plugins
+ javax-mail-api
+ 1.6.2-1
+ test
+
org.jenkins-ci.plugins
matrix-auth
diff --git a/war/pom.xml b/war/pom.xml
index e71473d30ca03..a9c806ca30e0d 100644
--- a/war/pom.xml
+++ b/war/pom.xml
@@ -367,6 +367,18 @@ THE SOFTWARE.
1.0.4
hpi
+
+ io.jenkins.plugins
+ javax-activation-api
+ 1.2.0-1
+ hpi
+
+
+ io.jenkins.plugins
+ javax-mail-api
+ 1.6.2-1
+ hpi
+
${project.build.directory}/${project.build.finalName}/WEB-INF/detached-plugins
true