Can assertion be enabled for multiple classes? I.e. If my application will access class A, B, and C which may or may not be in the same package and I want to enable assertion on class A and B, but not C. :roll:
And things get interesting when Class B inherits from Class A and Class A has assertions enabled, and Class B does not ( or vice versa ). -------------------------------------- Considering the Certified Java Programmer Exam? Get JCertify! http://www.enterprisedeveloper.com/jcertify For exam 310-025 and 310-035
Joined: Jul 01, 2002
Thank you David for pointing that out. Another question. I read about assertion in the book, JDK 1.4 Tutorial by Gregory M Travis. He has an example where he does something like"java -ea kg0 MyProgram" to enable assertion for the package pkg0. He leaves out ... after pkg0 name and the result is that assertion is disabled. I tried that myself and found the same result and no complaint from JRE. Is this because it thinks that I try to enable assertion for a class name, pkg0? And since there's no such class, the enable does not have effect. And seems like, it doesn't check for existence of the class either. Thanks a bunch.
Joined: Sep 29, 2000
Yes. The "..." is the hint to the JVM that the name you gave it is a package name instead of a class name. Don't you just LOVE the -ea:... option . "Just check stuff in THIS directory".