A
A
Artyom -2018-05-29 11:19:42
Java
Artyom -, 2018-05-29 11:19:42

MvcWebApplicationInitializer, what is the build warning about?

The class itself:

public class MvcWebApplicationInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
  @Override
  protected Class<?>[] getRootConfigClasses() {
    return new Class[] {AppConfig.class, WebSecurityConfig.class};
  }
  @Override
  protected Class<?>[] getServletConfigClasses() {
    return new Class[] {WebConfig.class};
  }
  @Override
  protected String[] getServletMappings() {
    return new String[] {"/"};
  }
}

I build maven and get warnings:
[WARNING] путь\config\MvcWebApplicationInitializer.java:[9,13] [rawtypes] found raw type: Class
missing type arguments for generic class Class<T>
  where T is a type-variable: T extends Object declared in class Class
[WARNING] путь\config\MvcWebApplicationInitializer.java:[14,13] [rawtypes] found raw type: Class

I don't understand what he means by this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Eugene, 2018-05-29
@tinoajato

In the first two methods, you describe the return value as a Class<?>{}. This can be interpreted as "an array of classes typed with an unknown type". In doing so, you return a Class[] (without the <?>), which is interpreted as "an array of classes not typed by any type". For the compiler, in principle, there is not much difference between these entries, so it only issues a warning that an array of typed Class was expected to be returned, but an array of untyped ones is returned.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question