• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

assertions

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello
What is the difference between:
java -da com.blah.MyClass
and
java -da:com.blah.MyClass

Why is the first one considered to be with no arguments? (from K&B p378)
Thanks
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Syntax for assertions is:

java (-da|-ea)(:class to enable or disable assertions) [class to run]

(items in the '()' are optional).

The first one:
java -da com.blah.MyClass is the same as running java com.blah.MyClass.

Assertions are disabled by default, so the -da by itself is superfluous.

The second one:

java -da:com.blah.MyClass

would not work at all because you need to tell it which class to run if you use the -da: syntax. All -da:<class_name> does is to disable assertions for <class_name>. You still need to tell it which class to run.

i.e. you would need to do somthing like this.

java -da:com.blah.MyClass com.blah.MyClass

Once this is done all the statements below achieve exactly the same thing, in that they disable assertions in the class com.blah.MyClass

java -da:com.blah.MyClass com.blah.MyClass
java -da com.blah.MyClass
java com.blah.MyClass

Hope that helps
 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
from web page


no arguments
Enables or disables assertions in all classes except system classes.
packageName...
Enables or disables assertions in the named package and any subpackages.
...
Enables or disables assertions in the unnamed package in the current working directory.
className
Enables or disables assertions in the named class



so java -da com.blah.MyClass <no arguments>

java -da:com.blah.MyClass <disables assertions in com.blah.MyClass class >
 
get schwifty. tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic