Why does OpenJDK place private methods into vtable?

﹥>﹥吖頭↗ 提交于 2019-12-08 17:32:04

问题


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?


回答1:


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 - 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.



来源:https://stackoverflow.com/questions/28528192/why-does-openjdk-place-private-methods-into-vtable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!