Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Assertions in Java
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

Report this thread to moderator Post Follow-up to this message
Old Post
tp
09-27-04 02:07 PM


Re: Assertions in Java
On 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.

Report this thread to moderator Post Follow-up to this message
Old Post
Stefan Schulz
09-27-04 02:07 PM


Re: Assertions in Java
tp 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

Report this thread to moderator Post Follow-up to this message
Old Post
Chris Smith
09-27-04 09:02 PM


Re: Assertions in Java
cdsmith@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.

Report this thread to moderator Post Follow-up to this message
Old Post
Richard
09-27-04 09:02 PM


Re: Assertions in Java
On 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


Report this thread to moderator Post Follow-up to this message
Old Post
Lāʻie Techie
09-27-04 09:02 PM


Re: Assertions in Java
laie@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?

Report this thread to moderator Post Follow-up to this message
Old Post
Richard
09-29-04 10:00 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java Help archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:33 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.