• Bug
  • Status: Open
  • 2 Major
  • Resolution:
  • ehcache-core
  • cdennis
  • Reporter: cdennis
  • February 09, 2010
  • 0
  • Watchers: 1
  • February 10, 2010

Description

Various classes in ehcache-core (and probably in other ehcache modules) provide public implementations of Object.clone(). The clone method is considered bad for numerous reasons (http://www.artima.com/intv/bloch13.html). In particular in Ehcache it prevents numerous final instance variables from being declared final which makes code harder to read and understand. I’m recommending immediately deprecating the clone implementations, and replacing them with copy constructors where relevant.

Comments

Fiona OShea 2010-02-10

What do you want to do with this?

Chris Dennis 2010-02-10

In the short term I guess we can deprecate the clone methods and discourage their use. Long term I would like to make sure that any new Ehcache API classes do not have clone implementations, and instead have copy constructors if copying even makes sense for the types.