aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Enabling or disabling assertions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Enabling or disabling assertions" Watch "Enabling or disabling assertions" New topic
Author

Enabling or disabling assertions

Hareendra Reddy
Ranch Hand

Joined: Jan 09, 2011
Posts: 173

Actually i am confused with some of the switches used with java command ....

1) java -ea Myclass
Does it enable assertions for system classes also??

2) java -ea:... MyClass
How it works if the argument is simply "..."

3) Documentation says in their "no-argument form, the switches do not apply to system classes"
What is no argument form??

Thanks in advance...
Sandra Bachan
Ranch Hand

Joined: Feb 18, 2010
Posts: 434
Hareendra Reddy wrote:Actually i am confused with some of the switches used with java command ....

1) java -ea Myclass
Does it enable assertions for system classes also??

2) java -ea:... MyClass
How it works if the argument is simply "..."

3) Documentation says in their "no-argument form, the switches do not apply to system classes"
What is no argument form??

Thanks in advance...



java -ea Myclass

is a no-argument form. This means that it will enable assertions in general, i.e. all system classes, all packages

You can enable and disable assertions on a class-by-class basis
Sierra/Bates wrote:java -ea -da:MyClass TestClass


Here you are enabling assertions for all classes EXCEPT MyClass


As for your second question

java -ea:... MyClass

I don't recall seeing this syntax. If this is part of a code sample, kindly post it here so we can assist.

Marriage Made in Heaven
http://www.youtube.com/user/RohitWaliaWedsSonia
Hareendra Reddy
Ranch Hand

Joined: Jan 09, 2011
Posts: 173

Hello sandra,

Actually in (K&B) page:390 ,it is written that "when used with no arguments it enables or disables in all classes , except for system classes"
but the table at page:391
java -ea -dsa is "Enable assertions in general but disables assertions in system classes"
I am confused with these two and if first statement is correct then second is redundant i believe...


docs of java application launcher says "If the argument is simply "...", the switch enables assertions in the unnamed package in the current working directory."
what is unnamed package here??
Is it the default package which include all the classes which are not in any package??
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9280
    
  17

Hareendra if you read the doc that you linked to, it says
in their no-argument form, the switches do not apply to system. This makes it easy to turn on asserts in all classes except for system classes. A separate switch is provided to enable asserts in all system classes; see -enablesystemassertions below.

As far as unnamed package is concerned, yes it means classes which are in the default package i.e. don't have any package...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Hareendra Reddy
Ranch Hand

Joined: Jan 09, 2011
Posts: 173

Thank you Ankit...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Enabling or disabling assertions
 
Similar Threads
Assertion - what are system classes?
Assertion doubt
Assertion command-line switches
Enable assertions in current package.
Discussing errata for K&B, SCJP 6