为什么OpenJDK将私有方法放入vtable? [英] Why does OpenJDK place private methods into vtable?

查看:79
本文介绍了为什么OpenJDK将私有方法放入vtable?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎 openJDK 8 将既不是final也不是static的私有方法放入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?

推荐答案

当超类中存在具有相同名称和签名的可重写方法时,此方法可以处理一些罕见的情况.尽管肯定有改进的地方,但可能针对JDK 9.

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.

请参见 https://bugs.openjdk.java.net/browse/JDK-8024368

私有方法总是获得一个vtable条目来向后处理 与类的兼容性-即您可以使用相同的名称 类本地的私有方法,还继承了from的方法 您的超类,将围绕私有方法继承, 由你的孩子.

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将私有方法放入vtable?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆