3 ms·
Isn't there a decent amount of overhead in declaring and extending an abstract class? Does the cache grouping outweigh the overhead?
by RyanZAG 13y ago
Isn't there a decent amount of overhead in declaring and extending an abstract class? Does the cache grouping outweigh the overhead?
- kasey_junk 13y agoA) 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 13y 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.