/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @summary unit tests for method handles which permute their arguments
* @run junit/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies -ea -esa -DPermuteArgsTest.MAX_ARITY=8 test.java.lang.invoke.PermuteArgsTest
*/
/* Examples of manual runs:
* java -DPermuteArgsTest.{DRY_RUN=true,MAX_ARITY=253} test.java.lang.invoke.PermuteArgsTest
* java -DPermuteArgsTest.{VERBOSE=true,MAX_ARITY=5} test.java.lang.invoke.PermuteArgsTest
* java test.java.lang.invoke.PermuteArgsTest list3I[2,0,1] listJLJ[2,0,1]
*/
public class PermuteArgsTest {
private static final boolean VERBOSE = Boolean.getBoolean(CLASS.getSimpleName()+".VERBOSE") || DRY_RUN;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
return res;
}
return res;
}
// arg ::= name[n,...]
}
return;
}
new PermuteArgsTest().test();
}
static int testCases;
@Test
testCases = 0;
}
}
}
// jump faster
else
i = max-1;
}
return i;
}
if (VERBOSE)
int testCases0 = testCases;
if (!mh.isVarargsCollector()) {
// normal case
} else {
// varargs case; add params up to MAX_ARITY
try {
} catch (IllegalArgumentException ex) {
break; // cannot get this arity for this type
}
}
}
if (VERBOSE)
}
// repeat types cyclically if possible:
}
try {
}
}
if (mh.isVarargsCollector()) {
return mh;
}
}
}
}
int testCases0 = testCases;
for (int j = 0; j <= 1; j++) {
//System.out.println("testPermutations"+Arrays.asList(start, end)+(j == 0 ? "" : " (reverse)"));
}
}
}
// do everything in reverse:
}
}
}
static void testPermutations(MethodHandle mh, int[] perm, int start, int end, Set<String> done) throws Throwable {
for (int j = 0; j <= 1; j++) {
}
// composed rotations:
for (int j = 0; j <= 1; j++) {
}
}
}
static void testRotations(MethodHandle mh, int[] perm, int start, int end, Set<String> done) throws Throwable {
}
}
MethodType pmt = methodType(mt.returnType(), unpermuteArgs(perm, mt.parameterArray(), Class[].class));
if (VERBOSE)
testCases += 1;
if (DRY_RUN)
return;
}
}
// For reproducing failures:
String s = permString;
s = s.trim();
int arity = 0;
while (!s.isEmpty()) {
int k = s.indexOf(' ');
if (k < 0) k = s.length();
}
}
}
}
return args;
}
for (int i = 0; i < len; i++)
perm[i] = i;
return perm;
}
}
}
}
}
int k = (end-1) - j;
}
}
// Permute the args according to the inverse of perm.
}
return res;
}
}