Sorry, I know what's wrong with my example. here is the right one:
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());
}
}