aspose file tools*
The moose likes Beginning Java and the fly likes Question on Design FAQ of Assertion Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Question on Design FAQ of Assertion " Watch "Question on Design FAQ of Assertion " New topic
Author

Question on Design FAQ of Assertion

Stephen Suen
Ranch Hand

Joined: Oct 30, 2003
Posts: 34
When I read Design FAQ of Assertion, I found such an entry(the last entry on the bottom of the page):

8. Why does an assert statement that executes before its class is initialized behave as if assertions were enabled in the class?

Few programmers are aware of the fact that a class's constructors and methods can run prior to its initialization. When this happens, it is quite likely that the class's invariants have not yet been established, which can cause serious and subtle bugs. Any assertion that executes in this state is likely to fail, alerting the programmer to the problem. Thus, it is generally helpful to the programmer to execute all assertions encountered while in this state.


I know the fact that a class'e constructors and methods can run before its initialization complete, but I still don't understand what the FAQ says.

Anyone can help me please?

Stephen Suen
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Note: The source for the above quote is...

http://java.sun.com/j2se/1.5.0/docs/guide/language/assert.html


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Stephen Suen
Ranch Hand

Joined: Oct 30, 2003
Posts: 34
Originally posted by marc weber:
Note: The source for the above quote is...

http://java.sun.com/j2se/1.5.0/docs/guide/language/assert.html


Sorry I forgot to post the link, and thank marc weber help me to do it.
Stephen Suen
Ranch Hand

Joined: Oct 30, 2003
Posts: 34
I think I found the answer. See:

http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.10
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on Design FAQ of Assertion