Skip to content

headius/invokebinder

Folders and files

NameName
Last commit message
Last commit date
Mar 16, 2023
Sep 27, 2016
Apr 2, 2024
Mar 16, 2015
Oct 22, 2020
Mar 21, 2011
Jan 21, 2012
Sep 27, 2016
Mar 21, 2011
Mar 21, 2011
Mar 21, 2011
Apr 2, 2024

Repository files navigation

Introduction

This library hopes to provide a more friendly DSL for binding method handles. Unlike the normal MethodHandle API, handles are bound forward from a source MethodType and eventually adapted to a final target MethodHandle. Along the way the transformations are pushed onto a stack and eventually applied in reverse order, as the standard API demands.

Examples

Transformation calls can be chained. They are not applied until an eventual "invoke" is called with the target endpoint MethodHandle.

MethodHandle mh = Binder
   .from(String.class, String.class, String.class) // String w(String, String)
   .drop(1, String.class) // String x(String)
   .insert(0, 'hello') // String y(String, String)
   .cast(String.class, CharSequence.class, Object.class) // String z(CharSequence, Object)
   .invoke(someTargetHandle);

Status

This is currently under development. Not all transformations from the MethodHandle API are yet supported.

Contributors are welcome :)

About

A Java DSL for binding method handles forward, rather than backward

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages