Skip to content

Commit 746f8d1

Browse files
weibxiaocoffeys
authored andcommitted
8305714: Add an extra test for JDK-8292755
Reviewed-by: coffeys
1 parent 1a1ce66 commit 746f8d1

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/**
25+
* @test
26+
* @bug 8292755
27+
* @summary InternalError seen while throwing undefined exception
28+
* @modules
29+
* jdk.compiler/com.sun.tools.javac.api
30+
* jdk.compiler/com.sun.tools.javac.main
31+
* jdk.jshell/jdk.internal.jshell.tool:open
32+
* jdk.jshell/jdk.internal.jshell.tool.resources:open
33+
* jdk.jshell/jdk.jshell:open
34+
* @library /tools/lib
35+
* @build toolbox.ToolBox toolbox.JarTask toolbox.JavacTask
36+
* @build Compiler UITesting
37+
* @build UndefinedClassTest
38+
* @run testng UndefinedClassTest
39+
*/
40+
41+
import org.testng.annotations.Test;
42+
43+
@Test
44+
public class UndefinedClassTest extends UITesting {
45+
46+
public UndefinedClassTest() {
47+
super(true);
48+
}
49+
50+
public void testUndefinedClassWithStaticAccess() throws Exception{
51+
String code = "@FunctionalInterface\n" +
52+
"interface RunnableWithThrowable {\n" +
53+
" void run() throws Throwable;\n" +
54+
"\n" +
55+
" static RunnableWithThrowable getInstance() {\n" +
56+
" return () -> { throw new NotExist(); };\n" +
57+
" }\n" +
58+
"}";
59+
doRunTest((inputSink, out) -> {
60+
inputSink.write(code + "\n");
61+
waitOutput(out, "NotExist");
62+
});
63+
}
64+
65+
public void testUndefinedClassWithDefaultAccess() throws Exception{
66+
String code = "@FunctionalInterface\n" +
67+
"interface RunnableWithThrowable {\n" +
68+
" void run() throws Throwable;\n" +
69+
"\n" +
70+
" default RunnableWithThrowable getInstance() {\n" +
71+
" return () -> { throw new NotExist(); };\n" +
72+
" }\n" +
73+
"}";
74+
doRunTest((inputSink, out) -> {
75+
inputSink.write(code + "\n");
76+
waitOutput(out, "NotExist");
77+
});
78+
}
79+
}

0 commit comments

Comments
 (0)