Skip to content

ByteBuddy in AssertJ 3.27.4 not compatible with Java 25 #3946

@thmarx

Description

@thmarx

The byte-buddy version shipped with assertj 3 does not support jdk25.

  • assertj core version: 3.27.4
  • java version: 25
  • test framework version: junit5

Test case reproducing the bug

The exception is thrown my mockito, but the reason is the byte-buddy version that comes with assertj

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>de.issue-test</groupId>
    <artifactId>test</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.release>25</maven.compiler.release>
    </properties>
	
	<dependencies>
		<dependency>
			<groupId>org.assertj</groupId>
			<artifactId>assertj-core</artifactId>
			<scope>test</scope>
			<version>3.27.4</version>
		</dependency>
		<dependency>
			<groupId>org.mockito</groupId>
			<artifactId>mockito-core</artifactId>
			<scope>test</scope>
			<version>5.19.0</version>
		</dependency>
		<dependency>
			<groupId>org.mockito</groupId>
			<artifactId>mockito-junit-jupiter</artifactId>
			<scope>test</scope>
			<version>5.19.0</version>
		</dependency>
		<dependency>
			<groupId>org.junit.jupiter</groupId>
			<artifactId>junit-jupiter</artifactId>
			<scope>test</scope>
			<version>5.13.4</version>
		</dependency>
	</dependencies>
</project>
package de.marx_software.test;

import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;

public class TestTest {

	@Test
	public void testSomeMethod() {

		var test2 = Mockito.mock(TestC.class);

		Mockito.when(test2.getName()).thenReturn("jdk25 test");

		Assertions.assertThat(test2.getName()).isEqualTo("jdk25 test");
	}

	public static class TestC {

		public String getName() {
			return "test";
		}
	}
}

Metadata

Metadata

Assignees

Labels

language: Java 25+An issue related to using AssertJ with Java 25 or newer

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions