We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 9a3acb6 commit a92e289Copy full SHA for a92e289
utbot-core/src/main/kotlin/org/utbot/common/ReflectionUtil.kt
@@ -15,7 +15,15 @@ object Reflection {
15
unsafe = f.get(null) as Unsafe
16
}
17
18
- private val modifiersField: Field = Field::class.java.getDeclaredField("modifiers")
+
19
+ // TODO: works on JDK 8-17. Doesn't work on JDK 18
20
+ private val modifiersField: Field = run {
21
+ val getDeclaredFields0 = Class::class.java.getDeclaredMethod("getDeclaredFields0", Boolean::class.java)
22
+ getDeclaredFields0.isAccessible = true
23
+ @Suppress("UNCHECKED_CAST")
24
+ val fields = getDeclaredFields0.invoke(Field::class.java, false) as Array<Field>
25
+ fields.first { it.name == "modifiers" }
26
+ }
27
28
init {
29
modifiersField.isAccessible = true
0 commit comments