oracle / graal

GraalVM compiles Java applications into native executables that start instantly, scale fast, and use fewer compute resources 🚀
https://www.graalvm.org
Other
20.3k stars 1.63k forks source link

`jdk.internal.misc.Unsafe.objectFieldOffset` substitution is sensitive to reflection filters #3961

Open ivan-ristovic opened 2 years ago

ivan-ristovic commented 2 years ago

Object field offset is calculated during build and stored in the offset field of Target_java_lang_reflect_Field substitution. jdk.internal.misc.Unsafe.objectFieldOffset is substituted in the following way: https://github.com/oracle/graal/blob/d0577b6cb0b7fce7b96f9d1f1855c2b4fd3cddd9/substratevm/src/com.oracle.svm.reflect/src/com/oracle/svm/reflect/target/Target_jdk_internal_misc_Unsafe_Reflection.java#L73-L79

This impementation is sensitive to reflection filters present in jdk.internal.reflect.Reflection.fieldFilterMap. There is at least one use-case for Unsafe.objectFieldOffset that breaks on Java 17 because of the field ClassLoader.classLoaderValueMap being filtered for ClassLoader class (#3811, with #3940 as a temporary workaround).

jdk.internal.misc.Unsafe.objectFieldOffset substitution should be updated so that it does not use reflection.

sdeleuze commented 2 years ago

Please add spring label to this issue since it is impacting us.

ivan-ristovic commented 2 years ago

Unfortunately I do not have the permissions to add labels, I hope someone else can do it.

rodrigar-mx commented 2 years ago

Thanks for sharing this issue. A member of the Dev team will take a look into it shortly.

koutheir commented 1 year ago

This issue affects Java SE 11 too, and causes failures in many JCK tests.