From: Gary P. <gpa...@cs...> - 2008-05-19 11:36:04
|
Hi, I was wondering why I added our own Cloneable interface to CIlib (after Edwin asked me about it). I just looked at the javadoc associated with the class and the reasons are actually rather obvious. Currently within Java, java.util.Cloneable is a marker interface with no methods defined within it. In Java, Object is defined to have the clone() method, however, the method is protected and as a result you can only call it from subclasses unless you change the access modifier. The actual problem stems from the manner in which the generics in java work. If the type parameter is not defined to have a particular starting point, the default extended class will be Object, which is perfectly correct from an object point of view. However, the accessor on Object is protected and as a result you cannot invoke the method. That was the reason for the introduction of our own Cloneable interface. Regards, Gary |