Abstract
The paper introduces a modular extension (plugin) for Java language compilers and Integrated Development Environments (IDE) which adds operator overloading feature to Java language while preserving backward compatibility. The extension use the idea of library-based language extensibility similar to SugarJ. But unlike most language extensions, it works directly inside the compiler and does not have any external preprocessors. This gives much faster compilation, better language compatibility and support of native developer tools (IDE, build tools). The extension plugs into javac and Eclipse Java compilers as well as in all tools whose use the compilers such as IDEs (Netbeans, Eclipse, IntelliJ IDEA), build tools (ant, maven, gradle), etc. No compiler, IDE, build tools modification needed. Just add a jar library to classpath and/or install a plugin to your IDE. The paper also discuss on how to build such Java compiler extensions. The extension source code is open on http://amelentev.github.io/java-oo/
Highlights
The paper introduces a modular extension for Java language compilers and Integrated Development Environments (IDE) which adds operator overloading feature to Java language while preserving backward compatibility
Because operator overloading allows the original programmer to change the usual semantics of an operator and to catch any subsequent programmers by surprise, it is usually considered good practice to use operator overloading with care
Instead of modifying compiler stages we extend them by creating subclasses and override specific methods
Summary
Operator overloading has often been criticized because it allows programmers to give operators completely different semantics depending on the types of their operands. Java language historically doesn’t support operator overloading mostly because of this reason. The common reply to this criticism is that the same argument applies to function (method) overloading as well. Even without overloading, a programmer can define a method to do something totally different from what would be expected from its name. Some people say that adding operator overloading to Java language will complicate Java compiler. The paper presents an implementation of Operator Overloading via small compiler plugin. Because operator overloading allows the original programmer to change the usual semantics of an operator and to catch any subsequent programmers by surprise, it is usually considered good practice to use operator overloading with care (the same for method overloading)
Talk to us
Join us for a 30 min session where you can share your feedback and ask us any queries you have
More From: International Journal of Programming Languages and Applications
Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.