Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@apache.org Received: (qmail 4164 invoked from network); 12 Aug 2002 17:53:19 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 12 Aug 2002 17:53:19 -0000 Received: (qmail 16402 invoked by uid 97); 12 Aug 2002 17:53:39 -0000 Delivered-To: qmlist-jakarta-archive-ant-dev@jakarta.apache.org Received: (qmail 16188 invoked by uid 97); 12 Aug 2002 17:53:38 -0000 Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 15935 invoked by uid 98); 12 Aug 2002 17:53:35 -0000 X-Antivirus: nagoya (v4198 created Apr 24 2002) Message-ID: <00bf01c24229$617dc540$1219570f@ranier> From: "Steve Loughran" To: "Ant Developers List" References: Subject: Re: Implementing the Clonable interface in a task Date: Mon, 12 Aug 2002 10:54:57 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-MailScanner: Found to be clean X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N ----- Original Message ----- From: To: "Ant Developers List" Sent: Monday, August 12, 2002 10:32 AM Subject: Implementing the Clonable interface in a task > > If a task (a class extending org.apache.tools.ant.Task) implements the > Clonable interface how should it deal with subclasses whose clone method > throw a CloneNotSupportedException? > > The following code snipt from Thinking in Java page 1032 shows a try catch > block around the call to super.clone(). > > public Object clone() { > Thing4 o = null; > try { > o=(Thing4)super.clone(); > } catch (CloneNotSupportedException e) { > System.err.println("Thing4 can't clone"); > } > //bla bla bla > > } but that breaks the rule of 'throw exceptions up till you know where to really catch them'. What do you return from this method if you cant clone? the original? null? Better to keep throwing and let the stuff upstream handle it. I dont know of any cloning that takes place. > Someone out there may be wondering why I am looking to clone an Ant task. > I am creating two tasks that use the CVS task by composition. This same > approach is taken by the CvsTagDiff task. The two classes I am writting > also have some shared functionality that should be moved off into a utility > class. The complication is that the utility class must have a configured > CVS object to do its job. The simplest way to configure the CVS instance > used by the utility is to simply clone the CVS instance within the client > class and pass it to the utility class's constructor or as an argument to > any static method. How about teasing the CVS configuration into a self contained object? Or pass a non-cloned reference in? -- To unsubscribe, e-mail: For additional commands, e-mail: