Operator overloading for Java

Brändli, Sandro (2011) Operator overloading for Java. Bachelor thesis, HSR Hochschule für Technik Rapperswil.

[img]
Preview
PDF
Thesis.pdf - Supplemental Material

Download (784kB) | Preview
  • PDF
    hapviewer_2_0.pdf - Supplemental Material

Abstract

Introduction This 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). Approach There are several possibilities to extend the Java syntax. The obvious ones are: 1. Patch the compiler 2. Preprocess the source code 3. Develop a compiler with the desired features The 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. Preprocessing the code complicates the build process by introducing an additional step. In 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 processors are used to generate source code or configuration files out of meta data (annotations) in the code. Annotation 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. The 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. Results Operator 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.

Item Type: Thesis (Bachelor)
Subjects: Technologies > Programming Languages > Java
Metatags > ITA (Institute for Internet Technologies and Applications)
Divisions: Bachelor of Science FHO in Informatik > Bachelor Thesis
Creators:
CreatorsEmail
Brändli, SandroUNSPECIFIED
Contributors:
ContributionNameEmail
Thesis advisorJoller, JosephUNSPECIFIED
Depositing User: HSR Deposit User
Date Deposited: 24 Jul 2012 07:57
Last Modified: 24 Jul 2012 09:35
URI: http://eprints.hsr.ch/id/eprint/146

Actions (login required)

View Item View Item