test/compiler/6987555/Test6987555.java

changeset 2678
b868d9928221
parent 2677
151da0c145a8
parent 2666
0a5d9566b8a4
child 2679
f731b22cd52d
child 2680
322a41ec766c
     1.1 --- a/test/compiler/6987555/Test6987555.java	Thu Mar 24 02:11:50 2011 -0700
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,177 +0,0 @@
     1.4 -/*
     1.5 - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
     1.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 - *
     1.8 - * This code is free software; you can redistribute it and/or modify it
     1.9 - * under the terms of the GNU General Public License version 2 only, as
    1.10 - * published by the Free Software Foundation.
    1.11 - *
    1.12 - * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 - * version 2 for more details (a copy is included in the LICENSE file that
    1.16 - * accompanied this code).
    1.17 - *
    1.18 - * You should have received a copy of the GNU General Public License version
    1.19 - * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 - *
    1.22 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 - * or visit www.oracle.com if you need additional information or have any
    1.24 - * questions.
    1.25 - *
    1.26 - */
    1.27 -
    1.28 -/**
    1.29 - * @test
    1.30 - * @bug 6987555
    1.31 - * @summary JSR 292 unboxing to a boolean value fails on big-endian SPARC
    1.32 - *
    1.33 - * @run main/othervm -Xint -ea -XX:+UnlockExperimentalVMOptions -XX:+EnableMethodHandles -XX:+EnableInvokeDynamic -XX:+UnlockDiagnosticVMOptions -XX:+VerifyMethodHandles Test6987555
    1.34 - */
    1.35 -
    1.36 -import java.dyn.*;
    1.37 -
    1.38 -public class Test6987555 {
    1.39 -    private static final Class   CLASS = Test6987555.class;
    1.40 -    private static final String  NAME  = "foo";
    1.41 -    private static final boolean DEBUG = false;
    1.42 -
    1.43 -    public static void main(String[] args) throws Throwable {
    1.44 -        testboolean();
    1.45 -        testbyte();
    1.46 -        testchar();
    1.47 -        testshort();
    1.48 -        testint();
    1.49 -    }
    1.50 -
    1.51 -    // boolean
    1.52 -    static void testboolean() throws Throwable {
    1.53 -        doboolean(false);
    1.54 -        doboolean(true);
    1.55 -    }
    1.56 -    static void doboolean(boolean x) throws Throwable {
    1.57 -        if (DEBUG)  System.out.println("boolean=" + x);
    1.58 -        MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(boolean.class, boolean.class));
    1.59 -        MethodHandle mh2 = mh1.asType(MethodType.methodType(boolean.class, Boolean.class));
    1.60 -        boolean a = (boolean) mh1.invokeExact(x);
    1.61 -        boolean b = (boolean) mh2.invokeExact(Boolean.valueOf(x));
    1.62 -        assert a == b : a + " != " + b;
    1.63 -    }
    1.64 -
    1.65 -    // byte
    1.66 -    static void testbyte() throws Throwable {
    1.67 -        byte[] a = new byte[] {
    1.68 -            Byte.MIN_VALUE,
    1.69 -            Byte.MIN_VALUE + 1,
    1.70 -            -0x0F,
    1.71 -            -1,
    1.72 -            0,
    1.73 -            1,
    1.74 -            0x0F,
    1.75 -            Byte.MAX_VALUE - 1,
    1.76 -            Byte.MAX_VALUE
    1.77 -        };
    1.78 -        for (int i = 0; i < a.length; i++) {
    1.79 -            dobyte(a[i]);
    1.80 -        }
    1.81 -    }
    1.82 -    static void dobyte(byte x) throws Throwable {
    1.83 -        if (DEBUG)  System.out.println("byte=" + x);
    1.84 -        MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(byte.class, byte.class));
    1.85 -        MethodHandle mh2 = mh1.asType(MethodType.methodType(byte.class, Byte.class));
    1.86 -        byte a = (byte) mh1.invokeExact(x);
    1.87 -        byte b = (byte) mh2.invokeExact(Byte.valueOf(x));
    1.88 -        assert a == b : a + " != " + b;
    1.89 -    }
    1.90 -
    1.91 -    // char
    1.92 -    static void testchar() throws Throwable {
    1.93 -        char[] a = new char[] {
    1.94 -            Character.MIN_VALUE,
    1.95 -            Character.MIN_VALUE + 1,
    1.96 -            0x000F,
    1.97 -            0x00FF,
    1.98 -            0x0FFF,
    1.99 -            Character.MAX_VALUE - 1,
   1.100 -            Character.MAX_VALUE
   1.101 -        };
   1.102 -        for (int i = 0; i < a.length; i++) {
   1.103 -            dochar(a[i]);
   1.104 -        }
   1.105 -    }
   1.106 -    static void dochar(char x) throws Throwable {
   1.107 -        if (DEBUG)  System.out.println("char=" + x);
   1.108 -        MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(char.class, char.class));
   1.109 -        MethodHandle mh2 = mh1.asType(MethodType.methodType(char.class, Character.class));
   1.110 -        char a = (char) mh1.invokeExact(x);
   1.111 -        char b = (char) mh2.invokeExact(Character.valueOf(x));
   1.112 -        assert a == b : a + " != " + b;
   1.113 -    }
   1.114 -
   1.115 -    // short
   1.116 -    static void testshort() throws Throwable {
   1.117 -        short[] a = new short[] {
   1.118 -            Short.MIN_VALUE,
   1.119 -            Short.MIN_VALUE + 1,
   1.120 -            -0x0FFF,
   1.121 -            -0x00FF,
   1.122 -            -0x000F,
   1.123 -            -1,
   1.124 -            0,
   1.125 -            1,
   1.126 -            0x000F,
   1.127 -            0x00FF,
   1.128 -            0x0FFF,
   1.129 -            Short.MAX_VALUE - 1,
   1.130 -            Short.MAX_VALUE
   1.131 -        };
   1.132 -        for (int i = 0; i < a.length; i++) {
   1.133 -            doshort(a[i]);
   1.134 -        }
   1.135 -    }
   1.136 -    static void doshort(short x) throws Throwable {
   1.137 -        if (DEBUG)  System.out.println("short=" + x);
   1.138 -        MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(short.class, short.class));
   1.139 -        MethodHandle mh2 = mh1.asType(MethodType.methodType(short.class, Short.class));
   1.140 -        short a = (short) mh1.invokeExact(x);
   1.141 -        short b = (short) mh2.invokeExact(Short.valueOf(x));
   1.142 -        assert a == b : a + " != " + b;
   1.143 -    }
   1.144 -
   1.145 -    // int
   1.146 -    static void testint() throws Throwable {
   1.147 -        int[] a = new int[] {
   1.148 -            Integer.MIN_VALUE,
   1.149 -            Integer.MIN_VALUE + 1,
   1.150 -            -0x00000FFF,
   1.151 -            -0x000000FF,
   1.152 -            -0x0000000F,
   1.153 -            -1,
   1.154 -            0,
   1.155 -            1,
   1.156 -            0x0000000F,
   1.157 -            0x000000FF,
   1.158 -            0x00000FFF,
   1.159 -            Integer.MAX_VALUE - 1,
   1.160 -            Integer.MAX_VALUE
   1.161 -        };
   1.162 -        for (int i = 0; i < a.length; i++) {
   1.163 -            doint(a[i]);
   1.164 -        }
   1.165 -    }
   1.166 -    static void doint(int x) throws Throwable {
   1.167 -        if (DEBUG)  System.out.println("int=" + x);
   1.168 -        MethodHandle mh1 = MethodHandles.lookup().findStatic(CLASS, NAME, MethodType.methodType(int.class, int.class));
   1.169 -        MethodHandle mh2 = mh1.asType(MethodType.methodType(int.class, Integer.class));
   1.170 -        int a = (int) mh1.invokeExact(x);
   1.171 -        int b = (int) mh2.invokeExact(Integer.valueOf(x));
   1.172 -        assert a == b : a + " != " + b;
   1.173 -    }
   1.174 -
   1.175 -    public static boolean foo(boolean i) { return i; }
   1.176 -    public static byte    foo(byte    i) { return i; }
   1.177 -    public static char    foo(char    i) { return i; }
   1.178 -    public static short   foo(short   i) { return i; }
   1.179 -    public static int     foo(int     i) { return i; }
   1.180 -}

mercurial