• 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

Question on enable system assertions

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When do we need to have system assertions enabled? Can someone give me an example in which the system assertion is enabled?
 
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you have assertions in your source code, you must compile like this:
javac -source 1.4 MyClass.java
or your assert statements will cause compilation errors.

To enable these assertions, you must also execute like this:
java -ea MyClass
Otherwise, the compiled assertions will not do anything at execution time.
 
Richard Vagner
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Mike,

Actually, I am asking about "system assertions", which can be enabled by
java -esa

I want to know why we need it and an example will be great.
 
Mike Gershman
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From an SCJP perspective, you just need to know that -esa is entirely independent of -ea and -dsa is equally independent of -da and that these options control assertions in system classes. Full stop.

What are the "system classes" controlled by -esa? Classes not loaded by a classloader. I think that these are classes integral to the jvm itself.

Are there actually any assertions in these classes as part of j2sdk1.4? Not in any documentation or source libraries that I searched.

When would you use -esa? When software support asks you to, probably after adding some debugging code to trap a specific problem.

If you want more information contact Sun, if you have the contacts, or grab a developer at a Sun presentation.
 
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 that in Java 1.5, no special flags are needed to compile with assertions.
 
Yes, my master! Here is the tiny ad you asked for:
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