author | vromero |
Thu, 19 Sep 2013 20:57:37 +0100 | |
changeset 20242 | 11fa75a0b9fb |
child 26100 | bb7dd001d190 |
permissions | -rw-r--r-- |
20242
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
1 |
/* |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
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 |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
10 |
* |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
11 |
* 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
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
13 |
* 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
|
14 |
* 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
|
15 |
* accompanied this code). |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
16 |
* |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
17 |
* 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
|
18 |
* 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
|
19 |
* 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
|
20 |
* |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
21 |
* 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
|
22 |
* 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
|
23 |
* questions. |
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 |
|
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
26 |
/* |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
27 |
* @test |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
28 |
* @bug 8024437 |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
29 |
* @summary Inferring the exception thrown by a lambda: sometimes fails to compile |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
30 |
* @library /tools/javac/lib |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
31 |
* @build ToolBox |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
32 |
* @run main ExceptionInferenceFromClassFileTest |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
33 |
*/ |
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 |
import java.nio.file.Files; |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
36 |
import java.nio.file.Paths; |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
37 |
|
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
38 |
public class ExceptionInferenceFromClassFileTest { |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
39 |
|
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
40 |
static final String ABSrc = |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
41 |
"class B {\n" + |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
42 |
" 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
|
43 |
" a.run();\n" + |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
44 |
" }\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 |
|
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
47 |
"interface A<E extends Throwable> {\n" + |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
48 |
" void run() throws E;\n" + |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
49 |
"}"; |
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 |
static final String CSrc = |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
52 |
"class C {\n" + |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
53 |
" public void d() {\n" + |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
54 |
" B.t(null);\n" + |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
55 |
" }\n" + |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
56 |
"}"; |
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 |
public static void main(String[] args) throws Exception { |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
59 |
Files.createDirectory(Paths.get("out")); |
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 |
ToolBox.JavaToolArgs compileABParams = |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
62 |
new ToolBox.JavaToolArgs() |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
63 |
.setOptions("-d", "out") |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
64 |
.setSources(ABSrc); |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
65 |
ToolBox.javac(compileABParams); |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
66 |
|
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
67 |
ToolBox.JavaToolArgs compileCParams = |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
68 |
new ToolBox.JavaToolArgs() |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
69 |
.setOptions("-d", "out", "-cp", "out") |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
70 |
.setSources(CSrc); |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
71 |
ToolBox.javac(compileCParams); |
11fa75a0b9fb
8024437: Inferring the exception thrown: sometimes fails to compile
vromero
parents:
diff
changeset
|
72 |
} |
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 |
} |