The University of Southampton
University of Southampton Institutional Repository

Generating correct and efficient equality and hashing methods using JEqualityGen

Generating correct and efficient equality and hashing methods using JEqualityGen
Generating correct and efficient equality and hashing methods using JEqualityGen
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 implementations 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 improvement of 162x 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.
Grech, Neville
b8afe72a-04a8-48cf-8193-cf1d9b5edfa5
Rathke, Julian
dba0b571-545c-4c31-9aec-5f70c231774b
Fischer, Bernd
0c9575e6-d099-47f1-b3a2-2dbc93c53d18
Grech, Neville
b8afe72a-04a8-48cf-8193-cf1d9b5edfa5
Rathke, Julian
dba0b571-545c-4c31-9aec-5f70c231774b
Fischer, Bernd
0c9575e6-d099-47f1-b3a2-2dbc93c53d18

Grech, Neville, Rathke, Julian and Fischer, Bernd (2010) Generating correct and efficient equality and hashing methods using JEqualityGen. Workshop on Generative Technologies, Paphos, Cyprus.

Record type: Conference or Workshop Item (Paper)

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 implementations 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 improvement of 162x 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.

Text
wgt.pdf - Other
Download (210kB)

More information

Published date: 27 March 2010
Additional Information: Event Dates: 27th March 2010
Venue - Dates: Workshop on Generative Technologies, Paphos, Cyprus, 2010-03-27
Organisations: Electronic & Software Systems

Identifiers

Local EPrints ID: 268754
URI: http://eprints.soton.ac.uk/id/eprint/268754
PURE UUID: 469055de-a287-4e15-b40f-ddf252a56419

Catalogue record

Date deposited: 18 Mar 2010 10:27
Last modified: 14 Mar 2024 09:14

Export record

Contributors

Author: Neville Grech
Author: Julian Rathke
Author: Bernd Fischer

Download statistics

Downloads from ePrints over the past year. Other digital versions may also be available to download e.g. from the publisher's website.

View more statistics

Atom RSS 1.0 RSS 2.0

Contact ePrints Soton: eprints@soton.ac.uk

ePrints Soton supports OAI 2.0 with a base URL of http://eprints.soton.ac.uk/cgi/oai2

This repository has been built using EPrints software, developed at the University of Southampton, but available to everyone to use.

We use cookies to ensure that we give you the best experience on our website. If you continue without changing your settings, we will assume that you are happy to receive cookies on the University of Southampton website.

×