As I understand from reading multiple posts here in SO, Java's compiler implements the operators overloading for objects, so that when it sees a simple expression like Integer i = a + b
(let a
and b
be of type Integer
, too), it compiles it as a call to the Integer.valueOf()
function (as explained here).
I'd like to know how a Java compiler implements this. I mean, does it have a Java C++ [edited according to comments] code underneath that uses a simple operator overloading, so that when seeing a binary +
operator with Integer
it calls the valueOf()
function?
Also, this link appeared in one of the SO answers (sorry, I can't remember where), and I thought maybe the enterBinop
part is related to this issue?