Hacker News new | ask | show | jobs
by johnc1231 2206 days ago
Can you explain that line? I think I am missing something obvious.
3 comments

It's Danish for "One more for the javanissen", which is explained later to be a little gnome that represents an anthropomorphized version of the JVM who needs an extra byte in addition to the buffer allocation lest it creates segfaults.
It looks like it supposed to be a Scandinavian language, most likely Norwegian or Danish. It could be interpreted as Swedish as well, in which case the correct corresponding Swedish sentence would be "och en till javanissen". A "nisse" is in Swedish something like a gnome, so "javanissen" would be "the Java gnome". The full translation would then be something like "and one for the Java gnome".

I'm not sure if there's any deeper meaning to the joke. I didn't think much of it until I read the subsequent paragraph of the text and figured out what was meant by "og én til javanissen".

Specifically in this case, he is creating a set of constant pool entries in the class, which are indexed from 1..n rather than 0..n-1, so if you have a constant pool that needs to hold 10 items, you have to declare 11 in the count of the constant pool.

One possible reason for this is because most of the constant pool entries work by indexing in to itself recursively (so you can do pool[pool[thing].value]) there’s no way of using a null or missing value.

So when you have java.lang.Object, the super class field contains 0 to indicate that there is no superclass, and if 0 were a valid index into this pool structure then this approach wouldn’t work.

Of course whatever the reason, we have been stuck with this implementational quirk since the first Java release, and it would be a backwards incompatible change if it were different, just like the fact that double and long occupy two slots on the stack - because that was a quick way of allowing 64 bit values on a 32 bit stack, and even though most JVMs now have a 64 bit stack we still “waste” a slot entry each time.

So the toast “one more for the Java gnome” is the extra space you have to allocate for the 0th entry of the constant pool in Java class files.