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

XMLWordPrintable

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

      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".

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

              Created:
              Updated:
              Resolved: