hotspot/test/compiler/compilercontrol/share/JSONFile.java
author dsamersoff
Sun, 01 May 2016 12:47:00 +0300
changeset 38152 80e5da81fb2c
parent 33452 04815c29859c
permissions -rw-r--r--
8154258: [TESTBUG] Various serviceability tests fail compilation Summary: Replace sun.misc.Unsafe with jdk.internal.misc.Unsafe Reviewed-by: chegar, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33452
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
     1
/*
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
     4
 *
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
     8
 *
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    13
 * accompanied this code).
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    14
 *
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    18
 *
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    21
 * questions.
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    22
 */
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    23
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    24
package compiler.compilercontrol.share;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    25
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    26
import java.io.FileNotFoundException;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    27
import java.io.PrintStream;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    28
import java.util.Objects;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    29
import java.util.Stack;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    30
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    31
/**
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    32
 * Simple JSON file writer
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    33
 */
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    34
public class JSONFile implements AutoCloseable {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    35
    private final Stack<Element> stack;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    36
    private final String fileName;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    37
    private final PrintStream out;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    38
    private int spaces;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    39
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    40
    /**
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    41
     * JSON element
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    42
     */
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    43
    public enum Element {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    44
        OBJECT,
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    45
        ARRAY,
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    46
        PAIR,
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    47
        VALUE
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    48
    }
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    49
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    50
    /**
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    51
     * Constructor. Creates file with default name
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    52
     */
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    53
    public JSONFile() {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    54
        this("directives_file.json");
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    55
    }
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    56
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    57
    /**
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    58
     * Constructor
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    59
     *
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    60
     * @param fileName file name
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    61
     */
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    62
    public JSONFile(String fileName) {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    63
        this.spaces = 0;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    64
        this.stack = new Stack<>();
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    65
        this.fileName = fileName;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    66
        try {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    67
            out = new PrintStream(fileName);
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    68
        } catch (FileNotFoundException e) {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    69
            throw new Error("TESTBUG: can't open/create file " + fileName, e);
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    70
        }
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    71
    }
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    72
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    73
    /**
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    74
     * Gets file name
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    75
     *
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    76
     * @return file name string
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    77
     */
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    78
    public String getFileName() {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    79
        return fileName;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    80
    }
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    81
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    82
    /**
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    83
     * Gets current JSON element in the file.
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    84
     * The element is a current {@linkplain Element}
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    85
     * that was written into a file.
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    86
     *
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    87
     * @return the type of the current element,
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    88
     * or null if there are nothing written
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    89
     */
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    90
    public Element getElement() {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    91
        if (stack.empty()) {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    92
            return null;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    93
        }
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    94
        return stack.peek();
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    95
    }
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    96
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    97
    /**
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    98
     * Writes given type with a value to file.
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
    99
     * Note that only PAIR and VALUE types accept a single value parameter.
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   100
     * OBJECT and ARRAY do not have a value
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   101
     *
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   102
     * @param element  JSON element type
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   103
     * @param value element's value
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   104
     * @return this file instance
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   105
     */
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   106
    public JSONFile write(Element element, String... value) {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   107
        if (value.length > 1) {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   108
            throw new Error("TESTBUG: Unexpected value length: "
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   109
                    + value.length);
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   110
        }
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   111
        if (!stack.empty()) {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   112
            if (stack.peek() == Element.VALUE) {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   113
                out.print(", ");
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   114
                stack.pop();
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   115
            }
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   116
        }
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   117
        switch (element) {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   118
            case OBJECT:
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   119
                out.print("{");
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   120
                spaces++;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   121
                stack.push(Element.VALUE);
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   122
                break;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   123
            case ARRAY:
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   124
                out.print("[");
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   125
                stack.push(Element.VALUE);
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   126
                break;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   127
            case PAIR:
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   128
                fillSpaces();
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   129
                Objects.requireNonNull(value, "TESTBUG: " + element
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   130
                        + "requires a value to be set");
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   131
                out.print(value[0] + ": ");
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   132
                break;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   133
            case VALUE:
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   134
                Objects.requireNonNull(value, "TESTBUG: " + element
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   135
                        + "requires a value to be set");
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   136
                out.print(value[0]);
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   137
                break;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   138
        }
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   139
        stack.push(element);
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   140
        return this;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   141
    }
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   142
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   143
    private void fillSpaces() {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   144
        out.println();
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   145
        for (int i = 0; i < spaces; i++) {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   146
            // Fill with spaces to be more readable
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   147
            out.print("  ");
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   148
        }
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   149
    }
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   150
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   151
    /**
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   152
     * Ends current object or array of {@linkplain Element}
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   153
     *
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   154
     * @return this file instance
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   155
     */
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   156
    public JSONFile end() {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   157
        if (!stack.empty()) {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   158
            Element prev = stack.pop();
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   159
            while (prev != Element.OBJECT && prev != Element.ARRAY
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   160
                    && !stack.empty()) {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   161
                prev = stack.pop();
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   162
            }
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   163
            switch (prev) {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   164
                case OBJECT:
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   165
                    spaces--;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   166
                    fillSpaces();
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   167
                    out.print("}");
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   168
                    break;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   169
                case ARRAY:
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   170
                    out.print("]");
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   171
                    break;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   172
                default:
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   173
                    throw new Error("TESTBUG: Incorrect end. " +
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   174
                            "Wrong type found: " + prev);
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   175
            }
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   176
        } else {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   177
            throw new Error("TESTBUG: Incorrect end. Empty stack");
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   178
        }
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   179
        return this;
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   180
    }
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   181
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   182
    /**
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   183
     * Closes this file
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   184
     */
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   185
    @Override
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   186
    public void close() {
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   187
        out.close();
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   188
    }
04815c29859c 8066153: JEP-JDK-8046155: Test task: cover existing
ppunegov
parents:
diff changeset
   189
}