[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A java DEBUG flag
From: |
Cedric Berger |
Subject: |
Re: A java DEBUG flag |
Date: |
Fri, 29 Dec 2000 10:31:06 -0800 |
"Boehm, Hans" wrote:
>
> > This is in the SUN Assertion JSR.
> > http://java.sun.com/aboutJava/communityprocess/jsr/asrt_prop.html
> >
> > ... The documentation is public but we certainly can not
> > participate in its
> > development because of SUNs *stupid* IP restrictions in the
> > JCP. There are good
> > ideas here though and since this stuff will eventually make
> > it into JDK 1.4 I
> > would say it should eventually belong here.
> >
> True. But isn't this an awfully weak proposal? It doesn't seem to allow me
> to cleanly compute additional state that's used only in assertion checking.
> I find that I need to do that all the time in order to be able to write
> reasonable assertions. For example, I might explicitly keep track of who
> holds a particular lock, so that I can assert that I hold it at some point.
> Or I might need to count opened files so that I can assert that I closed
> everything I opened in a certain section of code. Or ...
>
> Hans
Can't you put all this stuff a special debug class to keep things clean?
This class will only gets loaded if assertions are enabled!
class Debugging {
static int openFilesCount;
static boolean openFile() {
return openFilesCount < LIMIT;
}
static boolean closeFile() {
return openFilesCount > 0;
}
}
class Main {
void doSomething() {
assert(Debugging.openFile());
// do something
assert(Debugging.closeFile());
}
}
Cedric
- Re: A java DEBUG flag, (continued)
Re: A java DEBUG flag, Kevin A. Burton, 2000/11/24
RE: A java DEBUG flag, Boehm, Hans, 2000/11/29
- Re: A java DEBUG flag,
Cedric Berger <=
RE: A java DEBUG flag, Boehm, Hans, 2000/11/29
Re: A java DEBUG flag, Brian Jones, 2000/11/29
Re: A java DEBUG flag, Nic Ferrier, 2000/11/29
Re: A java DEBUG flag, Patrick Tullmann, 2000/11/29
Re: A java DEBUG flag, Nic Ferrier, 2000/11/30