Hi everyone, during our migration to java 21 I not...
# test
m
Hi everyone, during our migration to java 21 I noticed some changed behavior that I cannot track down as to why it happens. We have a category of tests that are classified by using a custom tag as follows:
Copy code
@Tag(TestCategory.DatabaseTest)
annotation class DatabaseTest {
    companion object {
        init {
            sharedDependency = TestImplementationOfDependency()
        }
    }
}
The shared dependency is declared as follow in order to be switched out in tests:
Copy code
var sharedDependency: SharedDependency? = null
val SHARED_DEPENDENCY: SharedDependency
    get() {
        if (sharedDependency == null) {
            sharedDependency = ProductionImplementationOfDependency()
        }
        return sharedDependency ?: throw RuntimeException("SharedDependency set to null by another thread")
    }
When running on java 11, the shared dependency is correctly set to the TestImplementation, this can clearly be seen by placing a breakpoint in the init block. However, when running on java 21 the init block of the tag is not executed. Does anyone have a clue as to why that could be?