-
Bug
-
Resolution: Unresolved
-
P4
-
11, 17
-
Cause Known
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
The dynamic registration of members to filter on jdk.internal.reflect.Reflection through registerFieldsToFilter(...) and registerMethodsToFilter(...) (seeJDK-8210496) might be flawed.
Because these methods are executed in the static initializers of the respective classes, accessing the class without initializing it prevents the registration of the filters.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Finding the method `getUnsafe` should fail
ACTUAL -
It does not fail, unless Unsafe has been initialized before
---------- BEGIN SOURCE ----------
public class ReflectionFilteringTest {
public static void main(String[] args) throws Exception {
boolean initialize = false;
Class<?> c = Class.forName("sun.misc.Unsafe", initialize, ReflectionFilteringTest.class.getClassLoader());
// This should fail because getUnsafe is supposed to be filtered
// But it does not fail if Unsafe has not been initialized yet
Method m = c.getDeclaredMethod("getUnsafe");
System.out.println(m);
}
}
---------- END SOURCE ----------
The dynamic registration of members to filter on jdk.internal.reflect.Reflection through registerFieldsToFilter(...) and registerMethodsToFilter(...) (see
Because these methods are executed in the static initializers of the respective classes, accessing the class without initializing it prevents the registration of the filters.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Finding the method `getUnsafe` should fail
ACTUAL -
It does not fail, unless Unsafe has been initialized before
---------- BEGIN SOURCE ----------
public class ReflectionFilteringTest {
public static void main(String[] args) throws Exception {
boolean initialize = false;
Class<?> c = Class.forName("sun.misc.Unsafe", initialize, ReflectionFilteringTest.class.getClassLoader());
// This should fail because getUnsafe is supposed to be filtered
// But it does not fail if Unsafe has not been initialized yet
Method m = c.getDeclaredMethod("getUnsafe");
System.out.println(m);
}
}
---------- END SOURCE ----------
- relates to
-
JDK-8161129 Unsafe::getUnsafe should allow the platform class loader to access it
-
- Resolved
-
- links to
-
Review(master) openjdk/jdk/20058