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


0
12 comments
Avatar
Permanently deleted user

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!!

0
Avatar
Permanently deleted user

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...

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!!
>


0
Avatar
Permanently deleted user

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

0
Avatar
Permanently deleted user

I've also seen this problem. But we use our own assertion framework. How
should IDEA know?

Tom

0
Avatar
Permanently deleted user

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...

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...

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!!
>

>
>


0
Avatar
Permanently deleted user

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...

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

>
>



0
Avatar
Permanently deleted user

On 12/11/03 6:37 PM, in article bra2uu$i92$1@is.intellij.net, "Amnon I.
Govrin" <agovrin@freshwater.com> wrote:

Fixed.

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...

>> 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!"


0
Avatar
Permanently deleted user

Awsome.

"Maxim Shafirov (JetBrains)" <max@intellij.com> wrote in message
news:BBFE82B2.1B48%max@intellij.com...

On 12/11/03 6:37 PM, in article bra2uu$i92$1@is.intellij.net, "Amnon I.
Govrin" <agovrin@freshwater.com> wrote:

>

Fixed.

>

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...

>> 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!"

>
>


0
Avatar
Permanently deleted user

Was it fixed by trusting assert statements (that is, assuming they're always executed)? I hope this isn't the case.

0
Avatar
Permanently deleted user

On 12/12/03 4:12 AM, in article
15759718.1071191521803.JavaMail.javamailuser@localhost, "Keith Lea"
<keith@cs.oswego.edu> wrote:

Was it fixed by trusting assert statements (that is, assuming they're always
executed)? I hope this isn't the case.

Exactly. Why you find it wrong?
--
Maxim Shafirov
JetBrains, Inc
http://www.intellij.com
"Develop with pleasure!"


0
Avatar
Permanently deleted user

I think this is wrong because assertions are not always executed.

0
Avatar
Permanently deleted user

Keith Lea wrote:

I think this is wrong because assertions are not always executed.


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

0

Please sign in to leave a comment.