Work

Operator overloading for Java

Year: 2011
Type: dissertation
Abstract: Introduction \nThis thesis analyzes the possibilities to extend the Java programming language. This is done by implementing operator overloading as an example of what is possible. An important goal of this implementation is to be easy to use for the developer. That means among other things that it should not require a special compiler or extra steps in the build process and it should work on a standard Java Runtime Environment (JRE). \nApproach \nThere are several possibilities to extend the Java syntax. The obvious ones are: \n1. Patch the compiler \n2. Preprocess the source code \n3. Develop a compiler with the desired features \nThe problem with patching the compiler or developing a new one is that it would require the developer to use a different compiler and thus requires extra effort from him. \nPreprocessing the code complicates the build process by introducing an additional step. \nIn this thesis the approach is using a Java 6 pluggable annotation processor to modify the Abstract Syntax Tree (AST) before the bytecode is generated. Annotations and annotation processors where introduced in Java 5, as tools like XDoclet showed the need for metadata in the code especially when developing Java EE applications. Annotation \nprocessors are used to generate source code or configuration files out of meta data (annotations) in the code. \nAnnotation processing in Java 5 was not integrated into the compiler, it required separate tools and an extra steps in the build process. With Java 6 and the introduction of pluggable annotation processors it became part of the compiling process. So an annotation processor can be registered via the Service Provider Interface (SPI) of Java and is then used by the compiler. \nThe transformation can be done by casting the objects passed to the annotation processor to their underlying classes and then modifying the AST. To stay independent of different compiler's AST implementations an abstraction layer is used. \nResults \nOperator overloading has been implemented and works with Eclipse, Netbeans and plain Javac. Also builds which use Ant or Maven both using Javac are working. The implementation is compiler independent and extendable. However it is not ready for productive use yet, because it still has some bugs. To extend it, a new transformations can be registrated with the SPI of Java.
Language: English
Subfield: Software
Open Access status: green
OpenAlex ID: W605834970
Cites: 1
Cited by:
Related to: 10