Closed Brad0309 closed 7 months ago
@theresa-m Please take a look at this
Thanks for the issue. I see in the spec from the notes on invokespecial:
The invokespecial instruction handles invocation of a nonabstract interface method, referenced either via a direct superinterface or via a superclass. In these cases, the rules for selection are essentially the same as those for invokeinterface (except that the search starts from a different class).
I am working on finding the cause of the different behavior in OpenJ9 and will create a fix.
Java -version output
Output from
java -version
.Summary of problem
We have encountered an interesting test program that produces inconsistent output values when using two different instructions ("invokespecial" and "invokevirtual") .
The test program consists of the following source code for
Class1
:The corresponding jasm code of
Class1
is as follows:When running this test program on both OpenJ9 and HotSpot Java virtual machines, the output is
1
. However, if we change the instruction from "invokevirtual" to "invokespecial", the output value differs between OpenJ9 and HotSpot. Specifically, HotSpot produces an output of1
, while OpenJ9 produces an output of2
.We have investigated the JVM spec to understand why this discrepancy occurs. According to the specification(https://docs.oracle.com/javase/specs/jvms/se11/jvms11.pdf) on page 509, the description of the
invokespecial
instruction is defined as follows: "The run-time constant pool entry at the index must be a symbolic reference to a method or an interface method. It provides the name and descriptor of the method or interface method, as well as a symbolic reference to the class or interface where the method or interface method is located."Based on the specification, it seems that the behavior of
invokespecial
should be consistent withinvokevirtual
. However, further investigation and analysis are required to determine the root cause of this discrepancy. Please check this!Test program: ValueError.zip