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

IllegalAccessError trying to access package-private class from VM anonymous class

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8u60, 9
    • Fix Version/s: 9
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b137

      Description

      Consider the following case:
        public class p1.IAE {...}
        /*package*/ class p1.Test {...}
        public class p2.AnonClass {...} // VM anonymous class w/ p1.Test provided as a host class.

      If AnonClass tries to access p1.Test the following exception is thrown:
      java.lang.IllegalAccessError: tried to access class p1.T from class p2.AnonClass/1309552426
      at p2.AnonClass/1309552426.test(Unknown Source)
      ... 5 more

      Though AnonClass tries to access package-private in p1 from p2, for VM anonymous class inherit it's host class should be used for all access checks. p1.IAE has access to p1.Test.

      Test case is attached.
      How to run:
        $ javac -XDignore.symbol.file -d . IAE.java
        $ java -Xbootclasspath/a:. p1.IAE

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                hseigel Harold Seigel
                Reporter:
                vlivanov Vladimir Ivanov
              • Votes:
                0 Vote for this issue
                Watchers:
                12 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: