author | amurillo |
Thu, 13 Aug 2015 15:50:52 -0700 | |
changeset 32224 | dae855d05f6c |
parent 31115 | 8d8e98052d5d |
child 32337 | c9d3ab9f601c |
permissions | -rw-r--r-- |
26991
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
1 |
/* |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
26991
diff
changeset
|
2 |
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. |
26991
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
4 |
* |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
10 |
* |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
15 |
* accompanied this code). |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
16 |
* |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
20 |
* |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
23 |
* questions. |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
24 |
*/ |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
25 |
|
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
26 |
/* |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
27 |
* @test |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
28 |
* @bug 8056258 |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
29 |
* @summary Analysis of public API does not take super classes into account |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
30 |
* @library /tools/lib |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
26991
diff
changeset
|
31 |
* @modules jdk.compiler/com.sun.tools.javac.api |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
26991
diff
changeset
|
32 |
* jdk.compiler/com.sun.tools.javac.file |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
26991
diff
changeset
|
33 |
* jdk.compiler/com.sun.tools.javac.main |
26991
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
34 |
* @build Wrapper ToolBox |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
35 |
* @run main Wrapper IncCompInheritance |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
36 |
*/ |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
37 |
|
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
38 |
import java.nio.file.Path; |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
39 |
import java.nio.file.Paths; |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
40 |
|
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
41 |
public class IncCompInheritance extends SjavacBase { |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
42 |
public static void main(String... args) throws Exception { |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
43 |
|
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
44 |
Path root = Paths.get(IncCompInheritance.class.getSimpleName() + "Test"); |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
45 |
Path src = root.resolve("src"); |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
46 |
Path classes = root.resolve("classes"); |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
47 |
|
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
48 |
// Prep source files: A <- B <- C |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
49 |
String a = "package pkga; public class A { public void m() {} }"; |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
50 |
String b = "package pkgb; public class B extends pkga.A {}"; |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
51 |
String c = "package pkgc; public class C extends pkgb.B {{ new pkgb.B().m(); }}"; |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
52 |
toolbox.writeFile(src.resolve("pkga/A.java"), a); |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
53 |
toolbox.writeFile(src.resolve("pkgb/B.java"), b); |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
54 |
toolbox.writeFile(src.resolve("pkgc/C.java"), c); |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
55 |
|
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
56 |
// Initial compile (should succeed) |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
57 |
String server = "--server:portfile=testserver,background=false"; |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
58 |
int rc1 = compile(server, "-d", classes, src); |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
59 |
if (rc1 != 0) |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
60 |
throw new AssertionError("Compilation failed unexpectedly"); |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
61 |
|
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
62 |
// Remove method A.m |
31115
8d8e98052d5d
8054717: SJavac should track changes in the public apis of classpath classes!
alundblad
parents:
30730
diff
changeset
|
63 |
Thread.sleep(2500); // Make sure we get a new timestamp |
26991
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
64 |
String aModified = "package pkga; public class A { }"; |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
65 |
toolbox.writeFile(src.resolve("pkga/A.java"), aModified); |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
66 |
|
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
67 |
// Incremental compile (C should now be recompiled even though it |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
68 |
// depends on A only through inheritance via B). |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
69 |
// Since A.m is removed, this should fail. |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
70 |
int rc2 = compile(server, "-d", classes, src); |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
71 |
if (rc2 == 0) |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
72 |
throw new AssertionError("Compilation succeeded unexpectedly"); |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
73 |
} |
88d998b3bb4b
8056258: Analysis of public API does not take super classes into account
alundblad
parents:
diff
changeset
|
74 |
} |