• 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

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Article of


Any of the following commands enables assertion checking in class Foo:
1)java -ea Foo
2)java -ea:Foo Foo
3)java -ea:... Foo


I understood what 1 and 3 do.But what's the purpose bof writing the classname(Foo) two times in command no. 2.
Can any one explain?
Thanx in advance.
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Osama, please change your display name to meet the JavaRanch naming requirements. You must use first name - space - last name.
 
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator




I understood what 1 and 3 do.But what's the purpose bof writing the classname(Foo) two times in command no. 2.
Can any one explain?
Thanx in advance.


I think you mistyped the name of your class i.e Foo1 instead of Foo. Anyway the following command
java -ea:Foo Foo
runs the program called Foo with Assertions enable only in package Foo and its subpackages.
you might have a package called Foo then.
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Thomas Paul:
Osama, please change your display name to meet the JavaRanch naming requirements. You must use first name - space - last name.


And here is the link:
Change your displayed name here
 
Osama Hasan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am still confused.
I am running class Foo with the command line:
java -ea:Foo Foo
Although class Foo is not in the package "Foo" but still class Foo is running with assertions enabled.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thought I'm not a professional on this particular issue, a quick search on the web found me this functionality for -ea:
<cut>
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
<cut>
--------------------
So java -ea:Foo Foo enables assertions for _class_ Foo not package, and runs the program Foo.

Jussi Sairanen
reply
    Bookmark Topic Watch Topic
  • New Topic