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

5.4.3.5: REF_invokeSpecial behavior should enforce sender/receiver relationship

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 8
    • specification
    • vm

      JVMS8 says that method handle of kind REF_invokeSpecial has the following bytecode behavior
          invokespecial C.m:(A*)T
      and descriptor
          (C,A*)T
      where C - class that contains target method, A* - target method parameters, T - target method return type

      Such description does not consider specific checks performed for invokespecial instruction:
      1. invokespecial may only invoke method defined in a superclass or a current class. Therefore, if C is not the current class or a superclass then resolution must fail. Otherwise, it would be possible to effectively do invokespecial on another class.
      2. invokespecial may only be invoked on instance of the current class or a subclass. Therefore, method handle type descriptor must be (CurrentClass, A*)T. Otherwise, it would be possible to effectively do invokespecial on superclass instance.

      For comparison, MethodHandles.Lookup.findSpecial() specification has both of this constraints.
      HotSpot also provides this both constraints (which makes it formally incompatible with spec).

            abuckley Alex Buckley
            kfertikov Kirill Fertikov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: