langtools/test/tools/javac/TryWithResources/ResInNestedExpr.java
author mchung
Wed, 27 May 2015 13:25:18 -0700
changeset 30846 2b3f379840f0
parent 21714 f5b7edec4304
permissions -rw-r--r--
8074432: Move jdeps and javap to jdk.jdeps module Reviewed-by: jjg, alanb, erikj
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21714
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
     1
/*
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
     2
 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
     4
 *
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
     7
 * published by the Free Software Foundation.
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
     8
 *
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    13
 * accompanied this code).
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    14
 *
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    18
 *
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    21
 * questions.
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    22
 */
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    23
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    24
/*
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    25
 * @test
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    26
 * @bug     8025113
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    27
 * @author  sogoel
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    28
 * @summary Resource creation in nested expressions
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    29
 */
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    30
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    31
/**
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    32
 * This test checks for resource creation in nested expressions.
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    33
 * test1() - Create 3 resource in nested new expressions, style 1
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    34
 * test2() - Create 3 resource in nested new expressions, style 2
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    35
 * test3() - Create 4 resources with resources as parameters: new expression; typeid & new expression
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    36
 */
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    37
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    38
public class ResInNestedExpr {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    39
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    40
    static final int expected = 5;
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    41
    static int closed = 0;
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    42
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    43
    static void closing(String clazz) {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    44
        closed++;
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    45
    }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    46
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    47
    static void checkClosedCount() {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    48
        if (expected != closed) {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    49
            throw new RuntimeException("Did not find enough closed resources."
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    50
               + "Expected " + expected + ", but found " + closed);
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    51
        }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    52
    }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    53
    /**
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    54
     * The "expected output" is each class name gotten with getSimpleName() to unclutter things.
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    55
     * Each test method returns a classname of the resource and that is compared with
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    56
     * values in this array.
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    57
     */
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    58
    static String[] expectedOutput = {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    59
        "aResource::bResource::cResource", //test1
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    60
        "aResource::bResource::cResource&aResource::cResource", //test3
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    61
        "aResource::bResource::cResource&aResource::cResource"}; //test2
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    62
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    63
    static void compare(String s1, String s2) {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    64
        if (s1.compareTo(s2) != 0) {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    65
            throw new RuntimeException(s1 + "!=" + s2);
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    66
        }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    67
    }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    68
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    69
    String test1() {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    70
        String ret = null;
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    71
        try (bResource br = new bResource(new cResource());
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    72
                aResource ar = new aResource(br)) {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    73
            ret = ar.getClass().getSimpleName() + "::" +
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    74
                  ar.getB().getClass().getSimpleName() + "::" +
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    75
                  ar.getB().getC().getClass().getSimpleName();
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    76
        }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    77
        return ret;
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    78
    }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    79
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    80
    String test2() {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    81
        String ret = null;
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    82
        try (aResource ar = new aResource(new bResource(new cResource()), new cResource())) {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    83
            String abc = ar.getClass().getSimpleName() + "::" +
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    84
                         ar.getB().getClass().getSimpleName() + "::" +
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    85
                         ar.getB().getC().getClass().getSimpleName();
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    86
            String ac = ar.getClass().getSimpleName() + "::" +
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    87
                        ar.getC().getClass().getSimpleName();
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    88
            ret = abc + "&" + ac;
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    89
        }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    90
        return ret;
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    91
    }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    92
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    93
    String test3() {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    94
        String ret = null;
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    95
        try (bResource br = new bResource(new cResource());
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    96
                aResource ar = new aResource(br, new cResource())) {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    97
            String abc = ar.getClass().getSimpleName() + "::" +
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    98
                         ar.getB().getClass().getSimpleName() + "::" +
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
    99
                         ar.getB().getC().getClass().getSimpleName();
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   100
            String ac = ar.getClass().getSimpleName() + "::" +
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   101
                        ar.getC().getClass().getSimpleName();
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   102
            ret = abc + "&" + ac;
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   103
        }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   104
        return ret;
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   105
    }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   106
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   107
    public static void main(String... args) {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   108
        ResInNestedExpr t = new ResInNestedExpr();
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   109
        int eo = 0;
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   110
        compare(expectedOutput[eo++], t.test1());
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   111
        compare(expectedOutput[eo++], t.test3());
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   112
        compare(expectedOutput[eo++], t.test2());
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   113
        ResInNestedExpr.checkClosedCount();
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   114
    }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   115
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   116
    /**
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   117
     * A resource to implement AutoCloseable
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   118
     * Contains two other resources as data items.
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   119
     */
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   120
    static class aResource implements AutoCloseable {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   121
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   122
        bResource bR;
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   123
        cResource cR;
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   124
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   125
        public aResource() {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   126
            bR = null;
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   127
            cR = null;
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   128
        }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   129
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   130
        public aResource(bResource br) {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   131
            bR = br;
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   132
        }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   133
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   134
        public aResource(cResource cr) {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   135
            cR = cr;
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   136
        }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   137
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   138
        public aResource(bResource br, cResource cr) {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   139
            bR = br;
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   140
            cR = cr;
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   141
        }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   142
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   143
        public bResource getB() {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   144
            return bR;
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   145
        }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   146
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   147
        public cResource getC() {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   148
            return cR;
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   149
        }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   150
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   151
        @Override
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   152
        public void close() {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   153
            ResInNestedExpr.closing(this.getClass().getName());
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   154
        }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   155
    }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   156
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   157
    /**
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   158
     * A resource to implement AutoCloseable
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   159
     * Contains one other resources as a data item.
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   160
     */
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   161
    static class bResource implements AutoCloseable {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   162
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   163
        cResource cR;
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   164
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   165
        public bResource() {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   166
            cR = null;
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   167
        }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   168
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   169
        public bResource(cResource cr) {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   170
            cR = cr;
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   171
        }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   172
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   173
        public cResource getC() {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   174
            return cR;
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   175
        }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   176
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   177
        @Override
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   178
        public void close() {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   179
            ResInNestedExpr.closing(this.getClass().getName());
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   180
        }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   181
    }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   182
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   183
    /** A resource to implement AutoCloseable */
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   184
    static class cResource implements AutoCloseable {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   185
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   186
        public cResource() {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   187
        }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   188
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   189
        @Override
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   190
        public void close() {
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   191
            ResInNestedExpr.closing(this.getClass().getName());
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   192
        }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   193
    }
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   194
}
f5b7edec4304 8025113: Convert 7 tools TryWithResources tests to jtreg format
sogoel
parents:
diff changeset
   195