Skip to content

Adding LambdaBlock DSL for Java 8 lambdas #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Adding LambdaBlock DSL for Java 8 lambdas #12

wants to merge 2 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jan 11, 2015

Hey @qmx! I've added a simple DSL block for generating lambdas more easily, mostly because I find the multiple invokedynamic arguments required for lambdas is tough to get my head around.

In a nutshell, lambdas require the following:

  • Functional interface type, method, and signature
  • Optional specialization of the functional interface method signature
  • The number and types of the arguments to capture off the stack
  • The method to delegate the lambda to

Using this information, the relevant invokedynamic instruction is created to delegate into the implementation method.

Caveats:
The lambda block test (JiteClassTest#testLambda) is only run on Java 8. The test method exits if not running Java 8. I've taken steps to ensure Java 8 isn't required when using jitescript by coding all JDK 8 class names as strings. Is there a better way to manage the test given the JDK version constraint? :S

Examples:

@qmx
Copy link
Owner

qmx commented Jan 14, 2015

wow, this is amazing @lmcgrath \o/

Will merge soon(ish), thanks!

@ghost
Copy link
Author

ghost commented Jan 14, 2015

Woohoo!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant