Re: array of lists



Wesley Hall wrote:
Thomas Hawtin wrote:

@SuppressWarnings({"unchecked"})
That is a measure of last resort. Not something to be thrown around just
to make the compiler shut up. If the compiler is making a noise, there
is probably a good reason.

In this case, it seems to be that the compiler is moaning that the OP is
using an array with no generic type, but as there seems to be no way to
create an array WITH a generic type (no reasonable way at least) then it
is not possible to avoid the compiler warning and still use arrays.

Yes, creating an array with a generic type is BAD. Ditch the arrays.

Using a list (as per you first point) is a reasonable measure but is not
always an option. There is still plenty of third party code that
requires the use of reference type arrays.

But there is no need to let these creep into your code.

I don't agree that the above annotation is 'the measure of a last
resort'. A warning is exactly that, a warning. Once the developer has
analysed the problem, determining that the warning is valid but doesn't
pose any problem then using the annotation to suppress the warning is a
good move. It will prevent the next developer to compile the code from
wasting time analysing a superfluous warning.

In Java, a warning is essentially an error that cannot be treated as such due to backward compatibility concerns. If you blindly suppress notifications of errors, then you are storing up problems for future developers. Even if no problem is (thought to be) posed, it is far better to fix the cause rather than the effect.

Tom Hawtin
.



Relevant Pages

  • Re: A C++-Language Question (Maybe C, too)
    ... So, here's an array definition. ... Under the gnu compiler, if I leave out one of the commas this ... The problem is you are asking to receive a warning for what is perfectly ... warn against missing structure initialisers, ...
    (comp.arch.embedded)
  • Re: A C++-Language Question (Maybe C, too)
    ... So, here's an array definition. ... English-language strings for four possible fault conditions. ... Under the gnu compiler, if I leave out one of the commas this construct ... The problem is you are asking to receive a warning for what is perfectly ...
    (comp.arch.embedded)
  • Re: Stack growth direction to thwart buffer overflow attacks
    ... > via SIGABRT or whatever when the buffer is exceeded, ... the MS compiler has an extension that lets you mark ... can insist that the warning count falls over time. ... For the wider problem of running off the ends of an array, ...
    (comp.security.unix)
  • Re: Stack growth direction to thwart buffer overflow attacks
    ... > via SIGABRT or whatever when the buffer is exceeded, ... the MS compiler has an extension that lets you mark ... can insist that the warning count falls over time. ... For the wider problem of running off the ends of an array, ...
    (comp.security.misc)
  • Re: Missing Index Value in Array Aggregate
    ... Doing so fixes bugs. ... Sometimes I have to resort to a compiler switch to suppress a ... warning, but very rarely. ...
    (comp.lang.ada)