• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic