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

Read more

Summary

Criticisms of operator overloading

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)

Modularity
Assignment operator e1 : T 1
Netbeans IDE
IntelliJ IDEA IDE
Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call