0

I have this method:

 @SafeVarargs
 public static MyClass getInstance(String myString,
        Class<? extends MyInterface>... classes) {
    if (instance == null) {
        instance = new MyClass();
    }

    if (classes != null) {
        for (Class<? extends MyInterface> c : classes) {
            MyInterface mi = instantiateClass(c);
            mi.myMethod();
        }
    }
    return instance;
}

Calling this method generates this warning on Eclipse:

 Type safety: A generic array of Class<? extends MyInterface> is created for a varargs parameter

Since I'm working on a framework I'd like to get rid of this warning without annotating the client code. To do that I've annotated my method with @SafeVarargs, but I keep getting the warning.

Maybe I'm not understanding this annotation? Shouldn't it suppress the warning?

Thank you.

Aurasphere
  • 3,841
  • 12
  • 44
  • 71

0 Answers0