Skip to content

Commit 9a3ab97

Browse files
authored
Update well-known versions in Jvm (spockframework#2057)
1 parent 276d2c6 commit 9a3ab97

File tree

4 files changed

+123
-2
lines changed

4 files changed

+123
-2
lines changed

docs/release_notes.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ include::include.adoc[]
1616
* Add new <<extensions.adoc#default-value-provider,`IDefaultValueProviderExtension`>> extension point to add support for special classes in the Stub's default `EmptyOrDummyResponse` spockPull:1994[]
1717
* Add support for Groovy-4-style range expressions spockIssue:1956[]
1818
* Add `IStatelessAnnotationDrivenExtension` to allow a single extension instance to be reused across all specifications spockPull:2055[]
19+
* Add new well-known versions to `Jvm` helper to support versions up to 29 spockPull:2057[]
1920
** Built-in extensions have been updated to use this new interface where applicable.
2021
* Improve `@Timeout` extension will now use virtual threads if available spockPull:1986[]
2122
* Improve mock argument matching, types constraints or arguments in interactions can now handle primitive types like `_ as int` spockIssue:1974[]

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#
1616

1717
org.gradle.java.installations.auto-download=false
18-
org.gradle.java.installations.fromEnv=JDK8,JDK11,JDK17,JDK21
18+
org.gradle.java.installations.fromEnv=JDK8,JDK11,JDK17,JDK21,JDK23
1919

2020
org.gradle.parallel=true
2121
org.gradle.caching=true

spock-core/src/main/java/spock/util/environment/Jvm.java

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,66 @@ public boolean isJava23() {
210210
return "23".equals(javaSpecVersion);
211211
}
212212

213+
/**
214+
* Tells whether the Java version is 24.
215+
*
216+
* @since 2.4
217+
* @return whether the Java version is 24
218+
*/
219+
public boolean isJava24() {
220+
return "24".equals(javaSpecVersion);
221+
}
222+
223+
/**
224+
* Tells whether the Java version is 25.
225+
*
226+
* @since 2.4
227+
* @return whether the Java version is 25
228+
*/
229+
public boolean isJava25() {
230+
return "25".equals(javaSpecVersion);
231+
}
232+
233+
/**
234+
* Tells whether the Java version is 26.
235+
*
236+
* @since 2.4
237+
* @return whether the Java version is 26
238+
*/
239+
public boolean isJava26() {
240+
return "26".equals(javaSpecVersion);
241+
}
242+
243+
/**
244+
* Tells whether the Java version is 27.
245+
*
246+
* @since 2.4
247+
* @return whether the Java version is 27
248+
*/
249+
public boolean isJava27() {
250+
return "27".equals(javaSpecVersion);
251+
}
252+
253+
/**
254+
* Tells whether the Java version is 28.
255+
*
256+
* @since 2.4
257+
* @return whether the Java version is 28
258+
*/
259+
public boolean isJava28() {
260+
return "28".equals(javaSpecVersion);
261+
}
262+
263+
/**
264+
* Tells whether the Java version is 29.
265+
*
266+
* @since 2.4
267+
* @return whether the Java version is 29
268+
*/
269+
public boolean isJava29() {
270+
return "29".equals(javaSpecVersion);
271+
}
272+
213273
/**
214274
* Tells whether the Java version is equal to the given major Java version.
215275
*
@@ -383,6 +443,66 @@ public boolean isJava23Compatible() {
383443
return javaSpecVersionNumber.getMajor() >= 23;
384444
}
385445

446+
/**
447+
* Tells whether the Java version is compatible with Java 24.
448+
*
449+
* @since 2.4
450+
* @return whether the Java version is compatible with Java 24
451+
*/
452+
public boolean isJava24Compatible() {
453+
return javaSpecVersionNumber.getMajor() >= 24;
454+
}
455+
456+
/**
457+
* Tells whether the Java version is compatible with Java 25.
458+
*
459+
* @since 2.4
460+
* @return whether the Java version is compatible with Java 25
461+
*/
462+
public boolean isJava25Compatible() {
463+
return javaSpecVersionNumber.getMajor() >= 25;
464+
}
465+
466+
/**
467+
* Tells whether the Java version is compatible with Java 26.
468+
*
469+
* @since 2.4
470+
* @return whether the Java version is compatible with Java 26
471+
*/
472+
public boolean isJava26Compatible() {
473+
return javaSpecVersionNumber.getMajor() >= 26;
474+
}
475+
476+
/**
477+
* Tells whether the Java version is compatible with Java 27.
478+
*
479+
* @since 2.4
480+
* @return whether the Java version is compatible with Java 27
481+
*/
482+
public boolean isJava27Compatible() {
483+
return javaSpecVersionNumber.getMajor() >= 27;
484+
}
485+
486+
/**
487+
* Tells whether the Java version is compatible with Java 28.
488+
*
489+
* @since 2.4
490+
* @return whether the Java version is compatible with Java 28
491+
*/
492+
public boolean isJava28Compatible() {
493+
return javaSpecVersionNumber.getMajor() >= 28;
494+
}
495+
496+
/**
497+
* Tells whether the Java version is compatible with Java 29.
498+
*
499+
* @since 2.4
500+
* @return whether the Java version is compatible with Java 29
501+
*/
502+
public boolean isJava29Compatible() {
503+
return javaSpecVersionNumber.getMajor() >= 29;
504+
}
505+
386506
/**
387507
* Tells whether the Java version is compatible with the given major Java version.
388508
*

spock-specs/src/test/groovy/org/spockframework/smoke/extension/RequiresExtension.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ class Test extends Bar {
448448
@Requires({
449449
jvm.java8 || jvm.java9 || jvm.java10 || jvm.java11 || jvm.java12 || jvm.java13 || jvm.java14 || jvm.java15 || jvm.java16 || jvm.java17 ||
450450
jvm.isJavaVersion(18) ||
451-
jvm.java21 || jvm.java22 || jvm.java23
451+
jvm.java21 || jvm.java22 || jvm.java23 || jvm.java24 || jvm.java25 || jvm.java26 || jvm.java27 || jvm.java28 || jvm.java29
452452
})
453453
def "provides JVM information"() {
454454
expect: true

0 commit comments

Comments
 (0)