-
Bug
-
Resolution: Fixed
-
P4
-
10, repo-valhalla
The Atomic*FieldUpdaterTest.checkPrivateAccess tries to create an field updater for a private in field in AtomicReferenceFieldUpdaterTest, using an "unrelated" class and a subclass, as contexts in which access to a private field should be disallowed. In both cases the calling class is defined as a nested class of Atomic*FieldUpdaterTest and so in fact - based on JLS - does have access to a private field of the enclosing class. The fact this test currently passes is to due to the misalignment between JLS access rules and JVMS/Reflection access rules.
With nestmates the misalignment is gone and the access is allowed causing the test to fail.
The test needs to use classes that are not nested classes of the class holding the private field to be accessed.
The simplest solution is to use package-private classes defined in the same source file and give the Unrelated class a unique name.
With nestmates the misalignment is gone and the access is allowed causing the test to fail.
The test needs to use classes that are not nested classes of the class holding the private field to be accessed.
The simplest solution is to use package-private classes defined in the same source file and give the Unrelated class a unique name.