Some input files use unchecked or unsafe operations

项目的异常环境:

项目类型:基本的gradle构建工程,加一些junit测试!

gradle版本:gradle 6.0 / gradle5.6.3 都有实践过!

gradle不同版本的下载地址

注:下载时只要下载xxxx-bin.zip就可以使用!

Junit版本:Junit5 。

Junit5的Gradle依赖:

testImplementation 'org.assertj:assertj-core:3.11.1'
testCompile('org.mockito:mockito-junit-jupiter:2.18.3')

// Deprecated. Target to remove powermock & junit4
testCompile group: 'org.powermock', name: 'powermock-api-mockito2', version: '2.0.0-beta.5'
// Deprecated. Target to remove powermock & junit4
testCompile group: 'org.powermock', name: 'powermock-module-junit4', version: '2.0.0-beta.5'
// Deprecated. Target to remove powermock & junit4
testCompile group: 'org.powermock', name: 'powermock-core', version: '2.0.0-beta.5'

testCompile group: 'org.mockito', name: 'mockito-core', version: '2.19.0'

testImplementation("org.junit.jupiter:junit-jupiter-api:5.5.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.5.2")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.5.2")

问题展示:

原因分析及相应的解决方法:

 原因分析:

          注意: 一些输入文件 使用了未经检查或不安全的操作。

          注意: 要了解详细信息,请使用 -Xlint:unchecked 重新编译。

          其实是因为用到了JAVA5.0的泛型,而5.0的泛型不做类型检查。

例如:ArrayList list =new ArrayList();

           list.add("apple");

           这样由于泛型问题就会出现这种警告!

解决方法:

         1)在方法的前面加上注解:@SuppressWarnings("unchecked");

         2)声明泛型类型,例如:ArrayList<Object> list = new ArrayList<Object>();

         3)使用1.4兼容JDK对项目进行编译:javac -source 1.4 XXX.java;

         4)查看详细的警告信息:javac Xlint:unchecked XXX.java;


 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
private void updateShowSeconds() { if (mShowSeconds) { // Wait until we have a display to start trying to show seconds. if (mSecondsHandler == null && getDisplay() != null) { mSecondsHandler = new Handler(); if (getDisplay().getState() == Display.STATE_ON) { mSecondsHandler.postAtTime(mSecondTick, SystemClock.uptimeMillis() / 1000 * 1000 + 1000); } IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_OFF); filter.addAction(Intent.ACTION_SCREEN_ON); mContext.registerReceiver(mScreenReceiver, filter); } } else { if (mSecondsHandler != null) { mContext.unregisterReceiver(mScreenReceiver); mSecondsHandler.removeCallbacks(mSecondTick); mSecondsHandler = null; updateClock(); } } } private final BroadcastReceiver mScreenReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (Intent.ACTION_SCREEN_OFF.equals(action)) { if (mSecondsHandler != null) { mSecondsHandler.removeCallbacks(mSecondTick); } } else if (Intent.ACTION_SCREEN_ON.equals(action)) { if (mSecondsHandler != null) { mSecondsHandler.postAtTime(mSecondTick, SystemClock.uptimeMillis() / 1000 * 1000 + 1000); } } } }; private final Runnable mSecondTick = new Runnable() { @Override public void run() { if (mCalendar != null) { updateClock(); } mSecondsHandler.postAtTime(this, SystemClock.uptimeMillis() / 1000 * 1000 + 1000); } }; } 编译报错,lframeworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/clock.java:115: cannot findlsymbolsymbol method getstate()location: class android.view.Display if (getDisplay().getstate() == Display.STATE_ON) fframeworks/base/packages/SystemUI/src/com/android/systemui/statusbar/policy/clock.java:115: cannot findlsymbolsymbol : variable STATE_ONlocation: class android.view.Display if (getDisplay().getstate() == Display.STATE_ON) fNote: Some input files use or override a deprecated API.Note: Recompile with -xlint:deprecation for details.Note: Some input files use unchecked or unsafe operations.Note: Recompile with -xlint:unchecked for details.2 errorsmake: *** fout/target/common/obi/Apps/SvstemlT intermediates/classes-full-dehun iarl Frror 4l
06-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值