Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

assertion

 
anushree ari
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to enable or disable the assertion form the source code itself?
explain me,
thx
 
Dan Chisholm
Ranch Hand
Posts: 1865
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can disable the program if assertions are not enabled using something like the following.

If assertions are not enabled the assertsEnabled boolean remains false and the RuntimeException is thrown.
 
Manish Hatwalne
Ranch Hand
Posts: 2591
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assertions can be enabled or disabled programmatically, have a look at ClassLoader class documentation.
HTH,
- Manish
 
Albert Lee
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can use // or /* */ to disable assersion statement.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic