Hacker News new | ask | show | jobs
by haxen 2141 days ago
> you are actually going to allocate both the parent and child.

You're going to allocate a single memory block that contains all the state of that object, which of course includes the superclass state. But that has nothing to do with the depth of the class hiererarchy.

> you're gonna be allocating functions everywhere as well.

If by "function" you mean a "Java method", they are code and not data, and they are not allocated dynamically at all.

In any case, this would have nothing to do with them being private or final. These options decide whether there will be an invokevirtual or invokespecial instruction to call them, where invokevirtual has more cost only before getting JIT-optimized.