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

6.5: invokevirtual must specify selection when resolved method is in interface


    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 11
    • Component/s: specification
    • Labels:
    • Subcomponent:


      "Let C be the class of objectref. The actual method to be invoked is selected by the following lookup procedure ... If C contains a declaration for an instance method m that overrides (§5.4.5) the resolved method, then m is the method to be invoked."

      Selection for invokevirtual is defined in terms of overriding; but overriding is undefined for interfaces:

      5.4.5: "An instance method mC declared in class C overrides another instance method mA declared in class A iff either mC is the same as mA, or all of the following are true: C is a subclass of A."

      We need to either:

      i) Special-case the logic for selection based on a resolved interface method (simplifying assumptions: interface is a superinterface of the referenced class, no superclass of the referenced class matches the descriptor, the resolved method is public)

      ii) Generalize overriding to include class-interface overriding (optional: include 'invokeinterface' in this as well; in that case, also need to support overriding by inherited methods, where the two method declarations don't "know" about each other)

      There are some subtle differences between 'invokeinterface' and 'invokevirtual' that should be taken into account here. Also, older versions of JVMS may be useful -- they may have done a better job of capturing the expected behavior.


          Issue Links



              • Assignee:
                dlsmith Dan Smith
                dlsmith Dan Smith
              • Votes:
                0 Vote for this issue
                1 Start watching this issue


                • Created: