langtools/test/tools/javac/lambda/speculative/T8177933.java
author mcimadamore
Fri, 07 Apr 2017 15:46:31 +0100
changeset 44575 e8892d76055f
parent 44571 1140b8dad6bb
permissions -rw-r--r--
8178283: tools/javac/lambda/speculative/T8177933.java fails with assertion error Summary: disable test on solaris Reviewed-by: darcy
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
44571
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
     1
/*
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
     2
 * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
     4
 *
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    10
 *
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    15
 * accompanied this code).
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    16
 *
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    20
 *
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    23
 * questions.
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    24
 */
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    25
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    26
/*
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    27
 * @test
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    28
 * @bug 8177933
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    29
 * @summary Stackoverflow during compilation, starting jdk-9+163
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    30
 *
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    31
 * @library /tools/javac/lib
44575
e8892d76055f 8178283: tools/javac/lambda/speculative/T8177933.java fails with assertion error
mcimadamore
parents: 44571
diff changeset
    32
 * @requires !(os.family == "solaris")
44571
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    33
 * @modules jdk.compiler/com.sun.tools.javac.api
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    34
 *          jdk.compiler/com.sun.tools.javac.code
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    35
 *          jdk.compiler/com.sun.tools.javac.comp
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    36
 *          jdk.compiler/com.sun.tools.javac.main
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    37
 *          jdk.compiler/com.sun.tools.javac.tree
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    38
 *          jdk.compiler/com.sun.tools.javac.util
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    39
 * @build combo.ComboTestHelper
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    40
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    41
 * @run main/othervm -Xss512K T8177933
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    42
 */
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    43
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    44
import combo.ComboInstance;
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    45
import combo.ComboParameter;
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    46
import combo.ComboTask.Result;
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    47
import combo.ComboTestHelper;
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    48
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    49
import javax.lang.model.element.Element;
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    50
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    51
public class T8177933 extends ComboInstance<T8177933> {
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    52
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    53
    static final int MAX_DEPTH = 350;
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    54
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    55
    static class CallExpr implements ComboParameter {
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    56
        @Override
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    57
        public String expand(String optParameter) {
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    58
            Integer n = Integer.parseInt(optParameter);
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    59
            if (n == MAX_DEPTH) {
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    60
                return "m()";
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    61
            } else {
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    62
                return "m().#{CALL." + (n + 1) + "}";
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    63
            }
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    64
        }
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    65
    }
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    66
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    67
    static final String sourceTemplate =
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    68
            "class Test {\n" +
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    69
            "   Test m() { return null; }\n" +
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    70
            "   void test() {\n" +
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    71
            "       #{CALL.0};\n" +
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    72
            "} }\n";
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    73
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    74
    public static void main(String[] args) {
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    75
        new ComboTestHelper<T8177933>()
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    76
                .withDimension("CALL", new CallExpr())
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    77
                .run(T8177933::new);
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    78
    }
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    79
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    80
    @Override
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    81
    protected void doWork() throws Throwable {
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    82
        Result<Iterable<? extends Element>> result = newCompilationTask()
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    83
                    .withOption("-XDdev")
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    84
                    .withSourceFromTemplate(sourceTemplate)
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    85
                    .analyze();
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    86
        if (!result.get().iterator().hasNext()) {
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    87
            fail("Exception occurred when compiling combo. " + result.compilationInfo());
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    88
        }
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    89
    }
1140b8dad6bb 8177933: Stackoverflow during compilation, starting jdk-9+163
mcimadamore
parents:
diff changeset
    90
}