This week's book giveaway is in the Open Source Projects forum.
We're giving away four copies of Eclipse Collections Categorically: Level up your programming game and have Donald Raab on-line!
See this thread for details.
  • 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

selective enabling and disabling in assertion

 
Ranch Hand
Posts: 144
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi guys
from K and B book:
The command-line switches for assertions can be used in various ways:

■ With no arguments (as in the preceding examples) Enables or disables
assertions in all classes, except for the system classes.

>> what does it mean by except for system classes? can we have an example for that?

With a package name Enables or disables assertions in the package specified,
and any packages below this package in the same directory hierarchy
(more on that in a moment).

does it mean if we first make java -ea:com.geeksanaymous... later we can use only java without -ea to run any java class inside the geeks anaymous directory and its subdirectories? like java Test1 >>> for Test1.java in geeksanaymous directory
i tried to use java -ea:a packageName but if fials

■ With a class name Enables or disables assertions in the class specified.


what is the difference between java -ea Test1 and java -ea:Test1 in terms of funcitonallity


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

Hama Kamal wrote:what does it mean by except for system classes? can we have an example for that?



http://stackoverflow.com/questions/2670269/which-are-javas-system-classes

Michael Borgwardt wrote: According to the assertions documentation, system classes are classes "which do not have an explicit class loader", i.e. the classes loaded by the bootstrap classloader. AFAIK that means the contents of rt.jar, the entire standard API.



==================================================================================

Hama Kamal wrote:
what is the difference between java -ea Test1 and java -ea:Test1 in terms of funcitonallity



The first enables all assertions in non-system classes. The second enables assertions only for the Test1 class.

The second one needs a program to run: java -ea:packagename.ClassName ProgramToRun

http://download.oracle.com/javase/1,5.0/docs/guide/language/assert.html#enable-disable


-ea
no arguments - Enables or disables assertions in all classes except system classes.
packageName... - Enables or disables assertions in the named package and any subpackages.

If a single command line contains multiple instances of these switches, they are processed in order before loading any classes. For example, the following command runs the BatTutor program with assertions enabled in package com.wombat.fruitbat but disabled in class com.wombat.fruitbat.Brickbat:

java -ea:com.wombat.fruitbat... -da:com.wombat.fruitbat.Brickbat BatTutor

 
I wasn't selected to go to mars. This tiny ad got in ahead of me:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic