当前位置:网站首页>Record a murder case caused by ignoring the @suppresslint ("newapi") prompt
Record a murder case caused by ignoring the @suppresslint ("newapi") prompt
2022-06-11 07:55:00 【tinyvampirepudge】
Remember to ignore once @SuppressLint(“NewApi”) Prompt the blood case caused
This development uses Java Priority queue in , You need to sort the elements according to the given priority , So I wrote the following code :
private Comparator<CustomObject> comparator = new Comparator<CustomObject>() {
@Override
public int compare(CustomObject o1, CustomObject o2) {
/**
* negative 、0、 Positive numbers
* Less than 、 be equal to 、 Greater than
*/
return o1.priority() - o2.priority();
}
};
/**
* Priority queue
*/
private PriorityQueue<CustomObject> queue = new PriorityQueue<>(comparator);
What's different is that , stay new PriorityQueue<>(comparator) The constructor code has red at the bottom error Tips ,IDE Give the prompt of version compatibility , Here's the picture :

Yes, of course , As a mature Developer , I have no hesitation 、 Press the button without hesitation option + enter key , Used a way to hide the problem ,SuppressLint annotation , The code is as follows :
@SuppressLint("NewApi")
private PriorityQueue<CustomObject> queue = new PriorityQueue<>(comparator);
The annoying hint finally disappeared , It's much fresher .
I'll pay you back sooner or later , It wasn't long before I received crash The report , The details are as follows :
java.lang.NoSuchMethodError: No direct method (Ljava/util/Comparator;)V in class Ljava/util/PriorityQueue; or its super classes (declaration of 'java.util.PriorityQueue' appears in /system/framework/core-libart.jar)
At the end of the day , I used a version that did not exist in the lower version api Method ,IDE Gave me a hint to change , Then I found the prompt annoying , Just use annotations to hide the hints , The problem is still unsolved .
ok , Solve the problem seriously . After consideration , take PriorityQueue + Comparator Replace with List + Comparator + Collections.sort(list, comparator) The way , Problem solved .
This story tells us ,IDE I won't give you any hints if I have nothing to do , Let's have some snacks later .
Reference resources :
https://stackoverflow.com/questions/36103606/nosuchmethoderror-for-comparator/36103681
边栏推荐
- Pycrypto packaging error
- C. Managing history (greedy / hashing / thinking / good questions)
- Crawl Baidu Baipin dynamic page
- Session and session management technology
- Image data enhancement (translation, rotation, brightness transformation, flipping, adding Gaussian noise, scaling, cropping)
- What exactly is PMP?
- C# 微信上传Form-data
- TypeScript-命名空间
- Data visualization and Matplotlib
- DAMENG 用户管理
猜你喜欢

Printing diamond of beginner C

forEach 中 return 和 for 中 break

How to prepare for the new PMP syllabus exam?

C language - Growth Diary -03- function definition and function prototype declaration

C language - Growth Diary -01- count primes and sum

Image data enhancement (translation, rotation, brightness transformation, flipping, adding Gaussian noise, scaling, cropping)

Collation of basic knowledge of intermediate development of Andrews (for interview)

C- print 99 multiplication table

【案例解读】医疗单据OCR识别助力健康险智能理赔
![[the most complete ENSP [installation diagram] in history!]](/img/1a/7d50d6e5c06a5e3ce6acab16ddb638.jpg)
[the most complete ENSP [installation diagram] in history!]
随机推荐
Zero foundation self-study SQL course | union joint query
[transfer] two-way merging and sorting of C language
C language to achieve three piece chess (not artificial mental retardation ha ha ha)
【AtCoder2387】+/- Rectangle
TypeScript-可辨识联合
JSP development model
Black Qunhui dsm7.0.1 physical machine installation tutorial
Remote office experience | community essay solicitation
Activity中,View#postDelay会导致内存泄漏,但是不会影响Activity的生命周期执行。
Logical implication of functional dependence
图数据库无缝集成Tushare接口
Magnifying mirror rendering
通过ComponentCallbacks2来接收onTrimMemory等回调,并mock对应的场景
Long dialogue in June 2017
排序——选择排序
2022.6.6 extra long growth simulation
Closure and minimum dependency in database
YUV数据的裁剪与重叠
How to start participating in the open source community
[IOT] intelligent hardware: how to obtain the WiFi signal strength of hardware products