hotspot/test/compiler/6832293/Test.java
author sundar
Mon, 15 Apr 2013 20:12:50 +0530
changeset 17224 e3481336d8f7
parent 5547 f4b087cbb361
permissions -rw-r--r--
8012240: Array.prototype.map.call({length: -1, get 0(){throw 0}}, function(){}).length does not throw error Reviewed-by: lagergren, jlaskey
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2870
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
     1
/*
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3261
diff changeset
     2
 * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
2870
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
     4
 *
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
     7
 * published by the Free Software Foundation.
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
     8
 *
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    13
 * accompanied this code).
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    14
 *
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3261
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 3261
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: 3261
diff changeset
    21
 * questions.
2870
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    22
 *
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    23
 */
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    24
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    25
/*
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    26
 * @test
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    27
 * @bug 6832293
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    28
 * @summary JIT compiler got wrong result in type checking with -server
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    29
 * @run main/othervm  -Xcomp -XX:CompileOnly=Test.run Test
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    30
 */
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    31
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    32
import java.io.PrintStream;
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    33
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    34
interface SomeInterface {
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    35
    int SEVENS = 777;
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    36
}
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    37
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    38
interface AnotherInterface {
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    39
    int THIRDS = 33;
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    40
}
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    41
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    42
class SomeClass implements SomeInterface {
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    43
    int i;
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    44
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    45
    SomeClass(int i) {
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    46
        this.i = i;
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    47
    }
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    48
}
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    49
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    50
class ImmediateSubclass extends SomeClass implements SomeInterface {
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    51
    float f;
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    52
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    53
    ImmediateSubclass(int i, float f) {
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    54
        super(i);
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    55
        this.f = f;
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    56
    }
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    57
}
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    58
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    59
final class FinalSubclass extends ImmediateSubclass implements AnotherInterface {
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    60
    double d;
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    61
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    62
     FinalSubclass(int i, float f, double d) {
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    63
        super(i, f);
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    64
        this.d = d;
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    65
    }
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    66
}
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    67
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    68
public class Test {
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    69
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    70
    public static void main(String args[]) throws Exception{
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    71
        /* try to pre initialize */
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    72
        SomeClass[] a=new SomeClass[10];
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    73
        Class.forName("ImmediateSubclass");
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    74
        Class.forName("FinalSubclass");
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    75
        System.exit(run(args, System.out) + 95/*STATUS_TEMP*/);
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    76
    }
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    77
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    78
    static int errorStatus = 0/*STATUS_PASSED*/;
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    79
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    80
    static void errorAlert(PrintStream out, int errorLevel) {
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    81
        out.println("Test: failure #" + errorLevel);
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    82
        errorStatus = 2/*STATUS_FAILED*/;
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    83
    }
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    84
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    85
    static SomeClass[] v2 = new FinalSubclass[4];
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    86
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    87
    public static int run(String args[],PrintStream out) {
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    88
        int i [], j [];
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    89
        SomeInterface u [], v[] [];
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    90
        AnotherInterface w [];
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    91
        SomeClass x [] [];
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    92
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    93
        i = new int [10];
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    94
        i[0] = 777;
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    95
        j = (int []) i;
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    96
        if (j != i)
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    97
            errorAlert(out, 2);
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    98
        else if (j.length != 10)
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
    99
            errorAlert(out, 3);
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   100
        else if (j[0] != 777)
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   101
            errorAlert(out, 4);
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   102
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   103
        v = new SomeClass [3] [];
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   104
        x = (SomeClass [] []) v;
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   105
        if (! (x instanceof SomeInterface [] []))
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   106
            errorAlert(out, 5);
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   107
        else if (! (x instanceof SomeClass [] []))
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   108
            errorAlert(out, 6);
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   109
        else if (x != v)
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   110
            errorAlert(out, 7);
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   111
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   112
        x[0] = (SomeClass []) new ImmediateSubclass [4];
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   113
        if (! (x[0] instanceof ImmediateSubclass []))
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   114
            errorAlert(out, 8);
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   115
        else if (x[0].length != 4)
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   116
            errorAlert(out, 9);
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   117
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   118
        x[1] = (SomeClass []) v2;
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   119
        if (! (x[1] instanceof FinalSubclass []))
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   120
            errorAlert(out, 10);
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   121
        else if (x[1].length != 4)
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   122
            errorAlert(out, 11);
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   123
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   124
        w = (AnotherInterface []) x[1];
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   125
        if (! (w instanceof FinalSubclass []))
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   126
            errorAlert(out, 12);
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   127
        else if (w != x[1])
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   128
            errorAlert(out, 13);
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   129
        else if (w.length != 4)
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   130
            errorAlert(out, 14);
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   131
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   132
        return errorStatus;
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   133
    }
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   134
}
52b70541d4d3 6832293: JIT compiler got wrong result in type checking with -server
kvn
parents:
diff changeset
   135