diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 82265a36d5c..845c9462020 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -27,7 +27,7 @@ on:
jobs:
build:
- name: build (${{ matrix.os }})
+ name: build (${{ matrix.os }}, jdk ${{ matrix.java }})
permissions:
contents: read
@@ -36,29 +36,46 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-24.04, windows-latest, macos-latest ]
+ java: [ '21' ]
+ # Include an additional matrix entry for main branch with Ubuntu 26.04, JDK 25, and Maven 3.10.0
+ include: ${{ github.ref == 'refs/heads/main' && fromJSON('[{"os":"ubuntu-26.04","java":"25","maven":"3.10.0"}]') || fromJSON('[]') }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v7
- - name: Set up JDK 17
+ - name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v6
with:
- java-version: '17'
+ java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: 'maven'
+ - name: Set up Maven ${{ matrix.maven }}
+ if: matrix.maven
+ env:
+ MAVEN_VERSION: ${{ matrix.maven }}
+ run: |
+ url="https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz"
+ curl -fsSL -o "${RUNNER_TEMP}/maven.tar.gz" "${url}"
+ echo "$(curl -fsSL "${url}.sha512") ${RUNNER_TEMP}/maven.tar.gz" | sha512sum -c -
+ tar -xzf "${RUNNER_TEMP}/maven.tar.gz" -C "${RUNNER_TEMP}"
+ # fails the step if the layout is not what we expect, rather than silently keeping Maven 3
+ "${RUNNER_TEMP}/apache-maven-${MAVEN_VERSION}/bin/mvn" -v
+ echo "${RUNNER_TEMP}/apache-maven-${MAVEN_VERSION}/bin" >> "${GITHUB_PATH}"
- name: Build
- run: mvn -U -B -e clean install -Prat -DskipTests "-Dinvoker.skip=true"
+ run: |
+ mvn --version
+ mvn -U -B -e clean install -Prat -DskipTests "-Dinvoker.skip=true"
- name: Save Maven Local Repository
uses: actions/upload-artifact@v7
with:
- name: maven-local-repo-${{ matrix.os }}
+ name: maven-local-repo-${{ matrix.os }}-jdk${{ matrix.java }}
path: ~/.m2/repository
retention-days: 1
test:
- name: test (${{ matrix.os }})
+ name: test (${{ matrix.os }}, jdk ${{ matrix.java }})
needs: build
permissions:
@@ -68,34 +85,51 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-24.04, windows-latest, macos-latest ]
+ java: [ '21' ]
+ # Include an additional matrix entry for main branch with Ubuntu 26.04, JDK 25, and Maven 3.10.0
+ include: ${{ github.ref == 'refs/heads/main' && fromJSON('[{"os":"ubuntu-26.04","java":"25","maven":"3.10.0"}]') || fromJSON('[]') }}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v7
- - name: Set up JDK 17
+ - name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v6
with:
- java-version: '17'
+ java-version: ${{ matrix.java }}
distribution: 'temurin'
cache: 'maven'
- name: Restore Maven Local Repository
uses: actions/download-artifact@v8
with:
- name: maven-local-repo-${{ matrix.os }}
+ name: maven-local-repo-${{ matrix.os }}-jdk${{ matrix.java }}
path: ~/.m2/repository
+ - name: Set up Maven ${{ matrix.maven }}
+ if: matrix.maven
+ env:
+ MAVEN_VERSION: ${{ matrix.maven }}
+ run: |
+ url="https://archive.apache.org/dist/maven/maven-3/${MAVEN_VERSION}/binaries/apache-maven-${MAVEN_VERSION}-bin.tar.gz"
+ curl -fsSL -o "${RUNNER_TEMP}/maven.tar.gz" "${url}"
+ echo "$(curl -fsSL "${url}.sha512") ${RUNNER_TEMP}/maven.tar.gz" | sha512sum -c -
+ tar -xzf "${RUNNER_TEMP}/maven.tar.gz" -C "${RUNNER_TEMP}"
+ # fails the step if the layout is not what we expect, rather than silently keeping Maven 3
+ "${RUNNER_TEMP}/apache-maven-${MAVEN_VERSION}/bin/mvn" -v
+ echo "${RUNNER_TEMP}/apache-maven-${MAVEN_VERSION}/bin" >> "${GITHUB_PATH}"
- name: Test
- run: mvn -B -e install -Ptest
+ run: |
+ mvn --version
+ mvn -B -e install -Ptest
timeout-minutes: 180
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v7
with:
- name: test-results-${{ matrix.os }}
+ name: test-results-${{ matrix.os }}-jdk${{ matrix.java }}
path: '**/target/surefire-reports/*.xml'
- name: Upload Event File
- if: always()
+ if: always() && matrix.java == '21'
uses: actions/upload-artifact@v7
with:
name: event-file-${{ matrix.os }}
diff --git a/BUILDING.md b/BUILDING.md
index 4286805b25a..408efd5fe9b 100644
--- a/BUILDING.md
+++ b/BUILDING.md
@@ -21,13 +21,13 @@
## Initial Setup
-1. Install J2SE 11 SDK (or later)
+1. Install J2SE 21 SDK (or later)
2. Make sure that your JAVA_HOME environment variable is set to the newly installed
JDK location, and that your PATH includes `%JAVA_HOME%\bin` (windows) or
`$JAVA_HOME$/bin` (unix).
-3. Install Maven 3.8.0 (or later), which can be downloaded from
+3. Install Maven 3.8.8 (or later), which can be downloaded from
http://maven.apache.org/download.html. Make sure that your PATH includes
the `$MVN_HOME/bin` directory.
diff --git a/archetypes/assembly/src/main/resources/archetype-resources/pom.xml b/archetypes/assembly/src/main/resources/archetype-resources/pom.xml
index 4bd78a8db18..c0fff59c068 100644
--- a/archetypes/assembly/src/main/resources/archetype-resources/pom.xml
+++ b/archetypes/assembly/src/main/resources/archetype-resources/pom.xml
@@ -174,7 +174,7 @@
- 17
+ ^javaVersion^
diff --git a/archetypes/blueprint/src/main/resources/archetype-resources/pom.xml b/archetypes/blueprint/src/main/resources/archetype-resources/pom.xml
index d442fecc346..cd322ff1458 100644
--- a/archetypes/blueprint/src/main/resources/archetype-resources/pom.xml
+++ b/archetypes/blueprint/src/main/resources/archetype-resources/pom.xml
@@ -63,8 +63,9 @@
maven-compiler-plugin
3.15.0
- 1.8
- 1.8
+ 21
+ 21
+ 21
256M
diff --git a/archetypes/bundle/pom.xml b/archetypes/bundle/pom.xml
index 3bbc2cecbac..7d4ecef397e 100644
--- a/archetypes/bundle/pom.xml
+++ b/archetypes/bundle/pom.xml
@@ -57,8 +57,9 @@
org.apache.maven.plugins
maven-compiler-plugin
- 1.8
- 1.8
+ ${javaVersion}
+ ${javaVersion}
+ ${javaVersion}
256M
diff --git a/archetypes/bundle/src/main/resources/archetype-resources/pom.xml b/archetypes/bundle/src/main/resources/archetype-resources/pom.xml
index 798beaeab16..83654cd8942 100644
--- a/archetypes/bundle/src/main/resources/archetype-resources/pom.xml
+++ b/archetypes/bundle/src/main/resources/archetype-resources/pom.xml
@@ -82,8 +82,9 @@
maven-compiler-plugin
3.15.0
- 1.8
- 1.8
+ 21
+ 21
+ 21
256M
diff --git a/archetypes/command/src/main/resources/archetype-resources/pom.xml b/archetypes/command/src/main/resources/archetype-resources/pom.xml
index 73ab71c704b..6a579d1cc27 100644
--- a/archetypes/command/src/main/resources/archetype-resources/pom.xml
+++ b/archetypes/command/src/main/resources/archetype-resources/pom.xml
@@ -67,8 +67,9 @@
true
3.15.0
- 1.8
- 1.8
+ 21
+ 21
+ 21
diff --git a/assemblies/apache-karaf-light/pom.xml b/assemblies/apache-karaf-light/pom.xml
index 8f70f27a265..6d06313629f 100644
--- a/assemblies/apache-karaf-light/pom.xml
+++ b/assemblies/apache-karaf-light/pom.xml
@@ -178,7 +178,7 @@
- 17
+ ${javaVersion}
${project.build.directory}
Apache Karaf Light
diff --git a/assemblies/apache-karaf-minimal/pom.xml b/assemblies/apache-karaf-minimal/pom.xml
index 072afd67715..dff15d80164 100644
--- a/assemblies/apache-karaf-minimal/pom.xml
+++ b/assemblies/apache-karaf-minimal/pom.xml
@@ -145,7 +145,7 @@
!org.apache.karaf.command.acl.*,
*
- 17
+ ${javaVersion}
diff --git a/assemblies/apache-karaf-mix/pom.xml b/assemblies/apache-karaf-mix/pom.xml
index e07eec0e8bf..4c4039b623c 100644
--- a/assemblies/apache-karaf-mix/pom.xml
+++ b/assemblies/apache-karaf-mix/pom.xml
@@ -187,7 +187,7 @@
- 17
+ ${javaVersion}
${project.build.directory}
Apache Karaf Mix
diff --git a/assemblies/apache-karaf/pom.xml b/assemblies/apache-karaf/pom.xml
index 9c05670f68f..2a263eca686 100644
--- a/assemblies/apache-karaf/pom.xml
+++ b/assemblies/apache-karaf/pom.xml
@@ -178,7 +178,7 @@
- 17
+ ${javaVersion}
${project.build.directory}
Apache Karaf (full)
diff --git a/assemblies/features/base/src/main/filtered-resources/resources/bin/inc b/assemblies/features/base/src/main/filtered-resources/resources/bin/inc
index 2809e8be7cf..d95ac412733 100644
--- a/assemblies/features/base/src/main/filtered-resources/resources/bin/inc
+++ b/assemblies/features/base/src/main/filtered-resources/resources/bin/inc
@@ -190,7 +190,7 @@ locateJava() {
fi
if [ "x${JAVA_HOME}" = "x" ] && [ "${darwin}" = "true" ]; then
- JAVA_HOME="`/usr/libexec/java_home -v 1.8`"
+ JAVA_HOME="`/usr/libexec/java_home -v 21+`"
fi
if [ "x${JAVA_HOME}" = "x" ] && [ -r /etc/gentoo-release ] ; then
JAVA_HOME=`java-config --jre-home`
@@ -243,9 +243,9 @@ checkJvmVersion() {
VERSION=`"${JAVA}" -version 2>&1 | ${AWK} -F '"' '/version/ {print $2}' | sed -e 's/_.*//g; s/^1\.//g; s/\..*//g; s/-.*//g;s/-.*//g; s/^[A-Za-z].*//'`
- # java must be at least version 11
- if [ "${VERSION}" -lt "11" ]; then
- die "JVM must be version 11 or greater"
+ # java must be at least version 21
+ if [ "${VERSION}" -lt "21" ]; then
+ die "JVM must be version 21 or greater"
fi
}
@@ -282,12 +282,6 @@ setupVendorSepcifics() {
setupDefaults() {
DEFAULT_JAVA_OPTS="-XX:+UnlockDiagnosticVMOptions "
- if [ "${VERSION}" -gt "11" ]; then
- # TODO revisit EventAdminImpl to avoid use of Subject.getSubject(AccessController.getContext());
- # -Djava.security.manager=allow is a workaround for SecurityController deprecation in JDK23+
- DEFAULT_JAVA_OPTS="$DEFAULT_JAVA_OPTS -Djava.security.manager=allow "
- fi
-
setupVendorSepcifics
DEFAULT_JAVA_OPTS="${DEFAULT_JAVA_OPTS} ${JAVA_VENDOR_OPTS}"
diff --git a/assemblies/features/base/src/main/filtered-resources/resources/bin/karaf b/assemblies/features/base/src/main/filtered-resources/resources/bin/karaf
index 65ecd5312c0..26c4b615d6f 100644
--- a/assemblies/features/base/src/main/filtered-resources/resources/bin/karaf
+++ b/assemblies/features/base/src/main/filtered-resources/resources/bin/karaf
@@ -94,16 +94,14 @@ setupClassPath() {
CLASSPATH="${CLASSPATH}:${file}"
fi
done
- if [ "${VERSION}" -gt "8" ] ; then
- for file in "${KARAF_HOME}"/lib/jdk9plus/*.jar
- do
- if [ -z "${CLASSPATH}" ]; then
- CLASSPATH="${file}"
- else
- CLASSPATH="${CLASSPATH}:${file}"
- fi
- done
- fi
+ for file in "${KARAF_HOME}"/lib/jdk9plus/*.jar
+ do
+ if [ -z "${CLASSPATH}" ]; then
+ CLASSPATH="${file}"
+ else
+ CLASSPATH="${CLASSPATH}:${file}"
+ fi
+ done
}
checkRootInstance() {
@@ -183,12 +181,8 @@ run() {
if [ "x$CHECK_ROOT_INSTANCE_RUNNING" = "x" ]; then
CHECK_ROOT_INSTANCE_RUNNING=true
fi
- JAVA_ENDORSED_DIRS="${JAVA_HOME}/jre/lib/endorsed:${JAVA_HOME}/lib/endorsed:${KARAF_HOME}/lib/endorsed"
- JAVA_EXT_DIRS="${JAVA_HOME}/jre/lib/ext:${JAVA_HOME}/lib/ext:${KARAF_HOME}/lib/ext"
if ${cygwin}; then
JAVA_HOME=`cygpath --path --windows "${JAVA_HOME}"`
- JAVA_ENDORSED_DIRS=`cygpath --path --windows "${JAVA_ENDORSED_DIRS}"`
- JAVA_EXT_DIRS=`cygpath --path --windows "${JAVA_EXT_DIRS}"`
fi
convertPaths
cd "${KARAF_BASE}" || exit 2
diff --git a/assemblies/features/base/src/main/filtered-resources/resources/bin/karaf.bat b/assemblies/features/base/src/main/filtered-resources/resources/bin/karaf.bat
index b3893b53873..981cd4fb9a1 100644
--- a/assemblies/features/base/src/main/filtered-resources/resources/bin/karaf.bat
+++ b/assemblies/features/base/src/main/filtered-resources/resources/bin/karaf.bat
@@ -234,12 +234,16 @@ for /f tokens^=2-5^ delims^=.-_+^" %%j in ('"%JAVA%" -fullversion 2^>^&1') do (
if %%j==1 (set JAVA_VERSION=%%k) else (set JAVA_VERSION=%%j)
)
-if %JAVA_VERSION% GTR 8 (
- pushd "%KARAF_HOME%\lib\jdk9plus"
- for %%G in (*.jar) do call:APPEND_TO_JDK9PLUS_CLASSPATH %%G
- popd
+rem java must be at least version 21
+if %JAVA_VERSION% LSS 21 (
+ call :warn JVM must be version 21 or greater
+ goto END
)
+pushd "%KARAF_HOME%\lib\jdk9plus"
+ for %%G in (*.jar) do call:APPEND_TO_JDK9PLUS_CLASSPATH %%G
+popd
+
:CheckRootInstance
set ROOT_INSTANCE_RUNNING=false
if exist "%KARAF_HOME%\instances\instance.properties" (
@@ -267,10 +271,6 @@ if not exist "%JAVA_HOME%\bin\server\jvm.dll" (
)
set DEFAULT_JAVA_OPTS=-XX:+UnlockDiagnosticVMOptions
-if %JAVA_VERSION% GTR 11 (
- set DEFAULT_JAVA_OPTS=%DEFAULT_JAVA_OPTS% -Djava.security.manager=allow
-)
-
if "%JAVA_OPTS%" == "" set JAVA_OPTS=%DEFAULT_JAVA_OPTS%
if "%EXTRA_JAVA_OPTS%" == "" goto :KARAF_EXTRA_JAVA_OPTS_END
diff --git a/assemblies/features/enterprise/pom.xml b/assemblies/features/enterprise/pom.xml
index 5ff00a0b820..d8cc722ba0d 100644
--- a/assemblies/features/enterprise/pom.xml
+++ b/assemblies/features/enterprise/pom.xml
@@ -214,7 +214,7 @@
file:${project.build.directory}/feature/feature.xml
org.apache.karaf.features:framework
- 17
+ ${javaVersion}
framework
diff --git a/assemblies/features/integration/pom.xml b/assemblies/features/integration/pom.xml
index 54faea9360a..0e4d7c326a5 100644
--- a/assemblies/features/integration/pom.xml
+++ b/assemblies/features/integration/pom.xml
@@ -105,7 +105,7 @@
file:${project.build.directory}/feature/feature.xml
org.apache.karaf.features:framework
- 17
+ ${javaVersion}
framework
diff --git a/assemblies/features/specs/pom.xml b/assemblies/features/specs/pom.xml
index 5944e6081b3..1558c26aeec 100644
--- a/assemblies/features/specs/pom.xml
+++ b/assemblies/features/specs/pom.xml
@@ -96,7 +96,7 @@
file:${project.build.directory}/feature/feature.xml
org.apache.karaf.features:framework
- 17
+ ${javaVersion}
framework
@@ -149,4 +149,4 @@
-
\ No newline at end of file
+
diff --git a/assemblies/features/spring/pom.xml b/assemblies/features/spring/pom.xml
index b5abe0e26ad..8658b716938 100644
--- a/assemblies/features/spring/pom.xml
+++ b/assemblies/features/spring/pom.xml
@@ -158,7 +158,7 @@
file:${project.build.directory}/feature/feature.xml
org.apache.karaf.features:framework
- 17
+ ${javaVersion}
framework
diff --git a/assemblies/features/standard/pom.xml b/assemblies/features/standard/pom.xml
index 540a5919c4d..ed6a8b92ac2 100644
--- a/assemblies/features/standard/pom.xml
+++ b/assemblies/features/standard/pom.xml
@@ -476,7 +476,7 @@
file:${project.build.directory}/feature/feature.xml
org.apache.karaf.features:framework
- 17
+ ${javaVersion}
framework
@@ -503,7 +503,7 @@
target/feature/feature.xml
- features
+ features
xml
diff --git a/examples/karaf-docker-example/karaf-docker-example-dynamic-dist/pom.xml b/examples/karaf-docker-example/karaf-docker-example-dynamic-dist/pom.xml
index 737f04e70c6..634aaab1618 100644
--- a/examples/karaf-docker-example/karaf-docker-example-dynamic-dist/pom.xml
+++ b/examples/karaf-docker-example/karaf-docker-example-dynamic-dist/pom.xml
@@ -139,7 +139,7 @@
- 17
+ ${javaVersion}
@@ -195,4 +195,4 @@
-
\ No newline at end of file
+
diff --git a/examples/karaf-docker-example/karaf-docker-example-static-dist/pom.xml b/examples/karaf-docker-example/karaf-docker-example-static-dist/pom.xml
index 962cb65914f..91a3fe1d3e7 100644
--- a/examples/karaf-docker-example/karaf-docker-example-static-dist/pom.xml
+++ b/examples/karaf-docker-example/karaf-docker-example-static-dist/pom.xml
@@ -111,7 +111,7 @@
static
true
static
- 17
+ ${javaVersion}
diff --git a/examples/karaf-graphql-example/karaf-graphql-example-websocket/pom.xml b/examples/karaf-graphql-example/karaf-graphql-example-websocket/pom.xml
index c684882f738..61817c99136 100644
--- a/examples/karaf-graphql-example/karaf-graphql-example-websocket/pom.xml
+++ b/examples/karaf-graphql-example/karaf-graphql-example-websocket/pom.xml
@@ -70,8 +70,8 @@
org.apache.maven.plugins
maven-compiler-plugin
- 11
- 11
+ 21
+ 21
diff --git a/instance/src/main/java/org/apache/karaf/instance/core/internal/InstanceServiceImpl.java b/instance/src/main/java/org/apache/karaf/instance/core/internal/InstanceServiceImpl.java
index e8537e9e157..c28c48779b3 100644
--- a/instance/src/main/java/org/apache/karaf/instance/core/internal/InstanceServiceImpl.java
+++ b/instance/src/main/java/org/apache/karaf/instance/core/internal/InstanceServiceImpl.java
@@ -523,37 +523,29 @@ private static void doStart(InstanceState instance, String name, String javaOpts
classpath.append(childClasspath);
}
- String jdkOpts;
- if (!System.getProperty("java.version").startsWith("1.")) {
- StringBuilder jdk9Classpath = classpathFromLibDir(new File(new File(System.getProperty("karaf.home"), "lib"), "jdk9plus"));
- if (jdk9Classpath.length() > 0) {
- classpath.append(System.getProperty("path.separator"));
- classpath.append(jdk9Classpath);
- }
- jdkOpts = " --add-opens java.base/java.security=ALL-UNNAMED" +
- " --add-opens java.base/java.net=ALL-UNNAMED" +
- " --add-opens java.base/java.lang=ALL-UNNAMED" +
- " --add-opens java.base/java.util=ALL-UNNAMED" +
- " --add-opens java.naming/javax.naming.spi=ALL-UNNAMED" +
- " --add-opens java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" +
- " --add-exports=java.base/sun.net.www.protocol.file=ALL-UNNAMED" +
- " --add-exports=java.base/sun.net.www.protocol.ftp=ALL-UNNAMED" +
- " --add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED" +
- " --add-exports=java.base/sun.net.www.protocol.https=ALL-UNNAMED" +
- " --add-exports=java.base/sun.net.www.protocol.jar=ALL-UNNAMED" +
- " --add-exports=java.base/sun.net.www.content.text=ALL-UNNAMED" +
- " --add-exports=jdk.xml.dom/org.w3c.dom.html=ALL-UNNAMED" +
- " --add-exports=java.rmi/sun.rmi.registry=ALL-UNNAMED" +
- " --add-exports=jdk.naming.rmi/com.sun.jndi.url.rmi=ALL-UNNAMED" +
- " --add-exports=java.security.sasl/com.sun.security.sasl=ALL-UNNAMED" +
- " --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED";
- if (!System.getProperty("java.version").startsWith("11")) {
- jdkOpts += " -Djava.security.manager=allow";
- }
- } else {
- jdkOpts = " -Djava.endorsed.dirs=\"" + new File(new File(new File(System.getProperty("java.home"), "jre"), "lib"), "endorsed") + System.getProperty("path.separator") + new File(new File(System.getProperty("java.home"), "lib"), "endorsed") + "\""
- + " -Djava.ext.dirs=\"" + new File(new File(new File(System.getProperty("java.home"), "jre"), "lib"), "ext") + System.getProperty("path.separator") + new File(new File(System.getProperty("java.home"), "lib"), "ext") + System.getProperty("path.separator") + new File(libDir, "ext").getCanonicalPath() + "\"";
+ StringBuilder jdk9Classpath = classpathFromLibDir(new File(new File(System.getProperty("karaf.home"), "lib"), "jdk9plus"));
+ if (!jdk9Classpath.isEmpty()) {
+ classpath.append(File.pathSeparator);
+ classpath.append(jdk9Classpath);
}
+ String jdkOpts = " --add-opens java.base/java.security=ALL-UNNAMED" +
+ " --add-opens java.base/java.net=ALL-UNNAMED" +
+ " --add-opens java.base/java.lang=ALL-UNNAMED" +
+ " --add-opens java.base/java.util=ALL-UNNAMED" +
+ " --add-opens java.naming/javax.naming.spi=ALL-UNNAMED" +
+ " --add-opens java.rmi/sun.rmi.transport.tcp=ALL-UNNAMED" +
+ " --add-exports=java.base/sun.net.www.protocol.file=ALL-UNNAMED" +
+ " --add-exports=java.base/sun.net.www.protocol.ftp=ALL-UNNAMED" +
+ " --add-exports=java.base/sun.net.www.protocol.http=ALL-UNNAMED" +
+ " --add-exports=java.base/sun.net.www.protocol.https=ALL-UNNAMED" +
+ " --add-exports=java.base/sun.net.www.protocol.jar=ALL-UNNAMED" +
+ " --add-exports=java.base/sun.net.www.content.text=ALL-UNNAMED" +
+ " --add-exports=jdk.xml.dom/org.w3c.dom.html=ALL-UNNAMED" +
+ " --add-exports=java.rmi/sun.rmi.registry=ALL-UNNAMED" +
+ " --add-exports=jdk.naming.rmi/com.sun.jndi.url.rmi=ALL-UNNAMED" +
+ " --add-exports=java.security.sasl/com.sun.security.sasl=ALL-UNNAMED" +
+ " --add-exports=java.naming/com.sun.jndi.ldap=ALL-UNNAMED";
+
String command = "\""
+ new File(System.getProperty("java.home"), ScriptUtils.isWindows() ? "bin\\java.exe" : "bin/java").getCanonicalPath()
+ "\" " + opts
diff --git a/itests/common/src/main/java/org/apache/karaf/itests/KarafTestSupport.java b/itests/common/src/main/java/org/apache/karaf/itests/KarafTestSupport.java
index 0f6971c2315..d1ba36f5c39 100644
--- a/itests/common/src/main/java/org/apache/karaf/itests/KarafTestSupport.java
+++ b/itests/common/src/main/java/org/apache/karaf/itests/KarafTestSupport.java
@@ -25,7 +25,6 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.Principal;
-import java.security.PrivilegedExceptionAction;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -36,6 +35,7 @@
import java.util.Hashtable;
import java.util.Set;
import java.util.concurrent.Callable;
+import java.util.concurrent.CompletionException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -417,11 +417,20 @@ private String executeCommand(final String command, final Long timeout, final Lo
if (principals.length == 0) {
commandFuture = new FutureTask<>(commandCallable);
} else {
- // If principals are defined, run the command callable via Subject.doAs()
+ // If principals are defined, run the command callable via Subject.callAs().
+ // Gogo dispatches the actual command execution on its own executor thread, which
+ // does not inherit the ScopedValue binding set up by Subject.callAs() on JDK 25,
+ // so also store the subject on the session for SecuredCommand to pick back up.
commandFuture = new FutureTask<>(() -> {
Subject subject = new Subject();
subject.getPrincipals().addAll(Arrays.asList(principals));
- return Subject.doAs(subject, (PrivilegedExceptionAction) commandCallable::call);
+ session.put(Subject.class.getName(), subject);
+ try {
+ return Subject.callAs(subject, (Callable) commandCallable::call);
+ } catch (CompletionException e) {
+ // unwrap like doAs did
+ throw e.getCause() instanceof RuntimeException runtimeException ? runtimeException : e;
+ }
});
}
diff --git a/itests/test/src/test/java/org/apache/karaf/itests/JavaSecurityTest.java b/itests/test/src/test/java/org/apache/karaf/itests/JavaSecurityTest.java
index 009a9e436d3..d2cfa7a59e1 100644
--- a/itests/test/src/test/java/org/apache/karaf/itests/JavaSecurityTest.java
+++ b/itests/test/src/test/java/org/apache/karaf/itests/JavaSecurityTest.java
@@ -34,7 +34,6 @@
import java.nio.file.StandardCopyOption;
import java.util.*;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import static org.ops4j.pax.exam.CoreOptions.maven;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.*;
@@ -63,7 +62,8 @@ public Option[] config() {
// Add some extra options used by this test...
options.addAll(Arrays.asList(
editConfigurationFilePut("etc/system.properties", "java.security.policy", "${karaf.etc}/all.policy"),
- editConfigurationFilePut("etc/system.properties", "org.osgi.framework.security", "osgi"),
+ // This is no longer allowed as felix framework 7.0.5 calls System.getSecurityManager() in case it is there, see Felix.java
+ // editConfigurationFilePut("etc/system.properties", "org.osgi.framework.security", "osgi"),
editConfigurationFilePut("etc/system.properties", "org.osgi.framework.trust.repositories", "${karaf.etc}/trustStore.ks"),
editConfigurationFilePut("etc/startup.properties", "mvn:org.apache.felix/org.apache.felix.framework.security/" + version, "1"),
replaceConfigurationFile("system/org/apache/felix/org.apache.felix.framework.security/" + version + "/org.apache.felix.framework.security-" + version + ".jar", temp.toFile())));
@@ -72,8 +72,6 @@ public Option[] config() {
@Test
public void testJavaSecurity() throws Exception {
- assertNotNull("Karaf should run under a security manager", System.getSecurityManager());
-
BundleService service = getOsgiService(BundleService.class);
long tried = 0;
while (true) {
diff --git a/itests/test/src/test/java/org/apache/karaf/itests/JtaTest.java b/itests/test/src/test/java/org/apache/karaf/itests/JtaTest.java
index 7a8dbc80490..04f7d3a5232 100644
--- a/itests/test/src/test/java/org/apache/karaf/itests/JtaTest.java
+++ b/itests/test/src/test/java/org/apache/karaf/itests/JtaTest.java
@@ -69,25 +69,17 @@ public Option[] config() {
public void noSpecialFeatures() throws Exception {
ClassLoader cl = FrameworkUtil.getBundle(this.getClass()).adapt(BundleWiring.class).getClassLoader();
- if (isJDK8OrEarlier()) {
- // these classes should be boot delegated because they should be part of JDK8, all used ONLY
- // in com.sun.corba.se.impl.javax.rmi.CORBA.Util.mapSystemException()
- ensureLoadedFromSystem(cl, "jakarta.transaction.InvalidTransactionException");
- ensureLoadedFromSystem(cl, "jakarta.transaction.TransactionRequiredException");
- ensureLoadedFromSystem(cl, "jakarta.transaction.TransactionRolledbackException");
- } else {
- // JDK9+ doesn't provide jakarta.transaction package at all
- ensureNotFound(cl, "jakarta.transaction.InvalidTransactionException");
- ensureNotFound(cl, "jakarta.transaction.TransactionRequiredException");
- ensureNotFound(cl, "jakarta.transaction.TransactionRolledbackException");
- }
+ // JDK9+ doesn't provide jakarta.transaction package at all
+ ensureNotFound(cl, "jakarta.transaction.InvalidTransactionException");
+ ensureNotFound(cl, "jakarta.transaction.TransactionRequiredException");
+ ensureNotFound(cl, "jakarta.transaction.TransactionRolledbackException");
- // whatever the JDK, these classes should be available
+ // these classes should be available
ensureLoadedFromSystem(cl, "javax.transaction.xa.XAException");
ensureLoadedFromSystem(cl, "javax.transaction.xa.XAResource");
ensureLoadedFromSystem(cl, "javax.transaction.xa.Xid");
- // whatever the JDK, these classes should NOT be available
+ // these classes should NOT be available
ensureNotFound(cl, "jakarta.transaction.UserTransaction");
ensureNotFound(cl, "jakarta.transaction.TransactionManager");
}
@@ -101,19 +93,12 @@ public void jakartaTransaction2_0() throws Exception {
ClassLoader myCl = FrameworkUtil.getBundle(this.getClass()).adapt(BundleWiring.class).getClassLoader();
ClassLoader jtaCl = FrameworkUtil.getBundle(myCl.loadClass("jakarta.transaction.UserTransaction")).adapt(BundleWiring.class).getClassLoader();
- if (isJDK8OrEarlier()) {
- // these classes should be boot delegated
- ensureLoadedFromSystem(myCl, "jakarta.transaction.InvalidTransactionException");
- ensureLoadedFromSystem(myCl, "jakarta.transaction.TransactionRequiredException");
- ensureLoadedFromSystem(myCl, "jakarta.transaction.TransactionRolledbackException");
- } else {
- // these classes ARE boot delegated, but can't be found in JDK, so they're loaded from the API bundle
- ensureLoadedFromCl(myCl, jtaCl, "jakarta.transaction.InvalidTransactionException");
- ensureLoadedFromCl(myCl, jtaCl, "jakarta.transaction.TransactionRequiredException");
- ensureLoadedFromCl(myCl, jtaCl, "jakarta.transaction.TransactionRolledbackException");
- }
+ // these classes are boot delegated, but can't be found in JDK, so they're loaded from the API bundle
+ ensureLoadedFromCl(myCl, jtaCl, "jakarta.transaction.InvalidTransactionException");
+ ensureLoadedFromCl(myCl, jtaCl, "jakarta.transaction.TransactionRequiredException");
+ ensureLoadedFromCl(myCl, jtaCl, "jakarta.transaction.TransactionRolledbackException");
- // whatever the JDK, these classes should be available from system CL, even if jakarta.transaction-api/2.0.1
+ // these classes should be available from system CL, even if jakarta.transaction-api/2.0.1
// exports javax.transaction.xa package
ensureLoadedFromSystem(myCl, "javax.transaction.xa.XAException");
ensureLoadedFromSystem(myCl, "javax.transaction.xa.XAResource");
@@ -151,15 +136,9 @@ public void jakartaTransaction2_0AndDBCP2() throws Exception {
ClassLoader myCl = FrameworkUtil.getBundle(this.getClass()).adapt(BundleWiring.class).getClassLoader();
ClassLoader jtaCl = FrameworkUtil.getBundle(myCl.loadClass("jakarta.transaction.UserTransaction")).adapt(BundleWiring.class).getClassLoader();
- if (isJDK8OrEarlier()) {
- ensureLoadedFromSystem(myCl, "jakarta.transaction.InvalidTransactionException");
- ensureLoadedFromSystem(myCl, "jakarta.transaction.TransactionRequiredException");
- ensureLoadedFromSystem(myCl, "jakarta.transaction.TransactionRolledbackException");
- } else {
- ensureLoadedFromCl(myCl, jtaCl, "jakarta.transaction.InvalidTransactionException");
- ensureLoadedFromCl(myCl, jtaCl, "jakarta.transaction.TransactionRequiredException");
- ensureLoadedFromCl(myCl, jtaCl, "jakarta.transaction.TransactionRolledbackException");
- }
+ ensureLoadedFromCl(myCl, jtaCl, "jakarta.transaction.InvalidTransactionException");
+ ensureLoadedFromCl(myCl, jtaCl, "jakarta.transaction.TransactionRequiredException");
+ ensureLoadedFromCl(myCl, jtaCl, "jakarta.transaction.TransactionRolledbackException");
ensureLoadedFromSystem(myCl, "javax.transaction.xa.Xid");
ensureLoadedFromSystem(jtaCl, "javax.transaction.xa.Xid");
@@ -190,15 +169,9 @@ public void jakartaTransaction2_0_1AndDBCP2() throws Exception {
ClassLoader myCl = FrameworkUtil.getBundle(this.getClass()).adapt(BundleWiring.class).getClassLoader();
ClassLoader jtaCl = FrameworkUtil.getBundle(myCl.loadClass("jakarta.transaction.UserTransaction")).adapt(BundleWiring.class).getClassLoader();
- if (isJDK8OrEarlier()) {
- ensureLoadedFromSystem(myCl, "jakarta.transaction.InvalidTransactionException");
- ensureLoadedFromSystem(myCl, "jakarta.transaction.TransactionRequiredException");
- ensureLoadedFromSystem(myCl, "jakarta.transaction.TransactionRolledbackException");
- } else {
- ensureLoadedFromCl(myCl, jtaCl, "jakarta.transaction.InvalidTransactionException");
- ensureLoadedFromCl(myCl, jtaCl, "jakarta.transaction.TransactionRequiredException");
- ensureLoadedFromCl(myCl, jtaCl, "jakarta.transaction.TransactionRolledbackException");
- }
+ ensureLoadedFromCl(myCl, jtaCl, "jakarta.transaction.InvalidTransactionException");
+ ensureLoadedFromCl(myCl, jtaCl, "jakarta.transaction.TransactionRequiredException");
+ ensureLoadedFromCl(myCl, jtaCl, "jakarta.transaction.TransactionRolledbackException");
ensureLoadedFromSystem(jtaCl, "javax.transaction.xa.Xid");
ensureLoadedFromSystem(myCl, "javax.transaction.xa.Xid");
@@ -235,19 +208,4 @@ private void ensureNotFound(ClassLoader cl, String className) {
}
}
- private boolean isJDK8OrEarlier() {
- String v = System.getProperty("java.specification.version");
- try {
- if (v.contains(".")) {
- float f = Float.parseFloat(v);
- return f < 1.9F;
- } else {
- int i = Integer.parseInt(v);
- return i < 9;
- }
- } catch (NumberFormatException ignored) {
- return true;
- }
- }
-
}
diff --git a/itests/test/src/test/java/org/apache/karaf/itests/features/EnterpriseFeaturesTest.java b/itests/test/src/test/java/org/apache/karaf/itests/features/EnterpriseFeaturesTest.java
index 5e1253f8cda..852a11cbac4 100644
--- a/itests/test/src/test/java/org/apache/karaf/itests/features/EnterpriseFeaturesTest.java
+++ b/itests/test/src/test/java/org/apache/karaf/itests/features/EnterpriseFeaturesTest.java
@@ -14,7 +14,6 @@
package org.apache.karaf.itests.features;
import org.apache.karaf.itests.BaseTest;
-import org.apache.karaf.itests.util.RunIfRules.RunIfNotOnJdk8;
import org.apache.karaf.itests.util.RunIfRule;
import org.junit.Ignore;
diff --git a/itests/test/src/test/java/org/apache/karaf/itests/util/RunIfRules.java b/itests/test/src/test/java/org/apache/karaf/itests/util/RunIfRules.java
deleted file mode 100644
index 35c253b5134..00000000000
--- a/itests/test/src/test/java/org/apache/karaf/itests/util/RunIfRules.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.karaf.itests.util;
-
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-import org.apache.karaf.itests.util.RunIfRule.RunIf;
-import org.apache.karaf.itests.util.RunIfRule.RunIfCondition;
-
-public class RunIfRules {
-
- @RunIf(condition = RunIfNotOnJdk8Condition.class)
- @Retention(RetentionPolicy.RUNTIME)
- @Inherited
- public @interface RunIfNotOnJdk8 {
-
- }
-
- public static class RunIfNotOnJdk8Condition implements RunIfCondition {
- @Override
- public boolean isSatisfied() {
- String jdk = System.getProperty("java.specification.version");
- return jdk.equals("1.5") || jdk.equals("1.6") || jdk.equals("1.7");
- }
- }
-
-}
diff --git a/jaas/command/src/main/java/org/apache/karaf/jaas/command/SudoCommand.java b/jaas/command/src/main/java/org/apache/karaf/jaas/command/SudoCommand.java
index 18e57e56fba..11d26b9c3c9 100644
--- a/jaas/command/src/main/java/org/apache/karaf/jaas/command/SudoCommand.java
+++ b/jaas/command/src/main/java/org/apache/karaf/jaas/command/SudoCommand.java
@@ -74,7 +74,15 @@ public Object execute() throws Exception {
}
sb.append(s);
}
- JaasHelper.doAs(subject, (PrivilegedExceptionAction