Workshop on Generative Technologies 2010 Generating correct and efficient equality and hashing methods using JEqualityGen

Gespeichert in:
Bibliographische Detailangaben
Titel: Workshop on Generative Technologies 2010 Generating correct and efficient equality and hashing methods using JEqualityGen
Autoren: Neville Grech, Julian Rathke, Bernd Fischer
Weitere Verfasser: The Pennsylvania State University CiteSeerX Archives
Quelle: http://eprints.soton.ac.uk/268754/1/wgt.pdf.
Bestand: CiteSeerX
Schlagwörter: meta-programming, equality, equals, hashCode, code generation, Java, AOP
Beschreibung: Determining equality of objects in Java requires the implementation of equals and hashCode methods. Such an implementation has to follow a specific object contract, making it a very tedious and error-prone process. Many equality and hashing methods implemented in Java applications violate this contract and are faulty, due to complexity arising from field shadowing, comparisons between different types, object cycles, etc. Equality and hashing implementations are conceptually simple, and can be derived automatically from information obtained statically from the program. However, existing systems that generate equality imple-mentations use reflection and are consequently inefficient. Here we describe JEqualityGen, a source code generator that seamlessly integrates with the build process of typical Java projects: the programmer only needs to indicate for which classes implementations should be generated. JEqualityGen produces correct and efficient code which on a typical large-scale Java application exhibits a typical performance improve-ment of 162 × in the equality operations generated by existing reflective systems. This was made possible through the use of optimised code generation and runtime profiling of these methods.
Publikationsart: text
Dateibeschreibung: application/pdf
Sprache: English
Relation: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.601.9686; http://eprints.soton.ac.uk/268754/1/wgt.pdf
Verfügbarkeit: http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.601.9686
http://eprints.soton.ac.uk/268754/1/wgt.pdf
Rights: Metadata may be used without restrictions as long as the oai identifier remains attached to it.
Dokumentencode: edsbas.FA482EC1
Datenbank: BASE
Beschreibung
Abstract:Determining equality of objects in Java requires the implementation of equals and hashCode methods. Such an implementation has to follow a specific object contract, making it a very tedious and error-prone process. Many equality and hashing methods implemented in Java applications violate this contract and are faulty, due to complexity arising from field shadowing, comparisons between different types, object cycles, etc. Equality and hashing implementations are conceptually simple, and can be derived automatically from information obtained statically from the program. However, existing systems that generate equality imple-mentations use reflection and are consequently inefficient. Here we describe JEqualityGen, a source code generator that seamlessly integrates with the build process of typical Java projects: the programmer only needs to indicate for which classes implementations should be generated. JEqualityGen produces correct and efficient code which on a typical large-scale Java application exhibits a typical performance improve-ment of 162 × in the equality operations generated by existing reflective systems. This was made possible through the use of optimised code generation and runtime profiling of these methods.