hotspot/test/compiler/5057225/Test5057225.java
author trims
Thu, 27 May 2010 19:08:38 -0700
changeset 5547 f4b087cbb361
parent 3177 f467776fc753
permissions -rw-r--r--
6941466: Oracle rebranding changes for Hotspot repositories Summary: Change all the Sun copyrights to Oracle copyright Reviewed-by: ohair
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3177
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
     1
/*
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3177
diff changeset
     2
 * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
3177
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
     4
 *
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
     7
 * published by the Free Software Foundation.
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
     8
 *
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    13
 * accompanied this code).
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    14
 *
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3177
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3177
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3177
diff changeset
    21
 * questions.
3177
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    22
 */
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    23
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    24
/**
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    25
 * @test
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    26
 * @bug 5057225
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    27
 * @summary Remove useless I2L conversions
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    28
 *
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    29
 * @run main/othervm -Xcomp -XX:CompileOnly=Test5057225.doload Test5057225
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    30
 */
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    31
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    32
import java.net.URLClassLoader;
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    33
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    34
public class Test5057225 {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    35
    static byte[]  ba = new byte[]  { -1 };
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    36
    static short[] sa = new short[] { -1 };
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    37
    static int[]   ia = new int[]   { -1 };
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    38
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    39
    static final long[] BYTE_MASKS = {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    40
         0x0FL,
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    41
         0x7FL,  // 7-bit
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    42
         0xFFL,
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    43
    };
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    44
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    45
    static final long[] SHORT_MASKS = {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    46
        0x000FL,
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    47
        0x007FL,  // 7-bit
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    48
        0x00FFL,
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    49
        0x0FFFL,
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    50
        0x3FFFL,  // 14-bit
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    51
        0x7FFFL,  // 15-bit
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    52
        0xFFFFL,
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    53
    };
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    54
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    55
    static final long[] INT_MASKS = {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    56
        0x0000000FL,
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    57
        0x0000007FL,  // 7-bit
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    58
        0x000000FFL,
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    59
        0x00000FFFL,
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    60
        0x00003FFFL,  // 14-bit
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    61
        0x00007FFFL,  // 15-bit
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    62
        0x0000FFFFL,
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    63
        0x00FFFFFFL,
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    64
        0x7FFFFFFFL,  // 31-bit
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    65
        0xFFFFFFFFL,
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    66
    };
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    67
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    68
    public static void main(String[] args) throws Exception {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    69
        for (int i = 0; i < BYTE_MASKS.length; i++) {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    70
            System.setProperty("value", "" + BYTE_MASKS[i]);
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    71
            loadAndRunClass("Test5057225$loadUB2L");
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    72
        }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    73
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    74
        for (int i = 0; i < SHORT_MASKS.length; i++) {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    75
            System.setProperty("value", "" + SHORT_MASKS[i]);
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    76
            loadAndRunClass("Test5057225$loadUS2L");
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    77
        }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    78
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    79
        for (int i = 0; i < INT_MASKS.length; i++) {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    80
            System.setProperty("value", "" + INT_MASKS[i]);
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    81
            loadAndRunClass("Test5057225$loadUI2L");
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    82
        }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    83
    }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    84
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    85
    static void check(long result, long expected) {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    86
        if (result != expected)
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    87
            throw new InternalError(result + " != " + expected);
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    88
    }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    89
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    90
    static void loadAndRunClass(String classname) throws Exception {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    91
        Class cl = Class.forName(classname);
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    92
        URLClassLoader apploader = (URLClassLoader) cl.getClassLoader();
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    93
        ClassLoader loader = new URLClassLoader(apploader.getURLs(), apploader.getParent());
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    94
        Class c = loader.loadClass(classname);
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    95
        Runnable r = (Runnable) c.newInstance();
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    96
        r.run();
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    97
    }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    98
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
    99
    public static class loadUB2L implements Runnable {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   100
        static final long MASK;
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   101
        static {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   102
            long value = 0;
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   103
            try {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   104
                value = Long.decode(System.getProperty("value"));
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   105
            } catch (Throwable e) {}
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   106
            MASK = value;
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   107
        }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   108
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   109
        public void run() { check(doload(ba), MASK); }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   110
        static long doload(byte[] ba) { return ba[0] & MASK; }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   111
    }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   112
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   113
    public static class loadUS2L implements Runnable {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   114
        static final long MASK;
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   115
        static {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   116
            long value = 0;
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   117
            try {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   118
                value = Long.decode(System.getProperty("value"));
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   119
            } catch (Throwable e) {}
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   120
            MASK = value;
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   121
        }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   122
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   123
        public void run() { check(doload(sa), MASK); }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   124
        static long doload(short[] sa) { return sa[0] & MASK; }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   125
    }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   126
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   127
    public static class loadUI2L implements Runnable {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   128
        static final long MASK;
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   129
        static {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   130
            long value = 0;
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   131
            try {
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   132
                value = Long.decode(System.getProperty("value"));
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   133
            } catch (Throwable e) {}
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   134
            MASK = value;
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   135
        }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   136
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   137
        public void run() { check(doload(ia), MASK); }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   138
        static long doload(int[] ia) { return ia[0] & MASK; }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   139
    }
f467776fc753 5057225: Remove useless I2L conversions
twisti
parents:
diff changeset
   140
}