< prev index next >
test/jdk/java/lang/invoke/condy/BootstrapMethodJumboArgsTest.java
Print this page
rev 52749 : Bootstrap method consolidation
* clean up and simplify JDK support code for BSM invocation
* simplify JVM bootstrap handshake: use BootstrapCallInfo only
* remove unused JVM paths and data fields
* move bootstrap argument processing from MethodHandleNatives to ConstantPool
* remove ConstantGroup; merge argument access into BootstrapCallInfo
* adjust BSM argument access: remove copyArguments, add argumentRef API
* add metadata-free BSM modes, including symbolic arguments from CP
*** 26,36 ****
* @bug 8186046
* @summary Test bootstrap methods throwing an exception
* @library /lib/testlibrary/bytecode /java/lang/invoke/common
* @build jdk.experimental.bytecode.BasicClassBuilder test.java.lang.invoke.lib.InstructionHelper
* @run testng BootstrapMethodJumboArgsTest
- * @run testng/othervm -XX:+UnlockDiagnosticVMOptions -XX:UseBootstrapCallInfo=3 BootstrapMethodJumboArgsTest
*/
import jdk.experimental.bytecode.PoolHelper;
import org.testng.Assert;
import org.testng.annotations.Test;
--- 26,35 ----
*** 84,93 ****
--- 83,103 ----
else {
return a;
}
}
+ // Expression-mode versions of bsm*
+ static Object bsmZeroExpr(Object... args) {
+ return bsmZero(null, null, null, args);
+ }
+ static Object bsmOneExpr(Object first, Object... args) {
+ return bsmOne(null, null, null, first, args);
+ }
+ static Object bsmTwoExpr(Object first, Object second, Object... args) {
+ return bsmTwo(null, null, null, first, second, args);
+ }
+
static void manyStaticStrings(String[] args, PoolHelper.StaticArgListBuilder<String, String, byte[]> staticArgs) {
for (String s : args) {
staticArgs.add(s);
}
}
*** 126,135 ****
--- 136,180 ----
Assert.assertEquals(actual, expected);
}
}
@Test
+ public void testCondyWithJumboArgsWithoutMetaData() throws Throwable {
+ String[] expected = IntStream.range(0, 1000).mapToObj(Integer::toString).toArray(String[]::new);
+
+ {
+ MethodHandle mh = InstructionHelper.ldcDynamicConstant(
+ L, "invoke", Object[].class,
+ "bsmZeroExpr", methodType(Object.class, Object[].class),
+ S -> manyStaticStrings(expected, S));
+
+ Object[] actual = (Object[]) mh.invoke();
+ Assert.assertEquals(actual, expected);
+ }
+
+ {
+ MethodHandle mh = InstructionHelper.ldcDynamicConstant(
+ L, "invoke", Object[].class,
+ "bsmOneExpr", methodType(Object.class, Object.class, Object[].class),
+ S -> manyStaticStrings(expected, S));
+
+ Object[] actual = (Object[]) mh.invoke();
+ Assert.assertEquals(actual, expected);
+ }
+
+ {
+ MethodHandle mh = InstructionHelper.ldcDynamicConstant(
+ L, "invoke", Object[].class,
+ "bsmTwoExpr", methodType(Object.class, Object.class, Object.class, Object[].class),
+ S -> manyStaticStrings(expected, S));
+
+ Object[] actual = (Object[]) mh.invoke();
+ Assert.assertEquals(actual, expected);
+ }
+ }
+
+ @Test
public void testIndyWithJumboArgs() throws Throwable {
String[] expected = IntStream.range(0, 1000).mapToObj(Integer::toString).toArray(String[]::new);
{
MethodHandle mh = InstructionHelper.invokedynamic(
< prev index next >