• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question on Design FAQ of Assertion

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Note: The source for the above quote is...

http://java.sun.com/j2se/1.5.0/docs/guide/language/assert.html
 
Stephen Suen
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I found the answer. See:

http://java.sun.com/docs/books/jls/third_edition/html/statements.html#14.10
 
reply
    Bookmark Topic Watch Topic
  • New Topic