From 5eb8a6fab1af5c2baf58b83e1d8355c8e56f3a24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Fri, 4 Mar 2022 09:22:56 +0100 Subject: [PATCH] HHH-15107 Use net.bytebuddy.experimental=true when running tests against JDK19 --- gradle/java-module.gradle | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gradle/java-module.gradle b/gradle/java-module.gradle index a6792d0390fb..f1dbd87ecb70 100644 --- a/gradle/java-module.gradle +++ b/gradle/java-module.gradle @@ -348,7 +348,13 @@ test { // Enable the experimental features of ByteBuddy with JDK 19+ test { - if ( gradle.ext.javaVersions.test.release.asInt() >= 19 ) { + // We need to test the *launcher* version, + // because some tests will use Mockito (and thus Bytebuddy) to mock/spy + // classes that are part of the JDK, + // and those classes always have bytecode matching the version of the launcher. + // So for example, when using a JDK19 launcher and compiling tests with --release 17, + // Bytebuddy will still encounter classes with Java 19 bytecode. + if ( gradle.ext.javaVersions.test.launcher.asInt() >= 19 ) { logger.warn( "The version of Java bytecode that will be tested is not supported by Bytebuddy by default. " + " Setting 'net.bytebuddy.experimental=true'." ) systemProperty 'net.bytebuddy.experimental', true