Android Studio中的原始类型警告

mul*_*lle 7 java compiler-warnings android-studio

在引用泛型类型时使用原始类型时,Android Studio不显示编译器警告.有没有办法启用此功能?

public class GenericClass<T> {
}

public class SpecificClass extends GenericClass {
}
Run Code Online (Sandbox Code Playgroud)

Eclipse通常显示以下警告:GenericClass是原始类型.应参数化对泛型类型GenericClass <T>的引用.

Gar*_*rry 6

您可以启用警告但不能强制它作为编译错误.Eclipse中的情况也是如此[请参阅tail的更新].您可以参考JLS,它指出编译警告而不是编译错误.

您可以在Android studio中启用检查.转到File > Settings > Inspection并打开检查,如下所示"参数化类的原始使用"设置可能会有所帮助:

原始用法

感谢Stephan:您可以使用::在Eclipse中启用它, Java Compiler > Errors/Warnings > Generic Types > Usage of a raw typeError在组合中选择