mirror of
https://github.com/corda/corda.git
synced 2025-01-29 15:43:55 +00:00
ENT-11113 Updating test case for accessing modifier as per JDK17 compatibility
This commit is contained in:
parent
d9e0172bf7
commit
49f35aa5ea
@ -330,6 +330,7 @@ jar {
|
||||
tasks.named('test', Test) {
|
||||
maxHeapSize = "3g"
|
||||
maxParallelForks = (System.env.CORDA_NODE_TESTING_FORKS == null) ? 1 : "$System.env.CORDA_NODE_TESTING_FORKS".toInteger()
|
||||
jvmArgs(['--add-opens', 'java.base/java.lang.reflect=ALL-UNNAMED', '--add-opens', 'java.base/java.util=ALL-UNNAMED'])
|
||||
}
|
||||
|
||||
publishing {
|
||||
|
@ -7,12 +7,12 @@ import org.assertj.core.api.Assertions.assertThatExceptionOfType
|
||||
import org.junit.After
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import org.mockito.ArgumentMatchers.contains
|
||||
import org.mockito.kotlin.spy
|
||||
import org.mockito.kotlin.verify
|
||||
import org.slf4j.Logger
|
||||
import java.lang.invoke.MethodHandles
|
||||
import java.lang.reflect.Field
|
||||
import java.lang.reflect.Modifier
|
||||
import java.nio.file.Files
|
||||
@ -71,13 +71,12 @@ class ConfigHelperTests {
|
||||
}
|
||||
|
||||
@Test(timeout = 300_000)
|
||||
@Ignore("TODO JDK17: Modifiers no longer supported")
|
||||
fun `bad keys are ignored and warned for`() {
|
||||
val loggerField = Node::class.java.getDeclaredField("staticLog")
|
||||
loggerField.isAccessible = true
|
||||
val modifiersField = Field::class.java.getDeclaredField("modifiers")
|
||||
modifiersField.isAccessible = true
|
||||
modifiersField.setInt(loggerField, loggerField.modifiers and Modifier.FINAL.inv())
|
||||
val fieldLookup = MethodHandles.privateLookupIn(Field::class.java, MethodHandles.lookup());
|
||||
val modifiersField = fieldLookup.findVarHandle(Field::class.java, "modifiers", Int::class.javaPrimitiveType)
|
||||
modifiersField.set(loggerField, loggerField.modifiers and Modifier.FINAL.inv())
|
||||
val originalLogger = loggerField.get(null) as Logger
|
||||
val spyLogger = spy(originalLogger)
|
||||
loggerField.set(null, spyLogger)
|
||||
|
Loading…
x
Reference in New Issue
Block a user