Bug 471023 - Exception when adapting a golo closure to a Java8 functional interface: back from the future
Summary: Exception when adapting a golo closure to a Java8 functional interface: back ...
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Golo (show other bugs)
Version: unspecified   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL: https://github.com/golo-lang/golo-lan...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-25 11:08 EDT by Thierry Chantier CLA
Modified: 2016-05-25 10:27 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thierry Chantier CLA 2015-06-25 11:08:44 EDT
Related to https://github.com/golo-lang/golo-lang/issues/277, but more subtle...

 [1..6]: stream(): map(|v| -> v + 1)

vs.

let a = 1
 [1..6]: stream(): map(|v| -> v + a)

The second sample raises a IllegalArgumentException: not a direct method handle.
Here the handle is a “real” closure, i.e. it captures values. Thus, it's no more a DirectMethodHandle, since an adaptation is done to close the value, but a BoundMethodHandle$Species_LL, that can't apparently be used as a handle for metafactory.

See http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8020816 for a similar bug.
Comment 1 Thierry Chantier CLA 2015-06-25 11:09:19 EDT
yloiseau commented 21 days ago

Note that explicitly converting the closure fix the problem:

let a = 1
[1..6]: stream(): map(asFunctionalInterface(Function.class, |v| -> v + a)) # ok
[1..6]: stream(): map(asInterfaceInstance(Function.class, |v| -> v + a)) # ok

so we can say it's a Golo feature (explicit over implicit :wink:)