Here is the code given below. My question is that will it compile with assertions enabled.In my view it should not since statement //1 will be unreachable if asssertions are enabled. I tried to compile with assertions enabled and it compiled fine. But i am not able to undestand why.
[ August 03, 2005: Message edited by: Barry Gaunt ]
Having Assertions enabled or disabled should never effect a program such that one line of code runs where another wouldn't based on it being enabled or not.
The compiler will not take those lines into account in determining if a line will run or not.
When an AssertionError occurs the application will stop, not continue on anyway, just like as if you issued a System.exit(0);
So you believe this should not compile with assertions enabled. Not an unreasonable assumption but that's never the case. Compile time expression values can only produce unreachable code in while, for and do statements. That way you can say if(SKIP_FLAG) ... and not have it compile in one state and not in the other. Not particularly orthogonal but useful nevertheless.
The rationale is that you can have a constant
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.