|
|
|
|
|
by nebulous1
3376 days ago
|
|
tl;dr Java needs to be able to decide which overloaded method implementation to use at compile time, meaning you can't differentiate between method implementations based on return type alone. However, when compiled to bytecode, each method and method call includes the return type as part of the method identification, so Java bytecode is actually capable of differentiating between implementations with the same name based on return type alone. This fact is used by bytecode obfuscators, and can lead to bugs in decompiled code if the decompiler doesn't account for it. |
|
That's not correct. Rust has no issue statically dispatching based on the return type.
Java-the-language does not allow it so it does not have to deal with calls which don't use the return value e.g.
If the return value is not used, you have to explicitly disambiguate this call somehow, and Java provides no way to do so.