Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Enabling or disabling assertions

 
Ranch Hand
Posts: 173
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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??
 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Ankit...
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic