Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8187607

[Testbug] Atomic*FieldUpdaterTest.checkPrivateAccess uses nested classes

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 10, repo-valhalla
    • Fix Version/s: 10
    • Component/s: core-libs

      Description

      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.

        Attachments

          Activity

            People

            • Assignee:
              martin Martin Buchholz
              Reporter:
              dholmes David Holmes
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: