Currently we link invocations of @FunctionalInterface methods with an "instanceof <declaring interface>" guard. This seems like a nice stable linkage but can produce weird behavior with classes that implement multiple functional interfaces. Currently, the functional method of the first functional interface of the latest-linked object will dominate earlier-linked ones in that call site. To illustrate:
var fc = new (Java.extend(java.util.function.Function, java.util.function.Consumer))({
apply: function(x) { print("fc invoked as a function") },
accept: function(x) { print("fc invoked as a consumer") }
});
var c = new java.util.function.Consumer(function(x) { print("c invoked as a consumer") });
for each(x in [fc, c, fc]) { x(null); }
prints:
fc invoked as a function
c invoked as a consumer
fc invoked as a consumer