< prev index next >

test/java/lang/invoke/ExplicitCastArgumentsTest.java

Print this page
rev 17241 : 8180890: move c.o.testlibrary.jsr292 classes to jdk/test/java/lang/invoke directory
Reviewed-by: duke
rev 17242 : [mq]: 8180890-1
   1 /*
   2  * Copyright (c) 2014, 2015, 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 import com.oracle.testlibrary.jsr292.Helper;


  25 import java.io.File;
  26 import java.io.Serializable;
  27 import java.lang.invoke.MethodHandle;
  28 import java.lang.invoke.MethodHandles;
  29 import java.lang.invoke.MethodType;
  30 import java.lang.invoke.WrongMethodTypeException;
  31 import java.util.HashMap;
  32 import java.util.Map;
  33 import java.util.Random;
  34 import sun.invoke.util.Wrapper;
  35 
  36 /*
  37  * @test
  38  * @bug 8060483 8066746
  39  * @key randomness
  40  * @library /lib/testlibrary /lib/testlibrary/jsr292
  41  * @modules java.base/sun.invoke.util
  42  * @summary unit tests for MethodHandles.explicitCastArguments()
  43  * @run main ExplicitCastArgumentsTest
  44  */
  45 
  46 /**
  47  * Tests for MethodHandles.explicitCastArguments().
  48  */
  49 public class ExplicitCastArgumentsTest {
  50 
  51     private static final boolean VERBOSE = Helper.IS_VERBOSE;
  52     private static final Class<?> THIS_CLASS = ExplicitCastArgumentsTest.class;
  53     private static final Random RNG = Helper.RNG;
  54     private static final Map<Wrapper, Object> RANDOM_VALUES = new HashMap<>(9);
  55 
  56     static {
  57         RANDOM_VALUES.put(Wrapper.BOOLEAN, RNG.nextBoolean());
  58         RANDOM_VALUES.put(Wrapper.BYTE, (byte) RNG.nextInt());
  59         RANDOM_VALUES.put(Wrapper.SHORT, (short) RNG.nextInt());
  60         RANDOM_VALUES.put(Wrapper.CHAR, (char) RNG.nextInt());


   1 /*
   2  * Copyright (c) 2014, 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 import sun.invoke.util.Wrapper;
  25 import test.java.lang.invoke.lib.Helper;
  26 
  27 import java.io.File;
  28 import java.io.Serializable;
  29 import java.lang.invoke.MethodHandle;
  30 import java.lang.invoke.MethodHandles;
  31 import java.lang.invoke.MethodType;
  32 import java.lang.invoke.WrongMethodTypeException;
  33 import java.util.HashMap;
  34 import java.util.Map;
  35 import java.util.Random;

  36 
  37 /*
  38  * @test
  39  * @bug 8060483 8066746
  40  * @key randomness
  41  * @library /lib/testlibrary /java/lang/invoke/common
  42  * @modules java.base/sun.invoke.util
  43  * @summary unit tests for MethodHandles.explicitCastArguments()
  44  * @run main ExplicitCastArgumentsTest
  45  */
  46 
  47 /**
  48  * Tests for MethodHandles.explicitCastArguments().
  49  */
  50 public class ExplicitCastArgumentsTest {
  51 
  52     private static final boolean VERBOSE = Helper.IS_VERBOSE;
  53     private static final Class<?> THIS_CLASS = ExplicitCastArgumentsTest.class;
  54     private static final Random RNG = Helper.RNG;
  55     private static final Map<Wrapper, Object> RANDOM_VALUES = new HashMap<>(9);
  56 
  57     static {
  58         RANDOM_VALUES.put(Wrapper.BOOLEAN, RNG.nextBoolean());
  59         RANDOM_VALUES.put(Wrapper.BYTE, (byte) RNG.nextInt());
  60         RANDOM_VALUES.put(Wrapper.SHORT, (short) RNG.nextInt());
  61         RANDOM_VALUES.put(Wrapper.CHAR, (char) RNG.nextInt());


< prev index next >