Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@apache.org Received: (qmail 88355 invoked from network); 12 Aug 2002 17:32:49 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 12 Aug 2002 17:32:49 -0000 Received: (qmail 25634 invoked by uid 97); 12 Aug 2002 17:33:14 -0000 Delivered-To: qmlist-jakarta-archive-ant-dev@jakarta.apache.org Received: (qmail 25587 invoked by uid 97); 12 Aug 2002 17:33:13 -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 25575 invoked by uid 98); 12 Aug 2002 17:33:13 -0000 X-Antivirus: nagoya (v4198 created Apr 24 2002) Subject: Implementing the Clonable interface in a task To: "Ant Developers List" X-Mailer: Lotus Notes Release 5.0.3 March 21, 2000 Message-ID: From: jlcarpenter@household.com Date: Mon, 12 Aug 2002 10:32:52 -0700 X-MIMETrack: Serialize by Router on PHILNOTESG1/SRV/Household(Release 5.0.10 |March 22, 2002) at 08/12/2002 12:32:41 PM MIME-Version: 1.0 Content-type: text/plain; charset=us-ascii X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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 } Printing to System.err doesn't seem to be the right thing. Should I throw a BuildException? I have been away from java for a year or so. Can anyone remind me why the clone method's return type is object instead of the type of object being cloned? Isn't it a bit sloppy to require casting the cloned object? 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. James Lee Carpenter Software Engineer Household Technical Services 6602 Convoy Court San Diego, CA 92111 ph: 858-609-2461 email: jlcarpenter@household.com -- To unsubscribe, e-mail: For additional commands, e-mail: