In article <hb0o55-hie.ln1@[EMAIL PROTECTED]
>,
Luc The Perverse <ataylor_no_spa_am@[EMAIL PROTECTED]
> wrote:
> I was wondering if Java has a built in feature that could be easily
> enabled to count unique class instantiations.
I don't know if there's anything built in, but you could always make
everything derive from:
class DebugObject extends Object // NOT checked for syntax!
{
private static int objectCount = 0;
DebugObject ()
{
super();
++objectCount;
}
protected void finalize()
{
objectCount--;
super.finalize();
}
public int objectCount()
{
return (objectCount);
}
}
If you want to simplify switching back & forth, you can also have:
class JavaObject extends Object
{
JavaObject()
{
super();
}
}
Then it's pretty simple to do replace-all in your project. (If you
replace-all to "Object", it can get trickier to go back to DebugObject,
depending on the rest of your project.)
If *ONLY* javac had a preprocessor! ;)
--
Please take off your pants or I won't read your e-mail.
I will not, no matter how "good" the deal, patronise any business which
sends
unsolicited commercial e-mail or that advertises in discussion newsgroups.


|