spotify / missinglink

Build time tool for detecting link problems in java projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

False error on a method with the polymorphic signature

plokhotnyuk opened this issue · comments

Got the following error when checking using the sbt-missinglink plugin:

[error] Category: Method being called not found
[error]   In artifact: scala-library-2.13.0.jar
[error]     In class: scala.runtime.Statics
[error]       In method:  releaseFence():148
[error]       Call to: java.lang.invoke.MethodHandle.invoke()
[error]       Problem: Method not found: java.lang.invoke.MethodHandle.invoke()
[error]       Found in: rt.jar
[error]       --------
[error] there were conflicts
[error] (jsoniter-scala-core / Compile / missinglinkCheck) there were conflicts

I tried looking at the caller:
https://github.com/scala/scala/blob/2.13.x/src/library/scala/runtime/Statics.java

And the target:
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/invoke/MethodHandle.html#invoke(java.lang.Object...)

The caller is doing:
VM.RELEASE_FENCE.invoke();
which should be compiled to the vararg method.

Running javap on the Statics class gives:

  public static void releaseFence() throws java.lang.Throwable;
    Code:
       0: getstatic     #25                 // Field scala/runtime/Statics$VM.RELEASE_FENCE:Ljava/lang/invoke/MethodHandle;
       3: invokevirtual #26                 // Method java/lang/invoke/MethodHandle.invoke:()V
       6: return

So yes, this seems like a bug.
I think the correct fix is that vararg methods should match calls that look like either:

  • java.lang.invoke.MethodHandle.invoke(Object[] args)
  • java.lang.invoke.MethodHandle.invoke()