Forum

Number Of Page View:100,000+/Months
LOGIN |New User

Reply

Selective Enabling and Disabling
The command-line switches to enable and
disable assertions can be used in various ways :
> With no arguments
> With a package name
> With a class name
         We can combine switches to, say, disable assertions in a single class, but keep them enabled for all others, as follows :
java -ea -da:com.geeksanonymous.Foo
            The preceding command line tells the JVM to enable assertions in general, but disable them in the class com.geeksanonymous.Foo. We can do the same selectivity for a package as follows :
       java -ea -da:com.geeksanonymous
              The preceding command line tells the JVM to enable assertions in general, but disable them in the package com.geeksanonymous, and all of its subpackages!A subpackage is any package in a subdirectory of the named package. For example, look at the following directory tree:
com
   |_geeksanonymous
                |_Foo
                |_Bar
                |_twelvesteps
                            |_StepOne
                            |_StepTwo
         This tree lists three directories,
com
geeksanonymous
twelvesteps
            and four classes :
com.geeksanonymous.Foo
com.geeksanonymous.Bar
com.geeksanonymous.twelvesteps.StepOne
com.geeksanonymous.twelvesteps.StepTwo

--------------------------------------------------
Command-Line            |   What It Means 
Example
--------------------------------------------------
java -ea               |  Enable assertions
java -enableassertions
--------------------------------------------------
java -da               |  Disable assertions
java -disableassertions
--------------------------------------------------
java -ea:com.foo.Bar   |Enable assertions in     
                        class com.foo.Bar
--------------------------------------------------
java -ea:com.foo       | Enable assertions in 
                         package com.foo, and any
                         of its subpackages
--------------------------------------------------
java -ea -dsa          | Enable assertions in 
                         general but disable 
                         assertions in system 
                         classes
--------------------------------------------------
java -ea -da:com.foo   | Enable assertions in
                         general, but disable
                         assertions in package
                         com.foo and any of its
                          subpackages
--------------------------------------------------
Posted By: Name:Rajesh Kr URL: Selective Enabling and Disabling