Thu, 07 Jun 2012 20:30:57 -0700
7170079: Adjustments to build-infra makefiles
Reviewed-by: ohair, ohrstrom, ihse, jonas
Contributed-by: jonas <jonas.oreland@oracle.com>, erikj <erik.joelsson@oracle.com>, ihse <magnus.ihse.bursie@oracle.com>, tgranat <torbjorn.granat@oracle.com>, ykantser <yekaterina.kantserova@oracle.com>
1 /*
2 * Copyright (c) 2012, 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 */
24 /*
25 * @test
26 * @bug 7142086
27 * @summary performance problem in Check.checkOverrideClashes(...)
28 * @run main/timeout=10 T7142086
29 */
31 import com.sun.source.util.JavacTask;
32 import java.net.URI;
33 import java.util.List;
34 import java.util.ArrayList;
35 import java.util.Locale;
36 import javax.tools.Diagnostic;
37 import javax.tools.JavaCompiler;
38 import javax.tools.JavaFileObject;
39 import javax.tools.SimpleJavaFileObject;
40 import javax.tools.StandardJavaFileManager;
41 import javax.tools.ToolProvider;
43 public class T7142086 {
45 final static int N_METHODS = 1000;
47 static class TestClass extends SimpleJavaFileObject {
49 String methTemplate = "abstract void m(A#N p);";
50 String classTemplate = "abstract class Test { #M }";
52 String source;
54 public TestClass() {
55 super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
56 StringBuilder buf = new StringBuilder();
57 for (int i = 0 ; i < N_METHODS ; i++) {
58 buf.append(methTemplate.replace("#N", String.valueOf(i)));
59 buf.append("\n");
60 }
61 source = classTemplate.replace("#M", buf.toString());
62 }
64 @Override
65 public CharSequence getCharContent(boolean ignoreEncodingErrors) {
66 return source;
67 }
68 }
70 static class AnSource extends SimpleJavaFileObject {
72 String classTemplate = "abstract class A#N { }";
74 String source;
76 public AnSource(int n) {
77 super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
78 source = classTemplate.replace("#N", String.valueOf(n));
79 }
81 @Override
82 public CharSequence getCharContent(boolean ignoreEncodingErrors) {
83 return source;
84 }
85 }
87 public static void main(String... args) throws Exception {
88 ArrayList<JavaFileObject> sources = new ArrayList<>();
89 for (int i = 0 ; i < N_METHODS ; i++) {
90 sources.add(new AnSource(i));
91 }
92 sources.add(new TestClass());
93 new T7142086().run(sources);
94 }
96 void run(List<JavaFileObject> sources) throws Exception {
97 DiagnosticChecker dc = new DiagnosticChecker();
98 JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
99 StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
100 JavacTask ct = (JavacTask)comp.getTask(null, fm, dc,
101 null, null, sources);
102 ct.analyze();
103 }
105 static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
107 boolean errorFound;
109 public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
110 if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
111 throw new AssertionError("unexpected diagnostic: " + diagnostic.getMessage(Locale.getDefault()));
112 }
113 }
114 }
115 }