test/compiler/6663621/IVTest.java

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

     1 /*
     2  * Copyright (c) 1997, 2008, 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  */
    25 /**
    26  * @test
    27  * @bug 6663621
    28  * @summary JVM crashes while trying to execute api/java_security/Signature/SignatureTests.html#initSign tests.
    29  */
    31 public class IVTest {
    32     static int paddedSize;
    34     static void padV15(byte[] padded) {
    35         int psSize = padded.length;
    36         int k = 0;
    37         while (psSize-- > 0) {
    38             padded[k++] = (byte)0xff;
    39         }
    40     }
    42     static void padV15_2(int paddedSize) {
    43         byte[] padded = new byte[paddedSize];
    44         int psSize = padded.length;
    45         int k = 0;
    46         while (psSize-- > 0) {
    47             padded[k++] = (byte)0xff;
    48         }
    49     }
    51     static void padV15_3() {
    52         byte[] padded = new byte[paddedSize];
    53         int psSize = padded.length;
    54         int k = 0;
    55         while (psSize-- > 0) {
    56             padded[k++] = (byte)0xff;
    57         }
    58     }
    60     static void padV15_4() {
    61         byte[] padded = new byte[paddedSize];
    62         int psSize = padded.length;
    63         for (int k = 0;psSize > 0; psSize--) {
    64             int i = padded.length - psSize;
    65             padded[i] = (byte)0xff;
    66         }
    67     }
    69     static void padV15_5() {
    70         byte[] padded = new byte[paddedSize];
    71         int psSize = padded.length;
    72         int k = psSize - 1;
    73         for (int i = 0; i < psSize; i++) {
    74             padded[k--] = (byte)0xff;
    75         }
    76     }
    78     public static void main(String argv[]) {
    79         int bounds = 1024;
    80         int lim = 500000;
    81         long start = System.currentTimeMillis();
    82         for (int j = 0; j < lim; j++) {
    83             paddedSize = j % bounds;
    84             padV15(new byte[paddedSize]);
    85         }
    86         long end = System.currentTimeMillis();
    87         System.out.println(end - start);
    88         start = System.currentTimeMillis();
    89         for (int j = 0; j < lim; j++) {
    90             paddedSize = j % bounds;
    91             padV15_2(paddedSize);
    92         }
    93         end = System.currentTimeMillis();
    94         System.out.println(end - start);
    95         start = System.currentTimeMillis();
    96         for (int j = 0; j < lim; j++) {
    97             paddedSize = j % bounds;
    98             padV15_3();
    99         }
   100         end = System.currentTimeMillis();
   101         System.out.println(end - start);
   102         start = System.currentTimeMillis();
   103         for (int j = 0; j < lim; j++) {
   104             paddedSize = j % bounds;
   105             padV15_4();
   106         }
   107         end = System.currentTimeMillis();
   108         System.out.println(end - start);
   109         start = System.currentTimeMillis();
   110         for (int j = 0; j < lim; j++) {
   111             paddedSize = j % bounds;
   112             padV15_5();
   113         }
   114         end = System.currentTimeMillis();
   115         System.out.println(end - start);
   116     }
   117 }

mercurial