From following sources:
https://www.amazon.com/Java-Complete-Reference-Herbert-Schildt/dp/0071808558
Chapter 8 : Using final with Inheritance
http://javarevisited.blogspot.com.by/2012/03/what-is-static-and-dynamic-binding-in.html
Static Vs. Dynamic Binding in Java
for private,static,final methods early(static) method binding should be used
. So I've created a little test
class MethodRefDemo2
{
public static void main( String args[] )
{
BindingTest bindingTest = new BindingTest();
bindingTest.printEarly();
bindingTest.printLate();
}
}
class BindingTest
{
private String early = "static";
private String late = "dynamic";
final String printEarly()
{
return early;
}
String printLate()
{
return late;
}
}
So as I think, these two methods should have different binding types. Checking byte code:
public static main([Ljava/lang/String;)V
L0
LINENUMBER 8 L0
NEW spring/BindingTest
DUP
INVOKESPECIAL spring/BindingTest.<init> ()V
ASTORE 1
L1
LINENUMBER 9 L1
ALOAD 1
INVOKEVIRTUAL spring/BindingTest.printEarly ()Ljava/lang/String;
POP
L2
LINENUMBER 10 L2
ALOAD 1
INVOKEVIRTUAL spring/BindingTest.printLate ()Ljava/lang/String;
POP
L3
LINENUMBER 11 L3
RETURN
L4
LOCALVARIABLE args [Ljava/lang/String; L0 L4 0
LOCALVARIABLE bindingTest Lspring/BindingTest; L1 L4 1
MAXSTACK = 2
MAXLOCALS = 2
Here i see two INVOKEVIRTUAL instructions. So is there any way to determine what kind of binding was used by the class byte code? And if no, how can i determine binding type?