< prev index next >

test/java/lang/invoke/PermuteArgsTest.java

Print this page


   1 /*
   2  * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /* @test
  25  * @summary unit tests for method handles which permute their arguments
  26  * @library /lib/testlibrary/jsr292 /lib/testlibrary
  27  * @run testng/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies -ea -esa -DPermuteArgsTest.MAX_ARITY=8 test.java.lang.invoke.PermuteArgsTest
  28  */

  29 /* Examples of manual runs:
  30  * java -DPermuteArgsTest.{DRY_RUN=true,MAX_ARITY=253} test.java.lang.invoke.PermuteArgsTest
  31  * java -DPermuteArgsTest.{VERBOSE=true,MAX_ARITY=5} test.java.lang.invoke.PermuteArgsTest
  32  * java test.java.lang.invoke.PermuteArgsTest list3I[2,0,1] listJLJ[2,0,1]
  33  */
  34 
  35 package test.java.lang.invoke;
  36 
  37 import org.testng.*;
  38 import org.testng.annotations.*;
  39 
  40 import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
  41 
  42 import java.util.*;
  43 import java.lang.reflect.*;
  44 
  45 import java.lang.invoke.*;
  46 import static java.lang.invoke.MethodHandles.*;
  47 import static java.lang.invoke.MethodType.*;











  48 
  49 public class PermuteArgsTest {
  50     private static final Class<?> CLASS = PermuteArgsTest.class;
  51     private static final int MAX_ARITY = Integer.getInteger(CLASS.getSimpleName()+".MAX_ARITY", 8);
  52     private static final boolean DRY_RUN = Boolean.getBoolean(CLASS.getSimpleName()+".DRY_RUN");
  53     private static final boolean VERBOSE = Boolean.getBoolean(CLASS.getSimpleName()+".VERBOSE") || DRY_RUN;
  54 
  55     static Object list2I(int x, int y) {
  56         return Arrays.asList(x, y);
  57     }
  58     static Object list3I(int x, int y, int z) {
  59         return Arrays.asList(x, y, z);
  60     }
  61     static Object list4I(int w, int x, int y, int z) {
  62         return Arrays.asList(w, x, y, z);
  63     }
  64     static Object list2J(long x, long y) {
  65         return Arrays.asList(x, y);
  66     }
  67     static Object list3J(long x, long y, long z) {


   1 /*
   2  * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /* @test
  25  * @summary unit tests for method handles which permute their arguments
  26  * @library /lib/testlibrary /java/lang/invoke/common
  27  * @run testng/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies -ea -esa -DPermuteArgsTest.MAX_ARITY=8 test.java.lang.invoke.PermuteArgsTest
  28  */
  29 
  30 /* Examples of manual runs:
  31  * java -DPermuteArgsTest.{DRY_RUN=true,MAX_ARITY=253} test.java.lang.invoke.PermuteArgsTest
  32  * java -DPermuteArgsTest.{VERBOSE=true,MAX_ARITY=5} test.java.lang.invoke.PermuteArgsTest
  33  * java test.java.lang.invoke.PermuteArgsTest list3I[2,0,1] listJLJ[2,0,1]
  34  */
  35 
  36 package test.java.lang.invoke;
  37 
  38 import org.testng.annotations.Test;
  39 import test.java.lang.invoke.lib.CodeCacheOverflowProcessor;





  40 
  41 import java.lang.invoke.MethodHandle;
  42 import java.lang.invoke.MethodType;
  43 import java.lang.invoke.WrongMethodTypeException;
  44 import java.lang.reflect.Method;
  45 import java.lang.reflect.Modifier;
  46 import java.util.ArrayList;
  47 import java.util.Arrays;
  48 import java.util.HashSet;
  49 import java.util.Set;
  50 
  51 import static java.lang.invoke.MethodHandles.Lookup;
  52 import static java.lang.invoke.MethodHandles.lookup;
  53 import static java.lang.invoke.MethodHandles.permuteArguments;
  54 import static java.lang.invoke.MethodType.methodType;
  55 
  56 public class PermuteArgsTest {
  57     private static final Class<?> CLASS = PermuteArgsTest.class;
  58     private static final int MAX_ARITY = Integer.getInteger(CLASS.getSimpleName()+".MAX_ARITY", 8);
  59     private static final boolean DRY_RUN = Boolean.getBoolean(CLASS.getSimpleName()+".DRY_RUN");
  60     private static final boolean VERBOSE = Boolean.getBoolean(CLASS.getSimpleName()+".VERBOSE") || DRY_RUN;
  61 
  62     static Object list2I(int x, int y) {
  63         return Arrays.asList(x, y);
  64     }
  65     static Object list3I(int x, int y, int z) {
  66         return Arrays.asList(x, y, z);
  67     }
  68     static Object list4I(int w, int x, int y, int z) {
  69         return Arrays.asList(w, x, y, z);
  70     }
  71     static Object list2J(long x, long y) {
  72         return Arrays.asList(x, y);
  73     }
  74     static Object list3J(long x, long y, long z) {


< prev index next >