test/compiler/EscapeAnalysis/Test8020215.java

Wed, 20 May 2015 09:07:36 -0400

author
skovalev
date
Wed, 20 May 2015 09:07:36 -0400
changeset 7871
3820a7d64760
parent 0
f90c822e73f8
permissions
-rw-r--r--

8078834: [TESTBUG] Tests fails on ARM64 due to unknown hardware
Reviewed-by: dholmes, adinn

     1 /*
     2  * Copyright (c) 2013, 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  */
    24 /*
    25  * @test
    26  * @bug 8020215
    27  * @summary Different execution plan when using JIT vs interpreter
    28  * @run main Test8020215
    29  */
    31 import java.util.ArrayList;
    32 import java.util.List;
    34 public class Test8020215 {
    35     public static class NamedObject {
    36         public int id;
    37         public String name;
    38         public NamedObject(int id, String name) {
    39             this.id = id;
    40             this.name = name;
    41         }
    42     }
    44     public static class NamedObjectList {
    45         public List<NamedObject> namedObjectList = new ArrayList<NamedObject>();
    47         public NamedObject getBest(int id) {
    48             NamedObject bestObject = null;
    49             for (NamedObject o : namedObjectList) {
    50                 bestObject = id==o.id ? getBetter(bestObject, o) : bestObject;
    51             }
    52             return (bestObject != null) ? bestObject : null;
    53         }
    55         private static NamedObject getBetter(NamedObject p1, NamedObject p2) {
    56             return (p1 == null) ? p2 : (p2 == null) ? p1 : (p2.name.compareTo(p1.name) >= 0) ? p2 : p1;
    57         }
    58     }
    60     static void test(NamedObjectList b, int i) {
    61         NamedObject x = b.getBest(2);
    62         // test
    63         if (x == null) {
    64             throw new RuntimeException("x should never be null here! (i=" + i + ")");
    65         }
    66     }
    68     public static void main(String[] args) {
    69         // setup
    70         NamedObjectList b = new NamedObjectList();
    71         for (int i = 0; i < 10000; i++) {
    72             b.namedObjectList.add(new NamedObject(1, "2012-12-31"));
    73         }
    74         b.namedObjectList.add(new NamedObject(2, "2013-12-31"));
    76         // execution
    77         for (int i = 0; i < 12000; i++) {
    78             test(b, i);
    79         }
    80         System.out.println("PASSED");
    81     }
    82 }

mercurial