• 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

Khalid Mughal : Assertions

 
Ranch Hand
Posts: 316
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
given the following command , which classes would have assertions enabled

java -ea -da:com... net.examle.LaunchTranslator

1. com.example.Translator
2. dot.com.Boom
3. net.example.LaunchTranslator

2 and 3 are correct


Problem : Why 2 is correct ? We gave disabled Assertions in com package and all its subpackages , and com is a subpackage of dot.

 
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
It doesn't work that way. When we said com... , it means any package starting with com, not packages that have com as a subpackage...
 
Ranch Hand
Posts: 2066
IntelliJ IDE Clojure Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ankit Garg wrote:It doesn't work that way. When we said com... , it means any package starting with com, not packages that have com as a subpackage...



Ankit, could you please sure this, in that book, it has been said.....


The following command line will only enable assertions for all classes in the package wizard.pandorasBox and its subpackage wizard.pandorasBox.artifacts. The assertions in the class Trickster are not enabled.



 
Sahil Kapoor
Ranch Hand
Posts: 316
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ankit Garg wrote:It doesn't work that way. When we said com... , it means any package starting with com, not packages that have com as a subpackage...



But Ankit ultimately Boom class is under com package only.
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Abimaran Kugathasan wrote:

Ankit Garg wrote:It doesn't work that way. When we said com... , it means any package starting with com, not packages that have com as a subpackage...



Ankit, could you please sure this, in that book, it has been said.....


The following command line will only enable assertions for all classes in the package wizard.pandorasBox and its subpackage wizard.pandorasBox.artifacts. The assertions in the class Trickster are not enabled.





What Ankit is saying is in line with what the book says. com... indeed means 'com and its sub packages'. Packages that have com as a sub package could be a.b.com or ankit.com

This is what the book tries to say as well, but it uses a slightly different perspective to relay the same message
 
Sahil Kapoor
Ranch Hand
Posts: 316
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please do consider the following

(Defining Directory Structure )

com-->foo-->sahil-->A.class
kapoor --->com-->foo--->sahil--->B.class

super--->com ( the above com directory is in super directory)
super----> kapoor ( the above kapoor directory is in super directory)

Suppose my current directory is super

ClASSPATH is super:super/kapoor;

If i say java -ea:com... which com package we are talking about ???


Problem :- Actually i am concerned about relation between CLASSPATH and argument given to -ea , are they related?
Does java sees CLASSPATH for assertion parameters also ( like -ea:com) or just the current directory ???
Does com would be searched according to CLASSPATH or current directory. ( current directory is not given in CLASSPATH)


 
Ankit Garg
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
Think of com... as regular expression. If I say "com.*", it would match "com.example", "com.abc" but it would not match "abc.com" or "example.com"
 
Sahil Kapoor
Ranch Hand
Posts: 316
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay that i got it from your first post when you said, packages STARTING from com....

But i m concened about "where does java looks for com "

Does it relates to CLASSPATH or just current working directory from where java is invoked ???

 
Ankit Garg
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

Does it relates to CLASSPATH or just current working directory from where java is invoked ???


It applies to every package that is available on the class path...
 
Deepak Bala
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Does it relates to CLASSPATH or just current working directory from where java is invoked ???



It applies to everything. There is no specific flag to tell the JVM assertion mechanism to work only for a particular folder in the file system.
 
Sahil Kapoor
Ranch Hand
Posts: 316
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ankit & Deepak

 
I'm doing laundry! Look how clean this tiny ad is:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic