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

JLS membership algorithm is too strong for JVMS method resolution

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Future Project
    • Affects Version/s: 7
    • Fix Version/s: None
    • Component/s: specification
    • Labels:
      None
    • Subcomponent:
    • CPU:
      generic
    • OS:
      generic

      Description

      This program compiles without error. It fails with an IllegalAccessError at runtime because A2#test does an invokevirtual A2#getI; since A2 doesn't declare getI, A1#getI method is resolved and is inaccessible from A2. It may appear that A2#test should do an invokeinterface I1#getI but the JLS doesn't want this to happen (for good reason - A2 logically has a member getI).

      class A1 {
        private int getI() {
           return 1;
        }
      }
      interface I1 {
         int getI();
      }
      abstract class A2 extends A1 implements I1 {
        public void test() {
           System.out.println(getI());
        }
      }
      class A3 extends A2 {
        public int getI() {
           return 2;
        }
      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                abuckley Alex Buckley
                Reporter:
                abuckley Alex Buckley
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: