Code Comments
Programming Forum and web based access to our favorite programming groups.Hi there
I need to write a program that looks approximately like this:
main() {
objects;
m();
}
m() {
check an assertion about all objects
}
I need some help with this. Is there a way to list all the objects
used in your program (modifying the objects are allowed).
Any ideas?
Thanx
Thinus
Post Follow-up to this messageOn 27 Sep 2004 03:26:12 -0700, tp <thinusp@gmail.com> wrote:
> Hi there
>
> I need to write a program that looks approximately like this:
>
> main() {
>
> objects;
>
> m();
>
> }
>
> m() {
>
> check an assertion about all objects
>
> }
>
> I need some help with this. Is there a way to list all the objects
> used in your program (modifying the objects are allowed).
While it is possible to list all the _fields_ in your class, you would not
want to do this. I am pretty certain this (homework?) task is meant another
way. Especially since you seem to be entirely in your main method...
But it is really hard to say, since you did not provide much information.
You
basically say "I need to do something with some objects. How do i do it?"
--
Whom the gods wish to destroy they first call promising.
Post Follow-up to this messagetp wrote: > I need some help with this. Is there a way to list all the objects > used in your program (modifying the objects are allowed). This has nothing at all to do with assertions, then. The answer is that there is no "normal" way to list all objects in a Java program. You almost certainly wouldn't care about most of them anyway, since they'd be used internally by the JVM and not related to your application. You should instead keep track of just those objects that you do care about, for example by keeping a list of WeakReference instances that you update from the object's constructor. It would be possible to use JVMTI (or one of its predecessors, JVMDI or JVMPI) to list all the objects in the VM, but this is generally a poor idea from real code; that API is meant for use by debuggers, profilers, and other such tools. -- www.designacourse.com The Easiest Way to Train Anyone... Anywhere. Chris Smith - Lead Software Developer/Technical Trainer MindIQ Corporation
Post Follow-up to this messagecdsmith@twu.net wrote... > tp wrote: > > This has nothing at all to do with assertions, then. Pity, too. As a C programmer with some OOP background, picking up Java, assertions in Java has been on my list of things to find out about once I get other, more fundamental things, under my belt.
Post Follow-up to this messageOn Mon, 27 Sep 2004 16:34:18 +0000, Richard wrote: > Pity, too. As a C programmer with some OOP background, picking up Java, > assertions in Java has been on my list of things to find out about once I > get other, more fundamental things, under my belt. http://java.sun.com/j2se/1.4.2/docs...ang/assert.html HTH, La'ie Techie
Post Follow-up to this messagelaie@win_remove_get_nospam_solutions.com wrote... > On Mon, 27 Sep 2004 16:34:18 +0000, Richard wrote: > > > http://java.sun.com/j2se/1.4.2/docs...ang/assert.html > > HTH, > La'ie Techie Oui. Merci beacoup. -- So, when are we liberating North Korea?
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.