Assertions can be enabled/disabled programatically ?

R

Razvan

Hi !





Is it possible to enable/disable assertions from a program while it
is running ? It seems that the function

setClassAssertionStatus(String className, boolean enabled);

from the class ClassLoader is doing that.

Did anybody used such a technique ? Please give me an example where
enabling/disabling assertions on the fly is useful.




Regards,
Razvan
 
P

Paul Lutus

Razvan said:
Hi !





Is it possible to enable/disable assertions from a program while it
is running ? It seems that the function

setClassAssertionStatus(String className, boolean enabled);

from the class ClassLoader is doing that.

Did anybody used such a technique ? Please give me an example where
enabling/disabling assertions on the fly is useful.

Well, obviously, to shield yourself from the ire of your users. Another
reason is to speed up a program after testing is completed.
 
R

Razvan

Paul Lutus said:
Well, obviously, to shield yourself from the ire of your users. Another
reason is to speed up a program after testing is completed.

Shield ... ?! What do you mean ?

If you want to speed up the program after testing then you
will run the program AS USUAL: with assertions disabled. No tricks
needed here.

Have you actually used this technique in practice ? If the
user bothers to specify the flag -ea it must have a good reason to do
so ! It is not a good idea to write programs with 'personality' (eg
that do what they want).
 
R

Razvan

Hi !





Is it possible to enable/disable assertions from a program while it
is running ? It seems that the function

setClassAssertionStatus(String className, boolean enabled);

from the class ClassLoader is doing that.

Did anybody used such a technique ? Please give me an example where
enabling/disabling assertions on the fly is useful.




Regards,
Razvan



No other brave soul has ever tried this ? :))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top