-
Bug
-
Resolution: Fixed
-
P4
-
8
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".
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".