classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] FYI: Remove (bogus) asserts in java-net.


From: Mark Wielaard
Subject: Re: [cp-patches] FYI: Remove (bogus) asserts in java-net.
Date: Thu, 19 Jan 2006 20:04:28 +0100

Hi Roman,

On Thu, 2006-01-19 at 11:18 +0100, Roman Kennke wrote:
> Granted, the example is a little constructed. The point is not if you
> get the crash in f2() anyway. The point is that the asserts help you
> find the actual bug. In a real world environment you may trash the stack
> anywhere, not only one function call up. The asserts help you find out,
> 'Oh, there's something wrong in f2() but in f1() it was ok, so the error
> must be in f1()'. Imagine such a scenario when there are more function
> calls in between etc and you quickly see that the asserts actually make
> sense.

In general our JNI code is a small as possible without any deeply nested
functions. Some of the assert code did more than the actual real code of
the JNI method did.

> OTOH, when you say the asserts don't make sense for argument checking,
> can you give a good example of a use case for asserts? Or are you
> opposed to using asserts in general?

I'll try to be a bit more constructive. I admit to have been very
irritated by the wrong asserts that made the network code just not work
and me finding out late while I was making and testing the 0.20 release.

For me there were two issues:

- The clearly wrong asserts that just prevented the code working. Maybe
correct ones could be added, but assert is just not that friendly. If we
had something like in the gtk-peers where a gtk-error translates into a
InternalError stacktrace it might be a bit more useful. But I still feel
these obvious asserts are not that helpful since if they fail so would
the code anyway when they weren't there.

- The asserts for the JNIEnv being setup correctly. I think this is like
checking that the Program Counter increased since the last instruction.
If the JNIEnv really is trashed you are so deep in trouble that an
assert won't help you anyway. It means the runtime is broken, or
something seriously trashed memory.

Cheers,

Mark

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]