File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

assertions...

 
Raju Champaklal
Ranch Hand
Posts: 521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can we set assertions programmatically? whizlabs says we can....want to know how?
 
Venu Chakravorty
Ranch Hand
Posts: 46
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes we can:



compile as: $ javac A.java
run as: $ java -ea A
the 'ea' stands for: enable assertions.
if you omit the '-ea' part then 'assert(i >= 5)' will have no effect.
 
Swagato Bhatta
Ranch Hand
Posts: 72
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
venu chakravorty wrote:Yes we can:



compile as: $ javac A.java
run as: $ java -ea A
the 'ea' stands for: enable assertions.
if you omit the '-ea' part then 'assert(i >= 5)' will have no effect.


However, we still have to enable (-ea) during running for the assertion to have any effect! So, I am not still sure how programmatically you can enable the assertion (if that was the question). But definitely, assertions are disabled at runtime by default
 
Raju Champaklal
Ranch Hand
Posts: 521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i was talking about enabling within the program and not using the command line....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic