From 174d0ac3adca170cbe3a7a103942088b27b0300a Mon Sep 17 00:00:00 2001 From: Ray Greenwell Date: Sat, 28 Aug 2004 01:23:31 +0000 Subject: [PATCH] It turns out that a cloned Object does not call any instance initializers, which makes sense when you think about it, so we now increment the instance when an object is cloned or created. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3107 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- src/java/com/threerings/util/TrackedObject.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/java/com/threerings/util/TrackedObject.java b/src/java/com/threerings/util/TrackedObject.java index a96e5f205..b7c19cdb7 100644 --- a/src/java/com/threerings/util/TrackedObject.java +++ b/src/java/com/threerings/util/TrackedObject.java @@ -1,5 +1,5 @@ // -// $Id: TrackedObject.java,v 1.5 2004/08/27 02:20:36 mdb Exp $ +// $Id: TrackedObject.java,v 1.6 2004/08/28 01:23:31 ray Exp $ // // Narya library - tools for developing networked games // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved @@ -38,7 +38,22 @@ import com.samskivert.util.Tuple; */ public class TrackedObject { + // instance initializer - called whenever an instance is constructed + { + incrementInstanceCount(); + } + + // documentation inherited + protected Object clone () + throws CloneNotSupportedException + { + Object o = super.clone(); + incrementInstanceCount(); + return o; + } + /** Records that this object came into existence. */ + protected final void incrementInstanceCount () { Class clazz = getClass(); synchronized (_map) {