I have seen some nice Java compiler hacks wherein you can replace assertions by throw-exception statements, you can have auto-generated properties for fields and so on...
I was just wondering...
Is it possible to hack Java compiler so that it supports Operator Overloading?
EDIT :
It's not that I am missing operator overloading in Java or something. I just want to know whether it is possible to implement it using the hacks mentioned in the links I have given above. So please do not suggest me to switch to some other language like Scala (which I am already learning anyway! :D ).
EDIT :
Please just tell me whether it is possible to do it using JSR 269 or something like that. :|
In response to the edited question, the only way you can implement true operator overloading in Java is to add it to the language. This means that you either have to change the compiler to compile your code or write a preprocessor that converts your code to standard Java. For the former, you can download a nearly complete FOSS java implementation from either GNU or the OpenJDK project. For the latter, you can either write your own parser using things like JavaCC etc. (examples are on this page) or you can use JFront as a base to add your own syntax.