langtools/test/tools/javac/T7093325.java
author vromero
Tue, 08 Jan 2013 13:47:57 +0000
changeset 15040 99fd9483d3f0
parent 10811 4d4ed480210e
child 15384 5a8d00abf076
permissions -rw-r--r--
8005167: execution time of combo tests in javac should be improved Reviewed-by: jjg, jjh
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10811
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
     1
/*
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
     2
 * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
10811
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
     4
 *
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
     7
 * published by the Free Software Foundation.
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
     8
 *
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    13
 * accompanied this code).
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    14
 *
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    18
 *
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    21
 * questions.
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    22
 */
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    23
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    24
/*
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    25
 * @test
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    26
 * @bug 7093325
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    27
 * @summary Redundant entry in bytecode exception table
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
    28
 * @library lib
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
    29
 * @build JavacTestingAbstractThreadedTest
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
    30
 * @run main T7093325
10811
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    31
 */
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    32
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
    33
import java.io.File;
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
    34
import java.net.URI;
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
    35
import java.util.Arrays;
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
    36
import javax.tools.JavaCompiler;
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
    37
import javax.tools.JavaFileObject;
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
    38
import javax.tools.SimpleJavaFileObject;
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
    39
import javax.tools.ToolProvider;
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
    40
10811
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    41
import com.sun.source.util.JavacTask;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    42
import com.sun.tools.classfile.Attribute;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    43
import com.sun.tools.classfile.ClassFile;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    44
import com.sun.tools.classfile.Code_attribute;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    45
import com.sun.tools.classfile.ConstantPool.*;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    46
import com.sun.tools.classfile.Method;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    47
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
    48
public class T7093325
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
    49
    extends JavacTestingAbstractThreadedTest
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
    50
    implements Runnable {
10811
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    51
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    52
    enum StatementKind {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    53
        THROW("throw new RuntimeException();", false, false),
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    54
        RETURN_NONEMPTY("System.out.println(); return;", true, false),
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    55
        RETURN_EMPTY("return;", true, true),
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    56
        APPLY("System.out.println();", true, false);
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    57
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    58
        String stmt;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    59
        boolean canInline;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    60
        boolean empty;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    61
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    62
        private StatementKind(String stmt, boolean canInline, boolean empty) {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    63
            this.stmt = stmt;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    64
            this.canInline = canInline;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    65
            this.empty = empty;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    66
        }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    67
    }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    68
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    69
    enum CatchArity {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    70
        NONE(""),
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    71
        ONE("catch (A a) { #S1 }"),
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    72
        TWO("catch (B b) { #S2 }"),
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    73
        THREE("catch (C c) { #S3 }"),
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    74
        FOUR("catch (D d) { #S4 }");
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    75
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    76
        String catchStr;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    77
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    78
        private CatchArity(String catchStr) {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    79
            this.catchStr = catchStr;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    80
        }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    81
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    82
        String catchers() {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    83
            if (this.ordinal() == 0) {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    84
                return catchStr;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    85
            } else {
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
    86
                return CatchArity.values()[this.ordinal() - 1].catchers() +
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
    87
                        catchStr;
10811
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    88
            }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    89
        }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    90
    }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    91
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    92
    public static void main(String... args) throws Exception {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    93
        for (CatchArity ca : CatchArity.values()) {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    94
            for (StatementKind stmt0 : StatementKind.values()) {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    95
                if (ca.ordinal() == 0) {
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
    96
                    pool.execute(new T7093325(ca, stmt0));
10811
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    97
                    continue;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    98
                }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
    99
                for (StatementKind stmt1 : StatementKind.values()) {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   100
                    if (ca.ordinal() == 1) {
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
   101
                        pool.execute(new T7093325(ca, stmt0, stmt1));
10811
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   102
                        continue;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   103
                    }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   104
                    for (StatementKind stmt2 : StatementKind.values()) {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   105
                        if (ca.ordinal() == 2) {
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
   106
                            pool.execute(new T7093325(ca, stmt0, stmt1, stmt2));
10811
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   107
                            continue;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   108
                        }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   109
                        for (StatementKind stmt3 : StatementKind.values()) {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   110
                            if (ca.ordinal() == 3) {
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
   111
                                pool.execute(
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
   112
                                    new T7093325(ca, stmt0, stmt1, stmt2, stmt3));
10811
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   113
                                continue;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   114
                            }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   115
                            for (StatementKind stmt4 : StatementKind.values()) {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   116
                                if (ca.ordinal() == 4) {
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
   117
                                    pool.execute(
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
   118
                                        new T7093325(ca, stmt0, stmt1,
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
   119
                                                     stmt2, stmt3, stmt4));
10811
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   120
                                    continue;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   121
                                }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   122
                                for (StatementKind stmt5 : StatementKind.values()) {
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
   123
                                    pool.execute(
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
   124
                                        new T7093325(ca, stmt0, stmt1, stmt2,
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
   125
                                                     stmt3, stmt4, stmt5));
10811
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   126
                                }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   127
                            }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   128
                        }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   129
                    }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   130
                }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   131
            }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   132
        }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   133
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
   134
        checkAfterExec();
10811
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   135
    }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   136
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   137
    /** instance decls **/
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   138
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   139
    CatchArity ca;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   140
    StatementKind[] stmts;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   141
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   142
    public T7093325(CatchArity ca, StatementKind... stmts) {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   143
        this.ca = ca;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   144
        this.stmts = stmts;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   145
    }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   146
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
   147
    @Override
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
   148
    public void run() {
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
   149
        int id = checkCount.incrementAndGet();
10811
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   150
        final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
   151
        JavaSource source = new JavaSource(id);
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
   152
        JavacTask ct = (JavacTask)tool.getTask(null, fm.get(), null,
10811
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   153
                null, null, Arrays.asList(source));
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   154
        ct.call();
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
   155
        verifyBytecode(source, id);
10811
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   156
    }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   157
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
   158
    void verifyBytecode(JavaSource source, int id) {
10811
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   159
        boolean lastInlined = false;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   160
        boolean hasCode = false;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   161
        int gapsCount = 0;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   162
        for (int i = 0; i < stmts.length ; i++) {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   163
            lastInlined = stmts[i].canInline;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   164
            hasCode = hasCode || !stmts[i].empty;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   165
            if (lastInlined && hasCode) {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   166
                hasCode = false;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   167
                gapsCount++;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   168
            }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   169
        }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   170
        if (!lastInlined) {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   171
            gapsCount++;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   172
        }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   173
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   174
        //System.out.printf("gaps %d \n %s \n", gapsCount, source.toString());
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   175
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
   176
        File compiledTest = new File(String.format("Test%s.class", id));
10811
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   177
        try {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   178
            ClassFile cf = ClassFile.read(compiledTest);
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   179
            if (cf == null) {
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
   180
                throw new Error("Classfile not found: " +
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
   181
                                compiledTest.getName());
10811
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   182
            }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   183
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   184
            Method test_method = null;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   185
            for (Method m : cf.methods) {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   186
                if (m.getName(cf.constant_pool).equals("test")) {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   187
                    test_method = m;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   188
                    break;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   189
                }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   190
            }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   191
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   192
            if (test_method == null) {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   193
                throw new Error("Method test() not found in class Test");
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   194
            }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   195
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   196
            Code_attribute code = null;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   197
            for (Attribute a : test_method.attributes) {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   198
                if (a.getName(cf.constant_pool).equals(Attribute.Code)) {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   199
                    code = (Code_attribute)a;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   200
                    break;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   201
                }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   202
            }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   203
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   204
            if (code == null) {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   205
                throw new Error("Code attribute not found in method test()");
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   206
            }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   207
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   208
            int actualGapsCount = 0;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   209
            for (int i = 0; i < code.exception_table_langth ; i++) {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   210
                int catchType = code.exception_table[i].catch_type;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   211
                if (catchType == 0) { //any
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   212
                    actualGapsCount++;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   213
                }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   214
            }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   215
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   216
            if (actualGapsCount != gapsCount) {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   217
                throw new Error("Bad exception table for test()\n" +
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   218
                            "expected gaps: " + gapsCount + "\n" +
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   219
                            "found gaps: " + actualGapsCount + "\n" +
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   220
                            source);
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   221
            }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   222
        } catch (Exception e) {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   223
            e.printStackTrace();
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   224
            throw new Error("error reading " + compiledTest +": " + e);
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   225
        }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   226
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   227
    }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   228
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   229
    class JavaSource extends SimpleJavaFileObject {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   230
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   231
        static final String source_template =
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   232
                "class A extends RuntimeException {} \n" +
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   233
                "class B extends RuntimeException {} \n" +
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   234
                "class C extends RuntimeException {} \n" +
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   235
                "class D extends RuntimeException {} \n" +
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   236
                "class E extends RuntimeException {} \n" +
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
   237
                "class Test#ID {\n" +
10811
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   238
                "   void test() {\n" +
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   239
                "   try { #S0 } #C finally { System.out.println(); }\n" +
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   240
                "   }\n" +
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   241
                "}";
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   242
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   243
        String source;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   244
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
   245
        public JavaSource(int id) {
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
   246
            super(URI.create(String.format("myfo:/Test%s.java", id)),
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
   247
                  JavaFileObject.Kind.SOURCE);
10811
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   248
            source = source_template.replace("#C", ca.catchers());
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   249
            source = source.replace("#S0", stmts[0].stmt);
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
   250
            source = source.replace("#ID", String.valueOf(id));
10811
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   251
            for (int i = 1; i < ca.ordinal() + 1; i++) {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   252
                source = source.replace("#S" + i, stmts[i].stmt);
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   253
            }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   254
        }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   255
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   256
        @Override
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   257
        public String toString() {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   258
            return source;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   259
        }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   260
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   261
        @Override
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   262
        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   263
            return source;
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   264
        }
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   265
    }
15040
99fd9483d3f0 8005167: execution time of combo tests in javac should be improved
vromero
parents: 10811
diff changeset
   266
10811
4d4ed480210e 7093325: Redundant entry in bytecode exception table
mcimadamore
parents:
diff changeset
   267
}