Re: Ensuring a method is overridden
On Sep 9, 3:32 pm, Daniel Pitts
<newsgroup.spamfil...@virtualinfinity.net> wrote:
Lew wrote:
Daniel Pitts wrote:
You don't need to test for all invariants everywhere, especially
invariants that would cause an exception anyway (such as a collection
must only contain objects of a certain class. That will be caught by a
ClassCastException, which is a built-in assertion you can not disable)
A ClassCastException is not an assertion. It's an exception.
It isn't an "assert" assertion, but it is still an "assertion" in the
English sense of the word. The JVM asserts that the class you cast to
is the runtime type of the class.
That is only one example.
NullPointerException, ArrayIndexOutOfBounds, etc.. are the same kind of
thing.
Technically, they are Exceptions, specifically RuntimeExceptions, but
that doesn't prevent them from being a kind of JVM level assertion.
A very disingenuous approach, that. "Assertion" in computer science,
and in Java particularly, has a specific technical meaning. To argue
that you meant it in "the English sense of the word" when you didn't
say so at first is misleading. Please be aware that when you use a
specific technical term in its specific technical context, that people
will expect the technical meaning not the non-technical meaning, and
to pretend otherwise only causes confusion.
--
Lew