Domanda

I am using Checkstyle Eclipse plugin 5.5 to validate my Java project using standard coding style. I was wondering if Checkstyle generates any error/warning if I have not referenced generic types using parameters?

Now this warning is already shown as a type of Java problem. Just curious if Checkstyle also catches this (apart from manual configuration/tweak).

È stato utile?

Soluzione

You mean, can Checkstyle detect something like List list = new ArrayList(); as missing generic type arguments.

No, Checkstyle can't do that because it works only on the Java source files, so it would not know if the List you are referencing has type parameters or not. Checkstyle would have to determine the binary class name of List, and locate its source, which may not even be available in many cases.

FindBugs may be able to do that, as it works on the compiled .class files. I don't know of a FindBugs rule which covers exactly your case, but there are other FindBugs rules related to generics.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top