on 07-26-2005 2:22 PM
Hi,
i am developing on jdk 1.4.2_8 and use assert statements to ensure that e.g. references are not null:
Object test = null;
try {
assert test != null;
test.doSomething();
} catch (AssertionError error) {
//do something
}
The problem is that the assert - which is highlighted as keyword in NWDI - does not throw an exception but goes on and the test.doSomething() throws a null-Pointer.
Do you have any clue why the assert does not work properly?
Thank you and best regards,
Daniel
hi, are assertions enabled..? http://java.sun.com/j2se/1.4.2/docs/guide/lang/assert.html#enable-disable
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
thank you! Well, excuse me when my question is stupid, but where can I ensure that assertions will be enabled in NWDI? I could not find a flag or something like that to enable assertions. Due to the fact that I am not doing something like java -ea how can I then ensure that assertions are enabled?
Thank you and best regards,
Daniel
Message was edited by: Daniel Ritter
Daniel,
And what is "Java WD" if it is not "Java classes"?
F.J. gives you correct answer.
However, I would like to emphasize your misuse of assertion functionality: Java program should not depend on the fact whether or not assertions are enabled. Obviously, you do right the opposite.
If your argument may be null, then it is better to check it via "if" statement and branch logic. If it must be non-null, then there is no reason to catch AssertionError.
Btw, do you know that you must not catch sublasses of java.lang.Error? Unless you are writting something like app. server or profiler.
VS
Valery,
thank you for your unfriendly, unqualified and subjective answer. People who have the time to write stuff like that...
If you don't know what Java WD is then read the documentation. Furthermore you will see how to start it and then try to do it with assertions enabled.
Well, let me emphasize your thoughtlessness because you have no clue what I want to do with assertions!!! So don't judge people when you don't have any knowledge!
Btw, see above!
DR
LOL!
<i>thank you for your unfriendly, unqualified and subjective answer.</i>
"unfriendly" -- this is really "subjective"
"unqualified" -- well, who knows... every SDN member has business card, you may check my...
<i>People who have the time to write stuff like that...</i>
Yes, and some of these people even have time to check their own suggestions before post. Like me, for example...
<i>If you don't know what Java WD is then read the documentation.</i>
Thanks for the tip.
<i>Furthermore you will see how to start it and then try to do it with assertions enabled.</i>
Ok, Master. Verify my steps, please:
1. Run config tool
2. Go to cluster-data/instance_ID######/server_ID####
3. Add option on "General" tab, "Java parameters"
4. Restart server
I do not know what I do wrong, but assertions get enabled!
<i>Well, let me emphasize your thoughtlessness because you have no clue what I want to do with assertions!!! So don't judge people when you don't have any knowledge!</i>
Simply brilliant!!! No further comments...
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.