On 25 September 2010 12:33, Reinier Zwitserloot <[email protected]> wrote:
> I have a good trick for you: *IF* the thing you want to suppress
> warnings on can be limited to a single expression, this works just
> fine:
>
> @SuppressWarnings("unsafe") List<String> x = (List<String>) someList;
>
> It has to be a variable declaration though, not just an assignment.
> Only declarations can legally be annotated. Still, useful quick hack
> to limit the scope of a @SuppressWarnings.

Thanks. I did know about that. Plus you can do a similar thing for
unused parameters, e.g.

    int example(int a, @SuppressWarnings("unused") int b) {
        return a * 2;
    }

But I find it ugly when these annotations appear in the FP list, or in
the method body, as opposed to in the method modifiers.

Rich

-- 
You received this message because you are subscribed to the Google Groups "The 
Java Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to