JDK-8068903 : Can't invoke vararg @FunctionalInterface methods
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: jdk.nashorn
  • Affected Version: 9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2015-01-13
  • Updated: 2016-01-14
  • Resolved: 2015-09-01
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8 JDK 9
8u72Fixed 9 b81Fixed
Related Reports
Relates :  
Description
Given this test interface:

package jdk.nashorn.test.models;

@FunctionalInterface
public interface VarArgConsumer {
    public void apply(Object... o);
}

This won't work:

var c = new (Java.type("jdk.nashorn.test.models.VarArgConsumer"))(
    function() { print(arguments.length) });
c(1, 2, 3)

A solution would be to rely on Dynalink's DynamicMethod instead of reflective Method.
Comments
Yes, this is an issue. But the function can't use arguments to access args passed - because it is passed as Java Object[]. That is the case when explicitly calling "apply" method (as an interface method) as well. i.e., that part has to be (if we want..) handled as Java adapter change. For the current issue, we just need to make sure the object can be invoked as a function even if it has vararg SAM.
01-09-2015

Using DynamicMethod would likely also (since they're specific to the exact receiver class) solve JDK-8068901.
13-01-2015