|
|
|
|
@ -151,10 +151,10 @@ Kotlin::
@@ -151,10 +151,10 @@ Kotlin::
|
|
|
|
|
---- |
|
|
|
|
====== |
|
|
|
|
|
|
|
|
|
As hinted above, binding a `MethodHandle` and registering the bound `MethodHandle` is also |
|
|
|
|
supported. This is likely to be more performant if both the target and all the arguments |
|
|
|
|
are bound. In that case no arguments are necessary in the SpEL expression, as the |
|
|
|
|
following example shows: |
|
|
|
|
As mentioned above, binding a `MethodHandle` and registering the bound `MethodHandle` is |
|
|
|
|
also supported. This is likely to be more performant if both the target and all the |
|
|
|
|
arguments are bound. In that case no arguments are necessary in the SpEL expression, as |
|
|
|
|
the following example shows: |
|
|
|
|
|
|
|
|
|
[tabs] |
|
|
|
|
====== |
|
|
|
|
@ -168,9 +168,10 @@ Java::
@@ -168,9 +168,10 @@ Java::
|
|
|
|
|
String template = "This is a %s message with %s words: <%s>"; |
|
|
|
|
Object varargs = new Object[] { "prerecorded", 3, "Oh Hello World!", "ignored" }; |
|
|
|
|
MethodHandle mh = MethodHandles.lookup().findVirtual(String.class, "formatted", |
|
|
|
|
MethodType.methodType(String.class, Object[].class)) |
|
|
|
|
MethodType.methodType(String.class, Object[].class)) |
|
|
|
|
.bindTo(template) |
|
|
|
|
.bindTo(varargs); //here we have to provide arguments in a single array binding |
|
|
|
|
// Here we have to provide the arguments in a single array binding: |
|
|
|
|
.bindTo(varargs); |
|
|
|
|
context.setVariable("message", mh); |
|
|
|
|
|
|
|
|
|
// evaluates to "This is a prerecorded message with 3 words: <Oh Hello World!>" |
|
|
|
|
@ -189,9 +190,10 @@ Kotlin::
@@ -189,9 +190,10 @@ Kotlin::
|
|
|
|
|
val varargs = arrayOf("prerecorded", 3, "Oh Hello World!", "ignored") |
|
|
|
|
|
|
|
|
|
val mh = MethodHandles.lookup().findVirtual(String::class.java, "formatted", |
|
|
|
|
MethodType.methodType(String::class.java, Array<Any>::class.java)) |
|
|
|
|
MethodType.methodType(String::class.java, Array<Any>::class.java)) |
|
|
|
|
.bindTo(template) |
|
|
|
|
.bindTo(varargs) //here we have to provide arguments in a single array binding |
|
|
|
|
// Here we have to provide the arguments in a single array binding: |
|
|
|
|
.bindTo(varargs) |
|
|
|
|
context.setVariable("message", mh) |
|
|
|
|
|
|
|
|
|
// evaluates to "This is a prerecorded message with 3 words: <Oh Hello World!>" |
|
|
|
|
|