dev@grizzly.java.net

Purpose of com.sun.grizzly.util.Copyable is not clear ...

From: kedar mhaswade <kedar.mhaswade_at_gmail.com>
Date: Fri, 26 Jun 2009 10:40:50 -0700

In general, I am not clear on the purpose of this Java interface which is
used all over. In all the *usages* of implementations of this interface, the
copyTo method just typecasts the given parameter to an expected type and it
either results in ClassCastException or returns abruptly if the passed
parameter is not of expected type. Thus, the caller *has to* pass the
correct type. For example, TCPSelectorHandler.copyTo does:

        TCPSelectorHandler copyHandler = (TCPSelectorHandler) copy;

and happily proceeds. Now, unless caller passes in an instance of
TCPSelectorHandler (which is what happening all the time), this method will
fail throwing CCE.

Now, my question is, if the above is true, what is the use of this
interface? It serves the purpose of neither a classic copy constructor, nor
is it a cloner (in traditional Java sense of Cloning). In general, it is not
possible to copy a generic class unless you know its internal structure,
because all the implementations are basically resulting in a bunch of
setters.

Am I missing something?

-Kedar