langtools/test/tools/javac/T8024437/ExceptionInferenceFromClassFileTest.java
author alundblad
Wed, 26 Aug 2015 09:02:02 +0200
changeset 32337 c9d3ab9f601c
parent 30730 d3ce7619db2c
child 36526 3b41f1c69604
permissions -rw-r--r--
8133671: langtools tests have bad license Summary: Dropped classpath exception from copyright notice in tests. Reviewed-by: jjg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
20242
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
     1
/*
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 26100
diff changeset
     2
 * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
20242
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
     4
 *
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
32337
c9d3ab9f601c 8133671: langtools tests have bad license
alundblad
parents: 30730
diff changeset
     7
 * published by the Free Software Foundation.
20242
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
     8
 *
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    13
 * accompanied this code).
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    14
 *
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    18
 *
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    21
 * questions.
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    22
 */
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    23
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    24
/*
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    25
 * @test
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    26
 * @bug 8024437
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    27
 * @summary Inferring the exception thrown by a lambda: sometimes fails to compile
26100
bb7dd001d190 8050429: Update/cleanup ToolBox
jjg
parents: 20242
diff changeset
    28
 * @library /tools/lib
30730
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 26100
diff changeset
    29
 * @modules jdk.compiler/com.sun.tools.javac.api
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 26100
diff changeset
    30
 *          jdk.compiler/com.sun.tools.javac.file
d3ce7619db2c 8076543: Add @modules as needed to the langtools tests
akulyakh
parents: 26100
diff changeset
    31
 *          jdk.compiler/com.sun.tools.javac.main
20242
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    32
 * @build ToolBox
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    33
 * @run main ExceptionInferenceFromClassFileTest
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    34
 */
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    35
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    36
import java.nio.file.Files;
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    37
import java.nio.file.Paths;
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    38
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    39
public class ExceptionInferenceFromClassFileTest {
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    40
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    41
    static final String ABSrc =
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    42
            "class B {\n" +
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    43
            "    public static <E extends Throwable> void t(A<E> a) throws E {\n" +
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    44
            "        a.run();\n" +
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    45
            "    }\n" +
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    46
            "}\n" +
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    47
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    48
            "interface A<E extends Throwable> {\n" +
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    49
            "    void run() throws E;\n" +
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    50
            "}";
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    51
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    52
    static final String CSrc =
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    53
            "class C {\n" +
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    54
            "    public void d() {\n" +
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    55
            "        B.t(null);\n" +
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    56
            "    }\n" +
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    57
            "}";
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    58
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    59
    public static void main(String[] args) throws Exception {
26100
bb7dd001d190 8050429: Update/cleanup ToolBox
jjg
parents: 20242
diff changeset
    60
        ToolBox tb = new ToolBox();
bb7dd001d190 8050429: Update/cleanup ToolBox
jjg
parents: 20242
diff changeset
    61
        tb.createDirectories("out");
20242
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    62
26100
bb7dd001d190 8050429: Update/cleanup ToolBox
jjg
parents: 20242
diff changeset
    63
        tb.new JavacTask()
bb7dd001d190 8050429: Update/cleanup ToolBox
jjg
parents: 20242
diff changeset
    64
                .outdir("out")
bb7dd001d190 8050429: Update/cleanup ToolBox
jjg
parents: 20242
diff changeset
    65
                .sources(ABSrc)
bb7dd001d190 8050429: Update/cleanup ToolBox
jjg
parents: 20242
diff changeset
    66
                .run();
20242
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    67
26100
bb7dd001d190 8050429: Update/cleanup ToolBox
jjg
parents: 20242
diff changeset
    68
        tb.new JavacTask()
bb7dd001d190 8050429: Update/cleanup ToolBox
jjg
parents: 20242
diff changeset
    69
                .outdir("out")
bb7dd001d190 8050429: Update/cleanup ToolBox
jjg
parents: 20242
diff changeset
    70
                .classpath("out")
bb7dd001d190 8050429: Update/cleanup ToolBox
jjg
parents: 20242
diff changeset
    71
                .sources(CSrc)
bb7dd001d190 8050429: Update/cleanup ToolBox
jjg
parents: 20242
diff changeset
    72
                .run();
20242
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    73
    }
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    74
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    75
}