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

Question on enable system assertions

 
Richard Vagner
Ranch Hand
Posts: 108
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
Mike Gershman
Ranch Hand
Posts: 1272
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Note that in Java 1.5, no special flags are needed to compile with assertions.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic