HHH-15107 Use net.bytebuddy.experimental=true when running tests against JDK19

This commit is contained in:
Yoann Rodière 2022-03-04 09:22:56 +01:00
parent a88170d24a
commit 5eb8a6fab1
1 changed files with 7 additions and 1 deletions

View File

@ -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