Combining multiple @SuppressWarnings annotations - Eclipse Indigo

knownasilya picture knownasilya · Oct 25, 2012 · Viewed 51.7k times · Source

So the issue is being able to combine multple warning suppressions so that each item doesn't need it's own @SuppressWarnings annotation.

So for example:

public class Example
    public Example() {
        GO go = new GO();  // unused
        ....
        List<String> list = ( List<String> ) go.getList(); // unchecked
    }
    ...
    // getters/setters/other methods
}

Now instead of having two @SuppressWarnings I want to have one at the class level for those two warnings, so like this:

@SuppressWarnings( "unused", "unchecked" )
public class Example
    public Example() {
        GO go = new GO();  // unused - suppressed
        ....
        List<String> list = ( List<String> ) go.getList(); // unchecked - suppressed
    }
    ...
    // getters/setters/other methods
}

But that is not a valid syntax, is there a way to do this?

Answer

LuGo picture LuGo · Oct 25, 2012

Use the following: @SuppressWarnings({"unused", "unchecked"})