| Author |
Khalid Mughal : Assertions
|
Sahil Kapoor
Ranch Hand
Joined: Sep 12, 2009
Posts: 316
|
|
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.
|
SCJP 6.0 96%
(Connecting the Dots ....)
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9191
|
|
|
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...
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
Abimaran Kugathasan
Ranch Hand
Joined: Nov 04, 2009
Posts: 2066
|
|
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.
|
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
|
 |
Sahil Kapoor
Ranch Hand
Joined: Sep 12, 2009
Posts: 316
|
|
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.
|
 |
Deepak Bala
Bartender
Joined: Feb 24, 2006
Posts: 6603
|
|
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
|
SCJP 6 articles - SCJP 5/6 mock exams - SCJP Mocks - SCJP 5 Mock exam (Word document ) - SCJP 5 Mock exam in Java.Inquisition format
|
 |
Sahil Kapoor
Ranch Hand
Joined: Sep 12, 2009
Posts: 316
|
|
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
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9191
|
|
|
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
Joined: Sep 12, 2009
Posts: 316
|
|
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
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9191
|
|
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
Joined: Feb 24, 2006
Posts: 6603
|
|
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
Joined: Sep 12, 2009
Posts: 316
|
|
Thanks Ankit & Deepak
|
 |
 |
|
|
subject: Khalid Mughal : Assertions
|
|
|