2 ms·
A) It depends on the JVM and B) on HotSpot at least, I believe that it is smart enough to figure out that all virtual methods are of the same type and optimize
by kasey_junk 14y ago
A) It depends on the JVM and B) on HotSpot at least, I believe that it is smart enough to figure out that all virtual methods are of the same type and optimize them as if they were non virtual.
- fmstephe 14y agoI can confirm that HotSpot is very aggressive at collapsing type hierachies and de-virtualising method calls. http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.117.2420&rep=rep1&type=pdf http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.117... This is one of the places where Java can outperform C++. Where c++ is unable to statically devirtualise method calls and HotSpot will just do it.