The University of Southampton
University of Southampton Institutional Repository

JEqualityGen: Generating Equality and Hashing Methods

JEqualityGen: Generating Equality and Hashing Methods
JEqualityGen: Generating Equality and Hashing Methods
Manually implementing equals (for object comparisons) and hashCode (for object hashing) methods in large software projects is tedious and error-prone. This is due to many special cases, such as field shadowing, comparison between different types, or cyclic object graphs. Here, we present JEqualityGen, a source code generator that automatically derives implementations of these methods. JEqualityGen proceeds in two states: it first uses source code reflection in MetaAspectJ to generate aspects that contain the method implementations, before it uses weaving on the bytecode level to insert these into the target application. JEqualityGen generates not only correct, but efficient source code that on a typical large-scale Java application exhibits a performance improvement of more than two orders of magnitude in the equality operations generated, compared to an existing system based on runtime reflection. JEqualityGen achieves this by generating runtime profiling code that collects data. This enables it to generate optimised method implementations in a second round.
meta-programming, equality, hashing, code generation, Java, Scala, AspectJ, AOP
978-1-4503-0154-1
177-186
Grech, Neville
b8afe72a-04a8-48cf-8193-cf1d9b5edfa5
Fischer, Bernd
0c9575e6-d099-47f1-b3a2-2dbc93c53d18
Rathke, Julian
dba0b571-545c-4c31-9aec-5f70c231774b
Grech, Neville
b8afe72a-04a8-48cf-8193-cf1d9b5edfa5
Fischer, Bernd
0c9575e6-d099-47f1-b3a2-2dbc93c53d18
Rathke, Julian
dba0b571-545c-4c31-9aec-5f70c231774b

Grech, Neville, Fischer, Bernd and Rathke, Julian (2010) JEqualityGen: Generating Equality and Hashing Methods. Generative Programming and Component Engineering,, Eindhoven, The, Netherlands. 10 - 13 Oct 2010. pp. 177-186 .

Record type: Conference or Workshop Item (Other)

Abstract

Manually implementing equals (for object comparisons) and hashCode (for object hashing) methods in large software projects is tedious and error-prone. This is due to many special cases, such as field shadowing, comparison between different types, or cyclic object graphs. Here, we present JEqualityGen, a source code generator that automatically derives implementations of these methods. JEqualityGen proceeds in two states: it first uses source code reflection in MetaAspectJ to generate aspects that contain the method implementations, before it uses weaving on the bytecode level to insert these into the target application. JEqualityGen generates not only correct, but efficient source code that on a typical large-scale Java application exhibits a performance improvement of more than two orders of magnitude in the equality operations generated, compared to an existing system based on runtime reflection. JEqualityGen achieves this by generating runtime profiling code that collects data. This enables it to generate optimised method implementations in a second round.

Text
gpce16-grech.pdf - Version of Record
Download (298kB)

More information

Published date: 10 October 2010
Additional Information: Event Dates: October 10-13, 2010
Venue - Dates: Generative Programming and Component Engineering,, Eindhoven, The, Netherlands, 2010-10-10 - 2010-10-13
Keywords: meta-programming, equality, hashing, code generation, Java, Scala, AspectJ, AOP
Organisations: Electronic & Software Systems

Identifiers

Local EPrints ID: 271893
URI: http://eprints.soton.ac.uk/id/eprint/271893
ISBN: 978-1-4503-0154-1
PURE UUID: a631a6db-7cda-4d08-a774-0f9373630a86

Catalogue record

Date deposited: 11 Jan 2011 13:09
Last modified: 14 Mar 2024 09:42

Export record

Contributors

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

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.

×