Get a class instances

M

Mohand

Hi
Can somebody help me?
I want to find all instances of a java class. The class is created and
several instances also are created. What I want to do is to retrieve all
these created instances.

Thanks all.

Mohand




---
Antivirus avast! : message Sortant sain.
Base de donnees virale (VPS) : 0605-1, 2006-01-30
Analyse le : 2006-01-30 19:47:45
avast! - copyright (c) 1988-2005 ALWIL Software.
http://www.avast.com
 
J

John C. Bollinger

Mohand said:
I want to find all instances of a java class. The class is created and
several instances also are created. What I want to do is to retrieve all
these created instances.

You cannot do what you ask unless you track instance creation. One way
to do it is to use a factory object as the only means of creating
instances of the class you're talking about, and keeping a record in the
factory object of the instances created. If you do this then you may
want to employ weak references so that your records of instances do not
prevent the instances from being garbage collected. It starts to get
complicated if you want to do it right.

On the other hand, it is almost always a flawed design that requires the
kind of accounting you describe. Why do you think you want to do what
you ask?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top