为什么 OpenJDK 将私有方法放入 vtable 中?
Why does OpenJDK place private methods into vtable?
好像是openJDK 8 places private methods which are not final
nor static
into vtable. Why is it so when dynamic binding is not used for private methods (since they're invoked with invokespecial)还是用的?
这样做是为了处理一些罕见的情况,即超类中存在具有相同名称和签名的可覆盖方法。虽然肯定有改进的地方,但可能是针对JDK 9.
见https://bugs.openjdk.java.net/browse/JDK-8024368
Private methods always get a vtable entry to handle backward
compatibility with classes - i.e. you can have the same name of a
private method local to your class and also inherit a method of from
your superclass, which will get inherited around the private method,
by your child.
好像是openJDK 8 places private methods which are not final
nor static
into vtable. Why is it so when dynamic binding is not used for private methods (since they're invoked with invokespecial)还是用的?
这样做是为了处理一些罕见的情况,即超类中存在具有相同名称和签名的可覆盖方法。虽然肯定有改进的地方,但可能是针对JDK 9.
见https://bugs.openjdk.java.net/browse/JDK-8024368
Private methods always get a vtable entry to handle backward compatibility with classes - i.e. you can have the same name of a private method local to your class and also inherit a method of from your superclass, which will get inherited around the private method, by your child.