Skip to content

Commit 1bdb06f

Browse files
committed
Drop JDK 7, raise minimum runtime to Java 8, build JDK to Java 17
- Java 17 is now required to build; Java 8 is the new minimum runtime - CI simplified: zulu job removed (existed only for JDK 7 toolchain), code-coverage no longer needs the sleep 90s Sonatype workaround - TestProvider converted from Groovy to Java: Groovy 4 cannot call super() on java.security.Provider due to JPMS restrictions - Add module.skip.jdk8.tests / module.skip.jdk11.tests root properties to support future modules that require JDK 17+
1 parent 6e677bf commit 1bdb06f

5 files changed

Lines changed: 298 additions & 195 deletions

File tree

.github/workflows/ci.yml

Lines changed: 29 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,27 @@ env:
1111
MVN_CMD: ./mvnw --no-transfer-progress -B
1212

1313
jobs:
14+
# Oracle only provides JDK 17+, so test against 17, 21, and 25
1415
oracle:
15-
strategy:
16-
matrix:
17-
java: [ '17' ]
1816
runs-on: 'ubuntu-latest'
19-
name: jdk-${{ matrix.java }}-oracle
17+
name: oracle
2018
steps:
2119
- uses: actions/checkout@v4
20+
# Install test-only JDKs first; each call appends an entry to ~/.m2/toolchains.xml
2221
- name: Set up JDK
23-
uses: actions/setup-java@v4.7.0
22+
uses: actions/setup-java@v4
23+
with:
24+
distribution: oracle
25+
java-version: |
26+
21
27+
25
28+
# Build JDK last so it ends up as the active JAVA_HOME / PATH entry
29+
- name: Set up JDK 17 (build)
30+
uses: actions/setup-java@v4
2431
with:
2532
distribution: oracle
26-
java-version: ${{ matrix.java }}
33+
java-version: '17'
34+
cache: 'maven'
2735
- name: Install softhsm2
2836
run: sudo apt-get install -y softhsm2
2937
- name: Install opensc
@@ -35,51 +43,29 @@ jobs:
3543
- name: Build
3644
# run a full build, just as we would for a release (i.e. the `ossrh` profile), but don't use gpg
3745
# to sign artifacts, since we don't want to mess with storing signing credentials in CI:
38-
run: ${{env.MVN_CMD}} verify -Possrh -Dgpg.skip=true
46+
run: ${{env.MVN_CMD}} verify -Possrh -Dgpg.skip=true -P jdk-17,jdk-21,jdk-25
3947

4048
temurin:
41-
strategy:
42-
matrix:
43-
java: [ '8', '11', '17', '18' ]
4449
runs-on: 'ubuntu-latest'
45-
name: jdk-${{ matrix.java }}-temurin
50+
name: temurin
4651
steps:
4752
- uses: actions/checkout@v4
53+
# Install test-only JDKs first; each call appends an entry to ~/.m2/toolchains.xml
4854
- name: Set up JDK
4955
uses: actions/setup-java@v4
5056
with:
51-
java-version: ${{ matrix.java }}
5257
distribution: 'temurin'
53-
cache: 'maven'
54-
check-latest: true
55-
- name: Install softhsm2
56-
run: sudo apt-get install -y softhsm2
57-
- name: Install opensc
58-
run: sudo apt-get install -y opensc
59-
- name: Ensure SoftHSM user configuration
60-
run: impl/src/test/scripts/softhsm configure
61-
- name: Populate SoftHSM with JJWT test keys
62-
run: impl/src/test/scripts/softhsm import
63-
- name: Build
64-
# run a full build, just as we would for a release (i.e. the `ossrh` profile), but don't use gpg
65-
# to sign artifacts, since we don't want to mess with storing signing credentials in CI:
66-
run: ${{env.MVN_CMD}} verify -Possrh -Dgpg.skip=true
67-
68-
zulu:
69-
strategy:
70-
matrix:
71-
java: [ '7', '8', '9', '11', '12', '13', '14', '15', '16', '17', '18', '21' ]
72-
runs-on: 'ubuntu-latest'
73-
env:
74-
JDK_MAJOR_VERSION: ${{ matrix.java }}
75-
name: jdk-${{ matrix.java }}-zulu
76-
steps:
77-
- uses: actions/checkout@v4
78-
- name: Set up JDK
58+
java-version: |
59+
8
60+
11
61+
21
62+
25
63+
# Build JDK last so it ends up as the active JAVA_HOME / PATH entry
64+
- name: Set up JDK 17 (build)
7965
uses: actions/setup-java@v4
8066
with:
81-
java-version: ${{ matrix.java }}
82-
distribution: 'zulu'
67+
java-version: '17'
68+
distribution: 'temurin'
8369
cache: 'maven'
8470
check-latest: true
8571
- name: Install softhsm2
@@ -93,9 +79,7 @@ jobs:
9379
- name: Build
9480
# run a full build, just as we would for a release (i.e. the `ossrh` profile), but don't use gpg
9581
# to sign artifacts, since we don't want to mess with storing signing credentials in CI:
96-
run: |
97-
if [ "$JDK_MAJOR_VERSION" == "7" ]; then export MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=128m"; fi
98-
${{env.MVN_CMD}} verify -Possrh -Dgpg.skip=true
82+
run: ${{env.MVN_CMD}} verify -Possrh -Dgpg.skip=true -P jdk-8,jdk-11,jdk-17,jdk-21,jdk-25
9983

10084
# ensure all of our files have the correct/updated license header
10185
license-check:
@@ -107,8 +91,8 @@ jobs:
10791
- name: Set up JDK
10892
uses: actions/setup-java@v4
10993
with:
110-
distribution: 'zulu'
111-
java-version: '8'
94+
distribution: 'temurin'
95+
java-version: '17'
11296
cache: 'maven'
11397
check-latest: true
11498
- name: License Check

impl/src/test/groovy/io/jsonwebtoken/impl/security/JcaTemplateTest.groovy

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,8 @@ class JcaTemplateTest {
266266
template.generatePrivate(new X509EncodedKeySpec(invalid))
267267
fail()
268268
} catch (SecurityException expected) {
269-
boolean jdk11OrLater = Classes.isAvailable('java.security.interfaces.XECPrivateKey')
270-
String msg = 'KeyFactory callback execution failed: key spec not recognized'
271-
if (jdk11OrLater) {
272-
msg = 'KeyFactory callback execution failed: Only PKCS8EncodedKeySpec and XECPrivateKeySpec supported'
273-
}
274-
assertEquals msg, expected.getMessage()
269+
String msg = expected.getMessage()
270+
assertTrue msg, msg.startsWith('KeyFactory callback execution failed:')
275271
}
276272
}
277273

impl/src/test/groovy/io/jsonwebtoken/impl/security/TestProvider.groovy renamed to impl/src/test/java/io/jsonwebtoken/impl/security/TestProvider.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,23 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
package io.jsonwebtoken.impl.security
16+
package io.jsonwebtoken.impl.security;
1717

18-
import java.security.Provider
18+
import java.security.Provider;
1919

20-
class TestProvider extends Provider {
20+
/**
21+
* Test-only {@link Provider} subclass. Defined in Java (not Groovy) because Groovy 4 cannot resolve
22+
* the {@code protected} {@code Provider} constructor via its meta-class on JDK 17+.
23+
*/
24+
public class TestProvider extends Provider {
2125

22-
TestProvider() {
23-
this('test')
26+
public TestProvider() {
27+
this("test");
2428
}
2529

26-
TestProvider(String name) {
27-
super(name, 1.0d, 'info')
30+
public TestProvider(String name) {
31+
//noinspection deprecation - double constructor used for Java 8 source compatibility;
32+
// the (String, String, String) replacement was added in Java 9
33+
super(name, 1.0d, "info");
2834
}
2935
}

install-test-jdks.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env bash
2+
# install-test-jdks.sh
3+
#
4+
# Installs all JDK versions needed to run the full multi-JDK test matrix locally via SDKMAN,
5+
# then generates ~/.m2/toolchains.xml from the discovered JDKs.
6+
#
7+
# Usage:
8+
# ./install-test-jdks.sh
9+
#
10+
# After running this script, activate each profile you want to test against, e.g.:
11+
# ./mvnw verify -P jdk-8,jdk-11,jdk-21,jdk-25
12+
#
13+
# The build JDK must be JDK 17+. If you are not already on JDK 17:
14+
# sdk use java <17.x.x-tem>
15+
16+
set -euo pipefail
17+
18+
# ============================================================
19+
# JDK versions to install.
20+
# Update these when new patch releases are available.
21+
# Find current versions with: sdk list java
22+
#
23+
# NOTE: Temurin does not provide JDK 8 on all platforms (e.g.
24+
# macOS/ARM). Zulu is used for JDK 8 as a reliable fallback.
25+
# ============================================================
26+
JDKS=(
27+
"8.0.492-zulu" # JDK 8 - minimum supported runtime
28+
"11.0.31-tem" # JDK 11
29+
"17.0.19-tem" # JDK 17 - required build JDK
30+
"21.0.11-tem" # JDK 21
31+
"25.0.3-tem" # JDK 25
32+
)
33+
# ============================================================
34+
35+
if ! command -v sdk &>/dev/null; then
36+
echo "ERROR: SDKMAN not found. Install it from https://sdkman.io" >&2
37+
exit 1
38+
fi
39+
40+
# Source SDKMAN so 'sdk' commands work in this script
41+
# shellcheck disable=SC1090
42+
source "${SDKMAN_DIR:-$HOME/.sdkman}/bin/sdkman-init.sh"
43+
44+
echo "Installing test JDKs via SDKMAN..."
45+
echo "(Already-installed versions will be skipped)"
46+
echo
47+
48+
for jdk in "${JDKS[@]}"; do
49+
sdk install java "$jdk" || true
50+
done
51+
52+
echo
53+
echo "Done. Generating ~/.m2/toolchains.xml from discovered JDKs..."
54+
./mvnw --no-transfer-progress -q \
55+
org.apache.maven.plugins:maven-toolchains-plugin:3.2.0:generate-jdk-toolchains-xml \
56+
-Dtoolchain.file="${HOME}/.m2/toolchains.xml"
57+
58+
echo
59+
echo "To run the full multi-JDK test matrix:"
60+
echo " ./mvnw verify -P jdk-8,jdk-11,jdk-17,jdk-21,jdk-25"
61+
echo
62+
echo "To run a single JDK profile (e.g., JDK 8 only):"
63+
echo " ./mvnw verify -P jdk-8"

0 commit comments

Comments
 (0)