55242
|
1 |
/*
|
|
2 |
* Copyright (c) 2019, 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 8216261
|
|
26 |
* @summary Javap ignores default modifier on interfaces
|
|
27 |
* @library /tools/lib
|
|
28 |
* @modules jdk.jdeps/com.sun.tools.javap
|
|
29 |
* @build toolbox.ToolBox toolbox.JavapTask
|
|
30 |
* @run main JavapNotPrintingDefaultModifierTest
|
|
31 |
*/
|
|
32 |
|
|
33 |
import java.nio.file.*;
|
|
34 |
import java.util.*;
|
|
35 |
|
|
36 |
import toolbox.JavapTask;
|
|
37 |
import toolbox.TestRunner;
|
|
38 |
import toolbox.ToolBox;
|
|
39 |
import toolbox.Task;
|
|
40 |
|
|
41 |
public class JavapNotPrintingDefaultModifierTest extends TestRunner {
|
|
42 |
ToolBox tb = new ToolBox();
|
|
43 |
|
|
44 |
interface SimpleInterface {
|
|
45 |
default void defaultMethod() {}
|
|
46 |
void foo();
|
|
47 |
}
|
|
48 |
|
55246
|
49 |
private static final List<String> expectedOutput = List.of(
|
|
50 |
"Compiled from \"JavapNotPrintingDefaultModifierTest.java\"",
|
|
51 |
"interface JavapNotPrintingDefaultModifierTest$SimpleInterface {",
|
|
52 |
" public default void defaultMethod();",
|
|
53 |
" public abstract void foo();",
|
|
54 |
"}");
|
55242
|
55 |
|
|
56 |
JavapNotPrintingDefaultModifierTest() throws Exception {
|
|
57 |
super(System.err);
|
|
58 |
}
|
|
59 |
|
|
60 |
public static void main(String... args) throws Exception {
|
|
61 |
JavapNotPrintingDefaultModifierTest tester = new JavapNotPrintingDefaultModifierTest();
|
|
62 |
tester.runTests();
|
|
63 |
}
|
|
64 |
|
|
65 |
protected void runTests() throws Exception {
|
|
66 |
runTests(m -> new Object[] { Paths.get(m.getName()) });
|
|
67 |
}
|
|
68 |
|
|
69 |
@Test
|
|
70 |
public void testMain(Path base) throws Exception {
|
|
71 |
Path testClassesPath = Paths.get(System.getProperty("test.classes"));
|
55246
|
72 |
List<String> output = new JavapTask(tb)
|
55242
|
73 |
.options("-p", testClassesPath.resolve(this.getClass().getSimpleName() + "$SimpleInterface.class").toString())
|
|
74 |
.run()
|
|
75 |
.writeAll()
|
55246
|
76 |
.getOutputLines(Task.OutputKind.DIRECT);
|
|
77 |
System.out.println(output);
|
|
78 |
if (!output.equals(expectedOutput)) {
|
55242
|
79 |
throw new AssertionError(String.format("unexpected output:\n %s", output));
|
|
80 |
}
|
|
81 |
}
|
|
82 |
}
|