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

5.4.3.5: Clarify that method handle resolution of REF_newInvokeSpecial needs a precise ctor

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 9
    • Component/s: specification
    • Labels:
    • Subcomponent:
      vm

      Description

      Method handle resolution is not specified to check if the resolved constructor is declared by the referenced class.
      HotSpot throws NoSuchMethodError if the constructor is not declared by the referenced class.

      Example:
      public class InheritedInitTest version 52:0 {
          // no <init> in this class
          public static Method main:"([Ljava/lang/String;)V" stack 1 locals 1 {
              // resolved method is Object.<init>:"()V"
              ldc MethodHandle REF_newInvokeSpecial:InheritedInitTest."<init>":"()V"; // throws NoSuchMethodError
              return;
          }
      }

      This is akin to the assertion jvms-6.5.invokespecial.linking-110 in invokespecial spec: "Otherwise, if the resolved method is an instance initialization method, and the class in which it is declared is not the class symbolically referenced by the instruction, a NoSuchMethodError is thrown."

      MethodHandles.Lookup.findConstructor(...) specifies analogous exception: "NoSuchMethodException - if the constructor does not exist".

        Attachments

          Activity

            People

            • Assignee:
              abuckley Alex Buckley
              Reporter:
              slukyanov Stanislav Lukyanov (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: