Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Enabling or disabling assertions

 
Hareendra Reddy
Ranch Hand
Posts: 173
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Hareendra Reddy
Ranch Hand
Posts: 173
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9529
33
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Hareendra Reddy
Ranch Hand
Posts: 173
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Ankit...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic