spotify / missinglink

Build time tool for detecting link problems in java projects
Apache License 2.0
146 stars 27 forks source link

add VarHandle to HotSpotIntrinsicCandidate blacklist #176

Closed mattnworb closed 3 years ago

mattnworb commented 3 years ago

If the current version of missinglink scans classes which call java.lang.invoke.VarHandle methods, it will generate false warnings since the methods of VarHandle are annotated with `

example from the popular Caffeine library with missinglink:0.2.3

[WARNING]     In class: com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueue
[WARNING]       In method:  soProducerLimit(com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueue, long):584
[WARNING]       Call to: java.lang.invoke.VarHandle.setRelease(com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueue, long)
[WARNING]       Problem: Method not found: java.lang.invoke.VarHandle.setRelease(com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueue, long)
[WARNING]       Found in: java.base
[WARNING]       --------
[WARNING]       In method:  lvConsumerIndex(com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueue):569
[WARNING]       Call to: java.lang.invoke.VarHandle.getVolatile(com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueue)
[WARNING]       Problem: Method not found: java.lang.invoke.VarHandle.getVolatile(com.github.benmanes.caffeine.cache.BaseMpscLinkedArrayQueue)
[WARNING]       Found in: java.base

There is already a blacklist of classes to ignore here:

https://github.com/spotify/missinglink/blob/c6cb55438d6c1cd25a4192e54e647beddef729ea/core/src/main/java/com/spotify/missinglink/ClassLoader.java#L79-L83

but perhaps we should also consider skipping any method annotated with @HotSpotIntrinsicCandidate