Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / September 2004

Tip: Looking for answers? Try searching our database.

Assertions in Java

Thread view: 
tp - 27 Sep 2004 11:26 GMT
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
Stefan Schulz - 27 Sep 2004 11:58 GMT
> Hi there
>
[quoted text clipped - 16 lines]
> 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?"

Signature

Whom the gods wish to destroy they first call promising.

Chris Smith - 27 Sep 2004 14:59 GMT
> 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.

Signature

www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation

Richard - 27 Sep 2004 17:34 GMT
cdsmith@twu.net 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.  

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.
Lāʻie Techie - 27 Sep 2004 20:16 GMT
> 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/guide/lang/assert.html

HTH,
La'ie Techie


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.