Why does OpenJDK put private methods in a vtable?

OpenJDK 8 seems to host private methods that are not final and static in the vtable. Why is this so when dynamic binding is not used for private methods (since they are invoked using invokespecial ) or is it used?

+7
java jvm bytecode openjdk
source share
1 answer

This is done to handle some rare situations when there is an overridable method in the superclass with the same name and signature. While there is definitely a place for improvement, it is probably intended for JDK 9.

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

Private methods always get a vtable entry for handling backwards compatibility with classes - i.e. you can have the same name a private method local to your class, as well as an inheriting method from your superclass that will be inherited around your private method by your child.

+4
source share

All Articles