[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] Patch: FYI: Kernel.clone() fixlet

From: Tom Tromey
Subject: [cp-patches] Patch: FYI: Kernel.clone() fixlet
Date: 06 Aug 2004 17:37:57 -0600
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

I'm checking this in.

I found this by chance while looking at a Mauve compilation problem.
It is usually a mistake to use `new' in an implementation of clone(),
the reason being that this will return the wrong result for a

This changes behavior slightly, in that the old code made a copy of
the float[], and the new code does not.  I think the new version is
just as correct, however, since the array is not ever modified, and it
is private so no subclass could modify it.

For this class, this is a lot of ado about nothing.  I doubt there is
a subclass of Kernel anywhere.


Index: ChangeLog
from  Tom Tromey  <address@hidden>

        * java/awt/image/ (clone): Use super.clone().

Index: java/awt/image/
RCS file: /cvsroot/classpath/classpath/java/awt/image/,v
retrieving revision 1.1
diff -u -r1.1
--- java/awt/image/ 22 Jul 2004 19:45:38 -0000 1.1
+++ java/awt/image/ 6 Aug 2004 23:48:17 -0000
@@ -131,6 +131,13 @@
   public Object clone()
-    return new Kernel(width, height, data);
+    try
+      {
+       return super.clone();
+      }
+    catch (CloneNotSupportedException e)
+      {
+        throw (Error) new InternalError().initCause(e); // Impossible
+      }

reply via email to

[Prev in Thread] Current Thread [Next in Thread]