1) Is it possible to track the number of exceptions being thrown by application? Can I write a test that will print me such a number? Uncaught exceptions stops the execution, so its easy, but what about caught exceptions?
AOP (aspect oriented programming) would be good for this. Take a look at AspectJ or the like.
2) How do I write a test that will tell me the number of activities completed in a second? For example, average number exceptions thrown by code in a second, average number of entities saved per second, average number of users logged to the site per second etc. For example, I want to put some load on my webapp and find out how many entities it can save per second under such a load, where the limit etc
A performance profiling tool would be better than a
JUnit test. It will tell you were the most time in your code is spent so you know where to tune.
3) I want to know how many times some line is executed. Can I do it without changing the code?
Some performance tools will tell you this as well.
4) I want to see the value of expression during the execution of the code without changing the code (*)
I agree with the debugger. If you want a more permanent log, change the code. Or maybe use a debugging tool that tracks this info? I don't recall the name of it, but I remember reading about something that keeps track.
5) I want to stop the execution of my application not in the breakpoint, but only if some expression or variable is equal to some value (for example, stop app if this variable is null). Without changing the code, of course.
Watch expressions do this in your debugger.
It feels like there is a bigger question here. Like how to debug production code. Because that's the only reason I can think of why changing code would not be allowed.