pippo-java / pippo

Micro Java Web Framework
http://www.pippo.ro
Apache License 2.0
787 stars 128 forks source link

unchecked generic array creation for varargs parameter of type java.lang.Class<? extends ro.pippo.controller.Controller>[] #507

Closed pitschr closed 5 years ago

pitschr commented 5 years ago

Hello.

Today I implemented the first pippo web service and everything are fine. However, I just noticed a warning message in IntelliJ:

Warning:(71, 23) java: unchecked generic array creation for varargs parameter of type java.lang.Class<? extends ro.pippo.controller.Controller>[]

My code is more&less same as suggested in official documentation: addControllers(HttpDaemonController.class);
(my created controller just extends the ro.pippo.controller.Controller, nothing special)

Sure, it is only a warning and we can ignore it, but do you see an opportunity to get rid off it? If you need more details, I'm happy to provide it.

KR, Christoph

decebals commented 5 years ago

Can you supply a quickstart project (GitHub or zip) that replicates/reproduces the problem?

More details (Java version, Pippo version, ...) help me find the problem faster.

pitschr commented 5 years ago

Hi Decebals.

Sure. My details: Java 11.0.2, Pippo 1.12.0.

I now committed my project to GitHub and can confirm that the warning is raised in Travis as well (line 530): https://travis-ci.org/pitschr/knx-link/builds/522303944

The implementation (line 70): https://github.com/pitschr/knx-link/blob/master/src/main/java/li/pitschmann/knx/daemon/HttpDaemonApplication.java

Let me know if you need more details.

KR, Christoph

decebals commented 5 years ago

The fast fix is to add SuppressWarnings annotation like


public class HttpDaemonApplication extends ControllerApplication {

    @SuppressWarnings("unchecked")
    protected void onInit() {
         // your business
    }

}
pitschr commented 5 years ago

Yes, this is the way I have to go, I suppose. I just was wondering that it is per design. But, thank you for your clarification. KR, Christoph

p.s. pippo is a great project! well done!

decebals commented 5 years ago

Thanks for appreciations! In last period of time I was a little bit busy with the release of the third major version of PF4J. After PF4J will be released, I will invest in the second version of Pippo.

If you encounter problems with Pippo, please let me know.

pitschr commented 5 years ago

Closed this thread as it is not critical and when resolving that in second version it would be great!