hotspot/test/compiler/exceptions/CatchInlineExceptions.java
author kvn
Tue, 21 Oct 2014 12:37:48 -0700
changeset 27415 42971a565f19
parent 27011 d8db57f7a955
child 40059 c2304140ed64
permissions -rw-r--r--
8061563: Typo in test/compiler/exceptions/CatchInlineExceptions.java Summary: fix typo Reviewed-by: iveresov
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27011
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
     1
/*
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
     4
 *
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
     7
 * published by the Free Software Foundation.
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
     8
 *
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    13
 * accompanied this code).
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    14
 *
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    18
 *
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    21
 * questions.
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    22
 */
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    23
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    24
/**
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    25
 * @test
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    26
 * @bug 8059299
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    27
 * @summary assert(adr_type != NULL) failed: expecting TypeKlassPtr
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    28
 * @run main/othervm -Xbatch CatchInlineExceptions
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    29
 */
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    30
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    31
class Exception1 extends Exception {};
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    32
class Exception2 extends Exception {};
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    33
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    34
public class CatchInlineExceptions {
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    35
    private static int counter0;
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    36
    private static int counter1;
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    37
    private static int counter2;
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    38
    private static int counter;
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    39
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    40
    static void foo(int i) throws Exception {
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    41
        if ((i & 1023) == 2) {
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    42
            counter0++;
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    43
            throw new Exception2();
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    44
        }
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    45
    }
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    46
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    47
    static void test(int i) throws Exception {
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    48
        try {
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    49
           foo(i);
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    50
        }
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    51
        catch (Exception e) {
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    52
            if (e instanceof Exception1) {
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    53
                counter1++;
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    54
            } else if (e instanceof Exception2) {
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    55
                counter2++;
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    56
            }
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    57
            counter++;
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    58
            throw e;
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    59
        }
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    60
    }
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    61
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    62
    public static void main(String[] args) throws Throwable {
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    63
        for (int i = 0; i < 15000; i++) {
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    64
            try {
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    65
                test(i);
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    66
            } catch (Exception e) {
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    67
                // expected
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    68
            }
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    69
        }
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    70
        if (counter1 != 0) {
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    71
            throw new RuntimeException("Failed: counter1(" + counter1  + ") != 0");
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    72
        }
27415
42971a565f19 8061563: Typo in test/compiler/exceptions/CatchInlineExceptions.java
kvn
parents: 27011
diff changeset
    73
        if (counter2 != counter0) {
27011
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    74
            throw new RuntimeException("Failed: counter2(" + counter2  + ") != counter0(" + counter0  + ")");
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    75
        }
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    76
        if (counter2 != counter) {
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    77
            throw new RuntimeException("Failed: counter2(" + counter2  + ") != counter(" + counter  + ")");
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    78
        }
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    79
        System.out.println("TEST PASSED");
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    80
    }
d8db57f7a955 8059299: assert(adr_type != NULL) failed: expecting TypeKlassPtr
kvn
parents:
diff changeset
    81
}