Why does OpenJDK place private methods into vtable?

It seems that 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) or is it used?


This is done to handle some rare situations when an overridable method with the same name and signature exists in a superclass. Though there is definitely a place for improvement, may be, targeted for JDK 9.

See https://bugs.openjdk.java.net/browse/JDK-8024368

Private methods always get a vtable entry to handle backward compatibility with classes - ie 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.

链接地址: http://www.djcxy.com/p/83768.html

上一篇: 热成像调色板

下一篇: 为什么OpenJDK将私有方法放入vtable中?