• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

doubt in assertions

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai all

source code---->assert false;

The above code should throw assertion error according to my understanding
but i did not get any assertion error at runtime.

I am using java 1.5 version and tool i am using is jdeveloper..
could you tell me what is the reason??

Thanks in advance..
 
Ranch Hand
Posts: 513
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You probably did not run your program with assertions enabled. To do that, specify either -ea or -enableassertions as a command-line switch. Assertions are disabled by default.
 
anveshana bandu
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai kelvin

I have seen a statement saying::

I we are using jdk 1.4 compiler the assertions are disabled by default..
But when we are using jdk 1.5 the assertions are enabled by default.
If that was the case no need to enable assertions ...

Is that statement right??
or still what ever compiler we are using we should enable assertions??
Let me know

Thanks in advance
 
Kelvin Chenhao Lim
Ranch Hand
Posts: 513
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're confusing the behavior of the Java compiler (javac) with that of the Java runtime launcher (java). In both 1.4 and 1.5, the runtime launcher will disable assertions by default. However, the 1.4 compiler does not support assertions by default, whereas the 1.5 compiler does.
[ November 30, 2007: Message edited by: Kelvin Lim ]
 
Politics is a circus designed to distract you from what is really going on. So is this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic