News for hackers. Stuff that matters.
Re:Impossible Java by tokenizerrr on Tuesday March 28, 2017 @11:11AM (#13977211)
For that specific example that would actually be fine in Java. Everything is an Object, so even if you have foo(Object) you can just pass it a String and that is then fine both for the JVM and the Java compiler.

Since the JVM identifies methods by their name + argument types this would most likely break overloading unless done very carefully. I've decompiled quite a few Java applications and haven't seen anything like this either, but perhaps I've just had the luck to not yet run into it.

Re:Impossible Java by MichaelGG on Tuesday March 28, 2017 @01:12PM (#13978443)
It wouldn't be fine. It'd call the wrong method. The bytecode invokes the foo(object) one, but a naive decompiling would invoke foo(string). A cast would be required to get it to resolve correctly. Or am I misunderstanding?
Re:Impossible Java by tokenizerrr on Tuesday March 28, 2017 @02:43PM (#13979413)
I'm talking about decompiled code, which would turn out looking something like http://ideone.com/HCOLU4 which compiles and runs just fine. Maybe I am misunderstanding what you mean?