Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Enabling assertions for Packages

 
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
What is the syntax for enabling the assertions for packages.
In K&B it has given that the syntax for enabling assertions is,
(Page No, 262 - If the package name is com.geeksanonymus)
java -ea:com.geeksanonymus <classname>
With the above syntax you can enable the assertions for all the classes in the package com.geeksanonymus and its sub packages too.
But in some material i saw the syntax is,
java -ea ... com.geeksanonymus <classname>
I am having one more doubt,
In some material i saw that, Assetion can be used for
"When you have written a comment that asserts as invariant"
What is the meaning of the above sentence....

Thanks in Advance...
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
There are 4 ways to Enable or Disable assertions:
1. -ea and -da. This is used to enable/disable assertions for all non-system classes.
2. -ea:<packagename>.../-da:<packagename>... - This enables/disables the assertions in the package given by the packagename & it's subpackages.
3. -ea:.../-da:... enables/disables all assertions in the unnamed package
4. -ea:<classname>/-da:<classname> - Enables/Disables all assertions in the particular class
 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I also have the same doubt. I think I saw this in Marcus, not sure though.
In some material i saw that, Assetion can be used for
"When you have written a comment that asserts as invariant"
What is the meaning of the above sentence....
Regards,
Raman
 
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This invarint topic is from Khalid's book. The book provides a nice explanation for this.
Cheers
-Suresh
 
Padma Raman
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I do not have the Kahlid's book. Could you please explain it if you can?
Regards
 
Narasimha Rao B.
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Swati,
I fully agree with you, that uisng the 3 dots to indicate if it is a package name instead of class name. But if you see the K&B book - Page no 263, Table 4.4 - Below is the syntax to enable assertions for com.foo
java -ea:com.foo
Here how it will work without using the dots.. This my exact doubt.

Thanks..
 
Swati Singhal
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are they talking about the foo class within the com package??
Because -ea:com.foo (wihout the dots) will enable assertions for the foo class within com package.
 
Narasimha Rao B.
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Swati,
com.foo - is package. Not foo class in com package..
Thanks
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can refer regarding Invariants in the below url
http://java.sun.com/j2se/1.4.2/docs/guide/lang/assert.html#usage-invariants
also the excerpt regarding Assertion from Khalid's book.
http://www.ii.uib.no/~khalid/pgjc/jcbook/JC2_Ch05-assertions-excerpt.pdf
 
this llama doesn't want your drama, he just wants this tiny ad for his mama
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic