--- old/test/java/lang/invoke/JavaDocExamplesTest.java 2016-03-22 13:02:10.700560681 +0300 +++ new/test/java/lang/invoke/JavaDocExamplesTest.java 2016-03-22 13:02:10.414560416 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,7 +57,9 @@ testFindVirtual(); testFindSpecial(); testPermuteArguments(); + testZero(); testDropArguments(); + testDropArgumentsToMatch(); testFilterArguments(); testFoldArguments(); testFoldArguments2(); @@ -235,6 +237,17 @@ }} } +@Test public void testZero() throws Throwable { + {{ +{} /// JAVADOC +Class type = Double.class; +MethodHandle mh1 = MethodHandles.explicitCastArguments(MethodHandles.constant(Object.class, null), methodType(type)); +assertEquals("()Double", mh1.type().toString()); +MethodHandle mh2 = MethodHandles.empty(methodType(type)); +assertEquals("()Double", mh2.type().toString()); + }} + } + @Test public void testDropArguments() throws Throwable { {{ {} /// JAVADOC @@ -262,6 +275,24 @@ }} } + @Test public void testDropArgumentsToMatch() throws Throwable { + {{ +{} /// JAVADOC +MethodHandle h0= constant(boolean.class, true); +MethodHandle h1 = lookup().findVirtual(String.class, "concat", methodType(String.class, String.class)); +MethodType bigType = h1.type().insertParameterTypes(1, String.class, int.class); +MethodHandle h2 = dropArguments(h1, 0, bigType.parameterList()); +if (h1.type().parameterCount() < h2.type().parameterCount()) { + h1 = dropArgumentsToMatch(h1, 0, h2.type().parameterList(), 0); // lengthen h1 +} +else { + h2 = dropArgumentsToMatch(h2, 0, h1.type().parameterList(), 0); // lengthen h2 +} +MethodHandle h3 = guardWithTest(h0, h1, h2); +assertEquals("xy", h3.invoke("x", "y", 1, "a", "b", "c")); + }} + } + @Test public void testFilterArguments() throws Throwable { {{ {} /// JAVADOC