Skip to content

Commit 1c7a15c

Browse files
committed
Forbid pre-17 JREs in execution condition annotations
1 parent b6b9798 commit 1c7a15c

File tree

13 files changed

+61
-64
lines changed

13 files changed

+61
-64
lines changed

documentation/src/docs/asciidoc/release-notes/release-notes-6.0.0-M1.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ repository on GitHub.
6565

6666
* The `JRE` enum constants for `JAVA_8` to `JAVA_16` have been deprecated because they can
6767
no longer be used at runtime since `JAVA_17` is the new baseline.
68+
* `@EnabledForJreRange` and `@DisabledForJreRange` now use `JAVA_17` as their default
69+
`min` value.
70+
* `@EnabledOnJre`, `@DisabledOnJre`, `@EnabledForJreRange`, and `@DisabledForJreRange` now
71+
fail if a JRE version less than 17 is specified.
6872

6973
[[release-notes-6.0.0-M1-junit-jupiter-new-features-and-improvements]]
7074
==== New Features and Improvements

junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/AbstractJreRangeCondition.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ protected final boolean isCurrentVersionWithinRange(JRE minJre, JRE maxJre, int
5858
// Now that we have checked the basic preconditions, we need to ensure that we are
5959
// using valid JRE enum constants.
6060
if (!minJreSet) {
61-
minJre = minJre();
61+
minJre = JRE.JAVA_17;
6262
}
6363
if (!maxJreSet) {
6464
maxJre = JRE.OTHER;
@@ -77,9 +77,4 @@ protected final boolean isCurrentVersionWithinRange(JRE minJre, JRE maxJre, int
7777
return JRE.isCurrentVersionWithinRange(min, max);
7878
}
7979

80-
@SuppressWarnings("removal")
81-
private static JRE minJre() {
82-
return JRE.JAVA_8;
83-
}
84-
8580
}

junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/DisabledForJreRange.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
* {@link #minVersion() minVersion} instead.
9797
*
9898
* <p>Defaults to {@link JRE#UNDEFINED UNDEFINED}, which will be interpreted
99-
* as {@link JRE#JAVA_8 JAVA_8} if the {@link #minVersion() minVersion} is
99+
* as {@link JRE#JAVA_17 JAVA_17} if the {@link #minVersion() minVersion} is
100100
* not set.
101101
*
102102
* @see JRE

junit-jupiter-api/src/main/java/org/junit/jupiter/api/condition/EnabledForJreRange.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
* {@link #minVersion() minVersion} instead.
9797
*
9898
* <p>Defaults to {@link JRE#UNDEFINED UNDEFINED}, which will be interpreted
99-
* as {@link JRE#JAVA_8 JAVA_8} if the {@link #minVersion() minVersion} is
99+
* as {@link JRE#JAVA_17 JAVA_17} if the {@link #minVersion() minVersion} is
100100
* not set.
101101
*
102102
* @see JRE

junit-jupiter-api/src/templates/resources/main/org/junit/jupiter/api/condition/JRE.java.jte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public enum JRE {
8585

8686
static final int UNDEFINED_VERSION = -1;
8787

88-
static final int MINIMUM_VERSION = ${jres.getFirst().getVersion()};
88+
static final int MINIMUM_VERSION = ${minRuntimeVersion};
8989

9090
private static final int CURRENT_VERSION = Runtime.version().feature();
9191

jupiter-tests/src/templates/resources/test/org/junit/jupiter/api/condition/DisabledOnJreConditionTests.java.jte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ class DisabledOnJreConditionTests extends AbstractExecutionConditionTests {
7474
* @see DisabledOnJreIntegrationTests#version7()
7575
*/
7676
@Test
77-
void version7() {
77+
void version16() {
7878
assertThatExceptionOfType(PreconditionViolationException.class)//
7979
.isThrownBy(this::evaluateCondition)//
80-
.withMessage("Version [7] in @DisabledOnJre must be greater than or equal to 8");
80+
.withMessage("Version [16] in @DisabledOnJre must be greater than or equal to 17");
8181
}
8282

8383
/**

jupiter-tests/src/templates/resources/test/org/junit/jupiter/api/condition/DisabledOnJreIntegrationTests.java.jte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ class DisabledOnJreIntegrationTests {
5050

5151
@Test
5252
@Disabled("Only used in a unit test via reflection")
53-
@DisabledOnJre(value = JAVA_17, versions = { 21, 7 })
54-
void version7() {
53+
@DisabledOnJre(value = JAVA_17, versions = { 21, 16 })
54+
void version16() {
5555
}
5656

5757
@Test

jupiter-tests/src/templates/resources/test/org/junit/jupiter/api/condition/EnabledOnJreConditionTests.java.jte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ class EnabledOnJreConditionTests extends AbstractExecutionConditionTests {
7171
}
7272

7373
/**
74-
* @see EnabledOnJreIntegrationTests#version7()
74+
* @see EnabledOnJreIntegrationTests#version16()
7575
*/
7676
@Test
77-
void version7() {
77+
void version16() {
7878
assertThatExceptionOfType(PreconditionViolationException.class)//
7979
.isThrownBy(this::evaluateCondition)//
80-
.withMessage("Version [7] in @EnabledOnJre must be greater than or equal to 8");
80+
.withMessage("Version [16] in @EnabledOnJre must be greater than or equal to 17");
8181
}
8282

8383
/**

jupiter-tests/src/templates/resources/test/org/junit/jupiter/api/condition/EnabledOnJreIntegrationTests.java.jte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ class EnabledOnJreIntegrationTests {
4949

5050
@Test
5151
@Disabled("Only used in a unit test via reflection")
52-
@EnabledOnJre(value = JAVA_17, versions = { 21, 7 })
53-
void version7() {
52+
@EnabledOnJre(value = JAVA_17, versions = { 21, 16 })
53+
void version16() {
5454
}
5555

5656
@Test

jupiter-tests/src/test/java/org/junit/jupiter/api/condition/DisabledForJreRangeConditionTests.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,18 +80,18 @@ void effectiveVersionDefaultValues() {
8080
}
8181

8282
/**
83-
* @see DisabledForJreRangeIntegrationTests#min8()
83+
* @see DisabledForJreRangeIntegrationTests#min17()
8484
*/
8585
@Test
86-
void min8() {
86+
void min17() {
8787
defaultValues();
8888
}
8989

9090
/**
91-
* @see DisabledForJreRangeIntegrationTests#minVersion8()
91+
* @see DisabledForJreRangeIntegrationTests#minVersion17()
9292
*/
9393
@Test
94-
void minVersion8() {
94+
void minVersion17() {
9595
defaultValues();
9696
}
9797

@@ -112,23 +112,23 @@ void maxVersionMaxInteger() {
112112
}
113113

114114
/**
115-
* @see DisabledForJreRangeIntegrationTests#minVersion7()
115+
* @see DisabledForJreRangeIntegrationTests#minVersion16()
116116
*/
117117
@Test
118-
void minVersion7() {
118+
void minVersion16() {
119119
assertThatExceptionOfType(PreconditionViolationException.class)//
120120
.isThrownBy(this::evaluateCondition)//
121-
.withMessage("@DisabledForJreRange's minVersion [7] must be greater than or equal to 8");
121+
.withMessage("@DisabledForJreRange's minVersion [16] must be greater than or equal to 17");
122122
}
123123

124124
/**
125-
* @see DisabledForJreRangeIntegrationTests#maxVersion7()
125+
* @see DisabledForJreRangeIntegrationTests#maxVersion16()
126126
*/
127127
@Test
128-
void maxVersion7() {
128+
void maxVersion16() {
129129
assertThatExceptionOfType(PreconditionViolationException.class)//
130130
.isThrownBy(this::evaluateCondition)//
131-
.withMessage("@DisabledForJreRange's maxVersion [7] must be greater than or equal to 8");
131+
.withMessage("@DisabledForJreRange's maxVersion [16] must be greater than or equal to 17");
132132
}
133133

134134
/**

0 commit comments

Comments
 (0)