Home > Archive > Java Help > September 2004 > Assertions in Java
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| 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
| |
| Stefan Schulz 2004-09-27, 9:07 am |
| 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.
| |
| Chris Smith 2004-09-27, 4:02 pm |
| 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
| |
| Richard 2004-09-27, 4:02 pm |
| 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.
| |
| Lāʻie Techie 2004-09-27, 4:02 pm |
| 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
| |
| Richard 2004-09-29, 5:00 am |
| 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?
|
|
|
|
|