assert
Hi.
Try the following code:
String s = this.getClass().getName();
assert (s != null);
int l = s.length();
there's a warning on s.length() that says it might produce an exception.
I recall having this in the bug tracker but can't find it now.
Amnon
Please sign in to leave a comment.
I agree with Amnon, this is a very annoying bug.
If I care to assert that a reference is not null, Aurora should't warn me that it may be null!!
As i know, to run java code with assertion enabled you must use special
parameter -ea. So, this mean, that "assert" will not guarantied safe
assertion, and warning have valid in this case.
"Francesco Bellomi" <fbellomi@libero.it> wrote in message
news:32642801.1071137048353.JavaMail.javamailuser@localhost...
>
that it may be null!!
>
Please fill SRC to tracker
Vladimir Kondratyev
___________________
JetBrains
Amnon I. Govrin wrote:
I've also seen this problem. But we use our own assertion framework. How
should IDEA know?
Tom
This IS a bug, as if you change it to "assert s == null;" the warning
dissappears, and that can't be right.
If you remove the assert altogether, the warning disappears as well.
"Alexey Efimov" <aefimov@spklabs.com> wrote in message
news:br9fuj$fcg$1@is.intellij.net...
>
me
>
>
Done.
http://www.intellij.net/tracker/idea/viewSCR?publicId=23407
Amnon
"Vladimir Kondratyev (JetBrains)" <vova@intellij.com> wrote in message
news:br9gjp$ih8$1@is.intellij.net...
>
>
On 12/11/03 6:37 PM, in article bra2uu$i92$1@is.intellij.net, "Amnon I.
Govrin" <agovrin@freshwater.com> wrote:
Fixed.
>> Please fill SRC to tracker
>>
>> Vladimir Kondratyev
>> ___________________
>> JetBrains
>>
>> Amnon I. Govrin wrote:
>>> Hi.
>>>
>>> Try the following code:
>>> String s = this.getClass().getName();
>>> assert (s != null);
>>> int l = s.length();
>>>
>>> there's a warning on s.length() that says it might produce an exception.
>>>
>>> I recall having this in the bug tracker but can't find it now.
>>>
>>> Amnon
>>>
>>>
--
Maxim Shafirov
JetBrains, Inc
http://www.intellij.com
"Develop with pleasure!"
Awsome.
"Maxim Shafirov (JetBrains)" <max@intellij.com> wrote in message
news:BBFE82B2.1B48%max@intellij.com...
>
>
exception.
>
>
>
Was it fixed by trusting assert statements (that is, assuming they're always executed)? I hope this isn't the case.
On 12/12/03 4:12 AM, in article
15759718.1071191521803.JavaMail.javamailuser@localhost, "Keith Lea"
<keith@cs.oswego.edu> wrote:
Exactly. Why you find it wrong?
--
Maxim Shafirov
JetBrains, Inc
http://www.intellij.com
"Develop with pleasure!"
I think this is wrong because assertions are not always executed.
Keith Lea wrote:
But, if you've got an assertion statement then you're obviously aware
that this condition could occur and are willing to take the risk of it
happening when assertions are disabled. If you weren't willing to take
the risk, you would use code that explicitly checks the condition
instead of using an assertion.
Therefore, I think it's fine for IDEA to not show warnings for
conditions that asserted to be false by the code.
Ciao,
Gordon
--
Gordon Tyler (Software Developer)
Quest Software <http://java.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: 416-643-4846 | Fax: 416-594-1919