langtools/test/tools/javac/T8024437/ExceptionInferenceFromClassFileTest.java
author robm
Tue, 13 Sep 2016 14:47:29 +0100
changeset 40938 5b0977acc842
parent 36778 e04318f39f92
permissions -rw-r--r--
6947916: JarURLConnection does not handle useCaches correctly Reviewed-by: chegar
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
/*
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
     2
 * Copyright (c) 2013, 2016, 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.main
36526
3b41f1c69604 8142968: Module System implementation
alanb
parents: 32337
diff changeset
    31
 *          jdk.jdeps/com.sun.tools.javap
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    32
 * @build toolbox.ToolBox toolbox.JavacTask
20242
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
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    39
import toolbox.JavacTask;
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    40
import toolbox.ToolBox;
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    41
20242
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    42
public class ExceptionInferenceFromClassFileTest {
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    43
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    44
    static final String ABSrc =
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    45
            "class B {\n" +
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    46
            "    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
    47
            "        a.run();\n" +
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    48
            "    }\n" +
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    49
            "}\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
            "interface A<E extends Throwable> {\n" +
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    52
            "    void run() throws E;\n" +
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    53
            "}";
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    54
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    55
    static final String CSrc =
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    56
            "class C {\n" +
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    57
            "    public void d() {\n" +
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    58
            "        B.t(null);\n" +
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    59
            "    }\n" +
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    60
            "}";
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    61
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    62
    public static void main(String[] args) throws Exception {
26100
bb7dd001d190 8050429: Update/cleanup ToolBox
jjg
parents: 20242
diff changeset
    63
        ToolBox tb = new ToolBox();
bb7dd001d190 8050429: Update/cleanup ToolBox
jjg
parents: 20242
diff changeset
    64
        tb.createDirectories("out");
20242
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    65
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    66
        new JavacTask(tb)
26100
bb7dd001d190 8050429: Update/cleanup ToolBox
jjg
parents: 20242
diff changeset
    67
                .outdir("out")
bb7dd001d190 8050429: Update/cleanup ToolBox
jjg
parents: 20242
diff changeset
    68
                .sources(ABSrc)
bb7dd001d190 8050429: Update/cleanup ToolBox
jjg
parents: 20242
diff changeset
    69
                .run();
20242
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    70
36778
e04318f39f92 8152897: refactor ToolBox to allow reduced documented dependencies
jjg
parents: 36526
diff changeset
    71
        new JavacTask(tb)
26100
bb7dd001d190 8050429: Update/cleanup ToolBox
jjg
parents: 20242
diff changeset
    72
                .outdir("out")
bb7dd001d190 8050429: Update/cleanup ToolBox
jjg
parents: 20242
diff changeset
    73
                .classpath("out")
bb7dd001d190 8050429: Update/cleanup ToolBox
jjg
parents: 20242
diff changeset
    74
                .sources(CSrc)
bb7dd001d190 8050429: Update/cleanup ToolBox
jjg
parents: 20242
diff changeset
    75
                .run();
20242
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    76
    }
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    77
11fa75a0b9fb 8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff changeset
    78
}