jdk/test/java/lang/Throwable/SuppressedExceptions.java
author katleman
Tue, 21 Jan 2014 18:17:07 -0800
changeset 22414 796c8cc1bc35
parent 17176 d7ee1e315fe7
permissions -rw-r--r--
Added tag jdk9-b01 for changeset 6428b06e538b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5972
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
     1
/*
17176
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
     2
 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
5972
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
     4
 *
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
     8
 *
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    13
 * accompanied this code).
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    14
 *
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    18
 *
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    21
 * questions.
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    22
 */
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    23
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    24
import java.io.*;
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    25
import java.util.*;
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    26
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    27
/*
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    28
 * @test
17176
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
    29
 * @bug     6911258 6962571 6963622 6991528 7005628 8012044
5972
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    30
 * @summary Basic tests of suppressed exceptions
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    31
 * @author  Joseph D. Darcy
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    32
 */
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    33
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    34
public class SuppressedExceptions {
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    35
    private static String message = "Bad suppressed exception information";
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    36
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    37
    public static void main(String... args) throws Exception {
6110
6db4b0180328 6963622: Project Coin: Refinements to suppressed exceptions
darcy
parents: 5972
diff changeset
    38
        noSelfSuppression();
5972
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    39
        basicSupressionTest();
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    40
        serializationTest();
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    41
        selfReference();
7186
7f5fe8985263 6991528: Support making Throwable.suppressedExceptions immutable
darcy
parents: 6110
diff changeset
    42
        noModification();
17176
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
    43
        initCausePlumbing();
5972
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    44
    }
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    45
6110
6db4b0180328 6963622: Project Coin: Refinements to suppressed exceptions
darcy
parents: 5972
diff changeset
    46
    private static void noSelfSuppression() {
6db4b0180328 6963622: Project Coin: Refinements to suppressed exceptions
darcy
parents: 5972
diff changeset
    47
        Throwable throwable = new Throwable();
6db4b0180328 6963622: Project Coin: Refinements to suppressed exceptions
darcy
parents: 5972
diff changeset
    48
        try {
7186
7f5fe8985263 6991528: Support making Throwable.suppressedExceptions immutable
darcy
parents: 6110
diff changeset
    49
            throwable.addSuppressed(throwable);
7f5fe8985263 6991528: Support making Throwable.suppressedExceptions immutable
darcy
parents: 6110
diff changeset
    50
            throw new RuntimeException("IllegalArgumentException for self-suppresion not thrown.");
7f5fe8985263 6991528: Support making Throwable.suppressedExceptions immutable
darcy
parents: 6110
diff changeset
    51
        } catch (IllegalArgumentException iae) {
17176
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
    52
            // Expected to be here
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
    53
            if (iae.getCause() != throwable)
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
    54
                throw new RuntimeException("Bad cause after self-suppresion.");
7186
7f5fe8985263 6991528: Support making Throwable.suppressedExceptions immutable
darcy
parents: 6110
diff changeset
    55
        }
6110
6db4b0180328 6963622: Project Coin: Refinements to suppressed exceptions
darcy
parents: 5972
diff changeset
    56
    }
6db4b0180328 6963622: Project Coin: Refinements to suppressed exceptions
darcy
parents: 5972
diff changeset
    57
5972
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    58
    private static void basicSupressionTest() {
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    59
        Throwable throwable = new Throwable();
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    60
        RuntimeException suppressed = new RuntimeException("A suppressed exception.");
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    61
        AssertionError repressed  = new AssertionError("A repressed error.");
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    62
7186
7f5fe8985263 6991528: Support making Throwable.suppressedExceptions immutable
darcy
parents: 6110
diff changeset
    63
        Throwable[] t0 = throwable.getSuppressed();
5972
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    64
        if (t0.length != 0) {
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    65
            throw new RuntimeException(message);
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    66
        }
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    67
        throwable.printStackTrace();
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    68
7186
7f5fe8985263 6991528: Support making Throwable.suppressedExceptions immutable
darcy
parents: 6110
diff changeset
    69
        throwable.addSuppressed(suppressed);
7f5fe8985263 6991528: Support making Throwable.suppressedExceptions immutable
darcy
parents: 6110
diff changeset
    70
        Throwable[] t1 = throwable.getSuppressed();
5972
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    71
        if (t1.length != 1 ||
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    72
            t1[0] != suppressed) {throw new RuntimeException(message);
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    73
        }
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    74
        throwable.printStackTrace();
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    75
7186
7f5fe8985263 6991528: Support making Throwable.suppressedExceptions immutable
darcy
parents: 6110
diff changeset
    76
        throwable.addSuppressed(repressed);
7f5fe8985263 6991528: Support making Throwable.suppressedExceptions immutable
darcy
parents: 6110
diff changeset
    77
        Throwable[] t2 = throwable.getSuppressed();
5972
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    78
        if (t2.length != 2 ||
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    79
            t2[0] != suppressed ||
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    80
            t2[1] != repressed) {
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    81
            throw new RuntimeException(message);
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    82
        }
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    83
        throwable.printStackTrace();
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    84
    }
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    85
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    86
    private static void serializationTest() throws Exception {
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    87
        /*
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    88
         * Bytes of the serial form of
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    89
         *
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    90
         * (new Throwable())setStackTrace(new StackTraceElement[0])
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    91
         *
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    92
         * from JDK 6; suppressedException field will be missing and
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    93
         * thus default to null upon deserialization.
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    94
         */
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    95
        byte[] bytes = {
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    96
            (byte)0xac, (byte)0xed, (byte)0x00, (byte)0x05, (byte)0x73, (byte)0x72, (byte)0x00, (byte)0x13,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    97
            (byte)0x6a, (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x2e, (byte)0x6c, (byte)0x61, (byte)0x6e,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    98
            (byte)0x67, (byte)0x2e, (byte)0x54, (byte)0x68, (byte)0x72, (byte)0x6f, (byte)0x77, (byte)0x61,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
    99
            (byte)0x62, (byte)0x6c, (byte)0x65, (byte)0xd5, (byte)0xc6, (byte)0x35, (byte)0x27, (byte)0x39,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   100
            (byte)0x77, (byte)0xb8, (byte)0xcb, (byte)0x03, (byte)0x00, (byte)0x03, (byte)0x4c, (byte)0x00,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   101
            (byte)0x05, (byte)0x63, (byte)0x61, (byte)0x75, (byte)0x73, (byte)0x65, (byte)0x74, (byte)0x00,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   102
            (byte)0x15, (byte)0x4c, (byte)0x6a, (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x2f, (byte)0x6c,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   103
            (byte)0x61, (byte)0x6e, (byte)0x67, (byte)0x2f, (byte)0x54, (byte)0x68, (byte)0x72, (byte)0x6f,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   104
            (byte)0x77, (byte)0x61, (byte)0x62, (byte)0x6c, (byte)0x65, (byte)0x3b, (byte)0x4c, (byte)0x00,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   105
            (byte)0x0d, (byte)0x64, (byte)0x65, (byte)0x74, (byte)0x61, (byte)0x69, (byte)0x6c, (byte)0x4d,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   106
            (byte)0x65, (byte)0x73, (byte)0x73, (byte)0x61, (byte)0x67, (byte)0x65, (byte)0x74, (byte)0x00,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   107
            (byte)0x12, (byte)0x4c, (byte)0x6a, (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x2f, (byte)0x6c,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   108
            (byte)0x61, (byte)0x6e, (byte)0x67, (byte)0x2f, (byte)0x53, (byte)0x74, (byte)0x72, (byte)0x69,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   109
            (byte)0x6e, (byte)0x67, (byte)0x3b, (byte)0x5b, (byte)0x00, (byte)0x0a, (byte)0x73, (byte)0x74,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   110
            (byte)0x61, (byte)0x63, (byte)0x6b, (byte)0x54, (byte)0x72, (byte)0x61, (byte)0x63, (byte)0x65,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   111
            (byte)0x74, (byte)0x00, (byte)0x1e, (byte)0x5b, (byte)0x4c, (byte)0x6a, (byte)0x61, (byte)0x76,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   112
            (byte)0x61, (byte)0x2f, (byte)0x6c, (byte)0x61, (byte)0x6e, (byte)0x67, (byte)0x2f, (byte)0x53,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   113
            (byte)0x74, (byte)0x61, (byte)0x63, (byte)0x6b, (byte)0x54, (byte)0x72, (byte)0x61, (byte)0x63,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   114
            (byte)0x65, (byte)0x45, (byte)0x6c, (byte)0x65, (byte)0x6d, (byte)0x65, (byte)0x6e, (byte)0x74,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   115
            (byte)0x3b, (byte)0x78, (byte)0x70, (byte)0x71, (byte)0x00, (byte)0x7e, (byte)0x00, (byte)0x04,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   116
            (byte)0x70, (byte)0x75, (byte)0x72, (byte)0x00, (byte)0x1e, (byte)0x5b, (byte)0x4c, (byte)0x6a,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   117
            (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x2e, (byte)0x6c, (byte)0x61, (byte)0x6e, (byte)0x67,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   118
            (byte)0x2e, (byte)0x53, (byte)0x74, (byte)0x61, (byte)0x63, (byte)0x6b, (byte)0x54, (byte)0x72,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   119
            (byte)0x61, (byte)0x63, (byte)0x65, (byte)0x45, (byte)0x6c, (byte)0x65, (byte)0x6d, (byte)0x65,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   120
            (byte)0x6e, (byte)0x74, (byte)0x3b, (byte)0x02, (byte)0x46, (byte)0x2a, (byte)0x3c, (byte)0x3c,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   121
            (byte)0xfd, (byte)0x22, (byte)0x39, (byte)0x02, (byte)0x00, (byte)0x00, (byte)0x78, (byte)0x70,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   122
            (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x78, (byte)0xac, (byte)0xed, (byte)0x00,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   123
            (byte)0x05, (byte)0x73, (byte)0x72, (byte)0x00, (byte)0x13, (byte)0x6a, (byte)0x61, (byte)0x76,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   124
            (byte)0x61, (byte)0x2e, (byte)0x6c, (byte)0x61, (byte)0x6e, (byte)0x67, (byte)0x2e, (byte)0x54,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   125
            (byte)0x68, (byte)0x72, (byte)0x6f, (byte)0x77, (byte)0x61, (byte)0x62, (byte)0x6c, (byte)0x65,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   126
            (byte)0xd5, (byte)0xc6, (byte)0x35, (byte)0x27, (byte)0x39, (byte)0x77, (byte)0xb8, (byte)0xcb,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   127
            (byte)0x03, (byte)0x00, (byte)0x03, (byte)0x4c, (byte)0x00, (byte)0x05, (byte)0x63, (byte)0x61,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   128
            (byte)0x75, (byte)0x73, (byte)0x65, (byte)0x74, (byte)0x00, (byte)0x15, (byte)0x4c, (byte)0x6a,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   129
            (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x2f, (byte)0x6c, (byte)0x61, (byte)0x6e, (byte)0x67,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   130
            (byte)0x2f, (byte)0x54, (byte)0x68, (byte)0x72, (byte)0x6f, (byte)0x77, (byte)0x61, (byte)0x62,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   131
            (byte)0x6c, (byte)0x65, (byte)0x3b, (byte)0x4c, (byte)0x00, (byte)0x0d, (byte)0x64, (byte)0x65,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   132
            (byte)0x74, (byte)0x61, (byte)0x69, (byte)0x6c, (byte)0x4d, (byte)0x65, (byte)0x73, (byte)0x73,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   133
            (byte)0x61, (byte)0x67, (byte)0x65, (byte)0x74, (byte)0x00, (byte)0x12, (byte)0x4c, (byte)0x6a,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   134
            (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x2f, (byte)0x6c, (byte)0x6e, (byte)0x67, (byte)0x3b,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   135
            (byte)0x61, (byte)0x6e, (byte)0x67, (byte)0x2f, (byte)0x53, (byte)0x74, (byte)0x72, (byte)0x69,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   136
            (byte)0x5b, (byte)0x00, (byte)0x0a, (byte)0x73, (byte)0x74, (byte)0x61, (byte)0x63, (byte)0x6b,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   137
            (byte)0x54, (byte)0x72, (byte)0x61, (byte)0x63, (byte)0x65, (byte)0x74, (byte)0x00, (byte)0x1e,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   138
            (byte)0x5b, (byte)0x4c, (byte)0x6a, (byte)0x61, (byte)0x76, (byte)0x61, (byte)0x2f, (byte)0x6c,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   139
            (byte)0x61, (byte)0x6e, (byte)0x67, (byte)0x2f, (byte)0x53, (byte)0x74, (byte)0x61, (byte)0x63,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   140
            (byte)0x6b, (byte)0x54, (byte)0x72, (byte)0x61, (byte)0x63, (byte)0x65, (byte)0x45, (byte)0x6c,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   141
            (byte)0x65, (byte)0x6d, (byte)0x65, (byte)0x6e, (byte)0x74, (byte)0x3b, (byte)0x78, (byte)0x70,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   142
            (byte)0x71, (byte)0x00, (byte)0x7e, (byte)0x00, (byte)0x04, (byte)0x70, (byte)0x75, (byte)0x72,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   143
            (byte)0x00, (byte)0x1e, (byte)0x5b, (byte)0x4c, (byte)0x6a, (byte)0x61, (byte)0x76, (byte)0x61,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   144
            (byte)0x2e, (byte)0x6c, (byte)0x61, (byte)0x6e, (byte)0x67, (byte)0x2e, (byte)0x53, (byte)0x74,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   145
            (byte)0x61, (byte)0x63, (byte)0x6b, (byte)0x54, (byte)0x72, (byte)0x61, (byte)0x63, (byte)0x65,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   146
            (byte)0x45, (byte)0x6c, (byte)0x65, (byte)0x6d, (byte)0x65, (byte)0x6e, (byte)0x74, (byte)0x3b,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   147
            (byte)0x02, (byte)0x46, (byte)0x2a, (byte)0x3c, (byte)0x3c, (byte)0xfd, (byte)0x22, (byte)0x39,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   148
            (byte)0x02, (byte)0x00, (byte)0x00, (byte)0x78, (byte)0x70,
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   149
        };
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   150
9020
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   151
        try(ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   152
            ObjectInputStream ois = new ObjectInputStream(bais)) {
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   153
            Object o = ois.readObject();
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   154
            Throwable throwable = (Throwable) o;
5972
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   155
9020
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   156
            System.err.println("TESTING SERIALIZED EXCEPTION");
5972
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   157
9020
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   158
            Throwable[] t0 = throwable.getSuppressed();
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   159
            if (t0.length != 0) { // Will fail if t0 is null.
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   160
                throw new RuntimeException(message);
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   161
            }
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   162
            throwable.printStackTrace();
5972
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   163
        }
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   164
    }
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   165
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   166
    private static void selfReference() {
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   167
        Throwable throwable1 = new RuntimeException();
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   168
        Throwable throwable2 = new AssertionError();
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   169
        throwable1.initCause(throwable2);
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   170
        throwable2.initCause(throwable1);
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   171
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   172
        throwable1.printStackTrace();
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   173
7186
7f5fe8985263 6991528: Support making Throwable.suppressedExceptions immutable
darcy
parents: 6110
diff changeset
   174
        throwable1.addSuppressed(throwable2);
7f5fe8985263 6991528: Support making Throwable.suppressedExceptions immutable
darcy
parents: 6110
diff changeset
   175
        throwable2.addSuppressed(throwable1);
5972
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   176
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   177
        throwable1.printStackTrace();
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   178
    }
7186
7f5fe8985263 6991528: Support making Throwable.suppressedExceptions immutable
darcy
parents: 6110
diff changeset
   179
7f5fe8985263 6991528: Support making Throwable.suppressedExceptions immutable
darcy
parents: 6110
diff changeset
   180
    private static void noModification() {
9020
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   181
        Throwable t = new NoSuppression(false);
7186
7f5fe8985263 6991528: Support making Throwable.suppressedExceptions immutable
darcy
parents: 6110
diff changeset
   182
7f5fe8985263 6991528: Support making Throwable.suppressedExceptions immutable
darcy
parents: 6110
diff changeset
   183
        Throwable[] t0 = t.getSuppressed();
7f5fe8985263 6991528: Support making Throwable.suppressedExceptions immutable
darcy
parents: 6110
diff changeset
   184
        if (t0.length != 0)
7f5fe8985263 6991528: Support making Throwable.suppressedExceptions immutable
darcy
parents: 6110
diff changeset
   185
            throw new RuntimeException("Bad nonzero length of suppressed exceptions.");
7f5fe8985263 6991528: Support making Throwable.suppressedExceptions immutable
darcy
parents: 6110
diff changeset
   186
7f5fe8985263 6991528: Support making Throwable.suppressedExceptions immutable
darcy
parents: 6110
diff changeset
   187
        t.addSuppressed(new ArithmeticException());
7f5fe8985263 6991528: Support making Throwable.suppressedExceptions immutable
darcy
parents: 6110
diff changeset
   188
7f5fe8985263 6991528: Support making Throwable.suppressedExceptions immutable
darcy
parents: 6110
diff changeset
   189
        // Make sure a suppressed exception did *not* get added.
7f5fe8985263 6991528: Support making Throwable.suppressedExceptions immutable
darcy
parents: 6110
diff changeset
   190
        t0 = t.getSuppressed();
7f5fe8985263 6991528: Support making Throwable.suppressedExceptions immutable
darcy
parents: 6110
diff changeset
   191
        if (t0.length != 0)
7f5fe8985263 6991528: Support making Throwable.suppressedExceptions immutable
darcy
parents: 6110
diff changeset
   192
            throw new RuntimeException("Bad nonzero length of suppressed exceptions.");
9020
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   193
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   194
        Throwable suppressed = new ArithmeticException();
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   195
        t = new NoSuppression(true); // Suppression enabled
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   196
        // Make sure addSuppressed(null) throws an NPE
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   197
        try {
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   198
            t.addSuppressed(null);
9513
1079ae7ada52 6998871: Support making the Throwable.stackTrace field immutable
darcy
parents: 9020
diff changeset
   199
            throw new RuntimeException("NPE not thrown!");
9020
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   200
        } catch(NullPointerException e) {
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   201
            ; // Expected
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   202
        }
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   203
        t.addSuppressed(suppressed);
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   204
        t0 = t.getSuppressed();
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   205
        if (t0.length != 1 || t0[0] != suppressed)
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   206
            throw new RuntimeException("Expected suppression did not occur.");
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   207
    }
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   208
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   209
    private static class NoSuppression extends Throwable {
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   210
        public NoSuppression(boolean enableSuppression) {
9513
1079ae7ada52 6998871: Support making the Throwable.stackTrace field immutable
darcy
parents: 9020
diff changeset
   211
            super("The medium.", null, enableSuppression, true);
9020
13b639abc930 7005628: Clarify NPE behavior of Throwable.addSuppressed(null)
darcy
parents: 7186
diff changeset
   212
        }
7186
7f5fe8985263 6991528: Support making Throwable.suppressedExceptions immutable
darcy
parents: 6110
diff changeset
   213
    }
17176
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   214
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   215
    private static void initCausePlumbing() {
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   216
        Throwable t1 = new Throwable();
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   217
        Throwable t2 = new Throwable("message", t1);
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   218
        Throwable t3 = new Throwable();
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   219
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   220
        try {
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   221
            t2.initCause(t3);
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   222
            throw new RuntimeException("Shouldn't reach.");
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   223
        } catch (IllegalStateException ise) {
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   224
            if (ise.getCause() != t2)
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   225
                throw new RuntimeException("Unexpected cause in ISE", ise);
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   226
            Throwable[] suppressed = ise.getSuppressed();
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   227
            if (suppressed.length !=  0)
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   228
                throw new RuntimeException("Bad suppression in ISE", ise);
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   229
        }
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   230
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   231
        try {
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   232
            t2.initCause(null);
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   233
            throw new RuntimeException("Shouldn't reach.");
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   234
        } catch (IllegalStateException ise) {
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   235
            ; // Expected; don't want an NPE.
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   236
        }
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   237
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   238
        try {
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   239
            t3.initCause(t3);
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   240
            throw new RuntimeException("Shouldn't reach.");
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   241
        } catch (IllegalArgumentException iae) {
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   242
            if (iae.getCause() != t3)
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   243
                throw new RuntimeException("Unexpected cause in ISE", iae);
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   244
        }
d7ee1e315fe7 8012044: Give more information about self-suppression from Throwable.addSuppressed
darcy
parents: 9513
diff changeset
   245
    }
5972
e3f47656e9d9 6911258: Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
darcy
parents:
diff changeset
   246
}