I need to know how many objects of some type exist in my system any time. Standard method with static variable and and increment/decrement in constructor/distructor doesn't work because missed Object.finalize method.
In standard Java, you could use a WeakReference
but that's not available in J2ME. Also, there is no standard API to enumerate all objects. The "easiest" way to do that in Java would be to write a garbage collector.
So your only choices are to run the code in a Java IDE which can do profiling at runtime or handle the destruction of your objects manually, so you can count them.
If you need it at runtime and want to process it programmatically as part of your app it's quite hard - otherwise you could create heapdumps and analyse them. then you'll know how many instances of which objects are currently used (i.e. on the heap)
As a brutforce answer you can produce all your objects with special singleton factory, where you can increment count, when new object is produced, and delete them through this factory to:
Object newOne = ObjectsFactory.getInstance().getNewObject(); // in this method count++
...
...
// we don`t need newOne anyMore
ObjectsFactory.getInstance().releaseObject(newOne); // here count--
newOne = null; // let gc do its work.
This approach do not give you exactly results, but something roundly.
You can't use any of this reflection stuff because it isn't support by J2me.
The only bet would be to enable the profiler under the WTK/bin/prefs. there is also a memory monitor in there.