javaehcacheehcache-2

How can I instantiate ehcache.CacheEventListener?


We need to close a connection when an object is evicted (timed out) of a cache. In trying to create a CacheEventListener for ehcache (version 2.10.4) we get:

The inherited method Object.clone() cannot hide the public abstract method in CacheEventListener

Is there a way around this? How can this work?! Is there an alternative?


Solution

  • So the issue is that Object.clone() is protected, and therefore any interface declaring a public clone() would not accept Object.clone() as an implementation.

    As I imagined, either implementing a public clone() yourself or extending the adapter (which implements all of course) would solve that problem.

    The related posting The inherited method Object.clone() cannot hide the public abstract method seems to go deeper and is unsolvable, but since there's no intersection types here, this is just a tiny annoyance.

    It's really true what they say about clone(), don't do it.