Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Raw Type Warning in Android Studio

Android Studio doesn't show a compiler warning when using the raw type in referencing a generic type. Is there a way to enable this feature?

public class GenericClass<T> {
}

public class SpecificClass extends GenericClass {
}

Eclipse usually shows the following warning: GenericClass is a raw type. References to generic type GenericClass <T> should be parameterized.

like image 296
multiholle Avatar asked Jul 22 '15 11:07

multiholle


1 Answers

You can enable the warning but cant force it as compilation error. Same is the case in Eclipse[see tail for the update]. You can refer to JLS which states it compilation warning and not a compilation error.

You can enable the inspection in your android studio. Go to File > Settings > Inspection and turn on the check as for the "Raw use of parameterized class" setting as shown below may help:

raw usage

Thanks to Stephan: You can enable this in Eclipse using: Java Compiler > Errors/Warnings > Generic Types > Usage of a raw type: and select Error in the combo

like image 181
Garry Avatar answered Nov 09 '22 11:11

Garry