Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

still the lookup is based on the symbol, no? so the JVM does not resolve overload even in that case, i believe


Read what I said again.

Step 1 is a lookup by symbol. You're ignoring the vast majority of the logic.

There are hints about what I'm talking about in this conversation about invokespecial: https://stackoverflow.com/questions/13764238/why-invokespeci...

This trickiness is not called out in the bytecode specification, but in the JVM spec. They get a little closer to the mark here:

https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-6.ht...

"Is Java Statically Typed or Dynamically Typed?" is basically an interview gotcha question. Most people should answer the former, but if you are hiring people to create a JVM or a language that translates to the JVM, you're looking for a much longer answer that circles around gradations of the latter, because the compiler is strongly typed but the JVM has weaker type guarantees that are sorted out at first invocation, and which look like variance (predating most literature on contra and covariance, I might add). Prior to invokedynamic people used this and other facts to trick the JVM into doing things that are illegal in Java. The Hotspot people learned a whole lot about how the JVM actually functions from interactions with these sorts of people.


i now get what you mean, thanks


If I wasn't already clear, this isn't something that normal devs should have or want to think about.

But it's hard to avoid if you end up dealing with separate compilation units that are run on a different build schedule. Sooner or later your refactoring will either blow up with an obscure error, or work even though if you really think about it, the compiler would say it shouldn't. And of course if you actually dig you'll find it out as well.

If you want sophisticated dispatch you want to use invokedynamic, but that was an RFE when I was learning about this stuff.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: