multiholle
multiholle

Reputation: 3160

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.

Upvotes: 7

Views: 1578

Answers (1)

Garry
Garry

Reputation: 4533

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

Upvotes: 6

Related Questions