T7142086.java revision 1165
0N/A/*
579N/A * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
0N/A * published by the Free Software Foundation.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
0N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0N/A * or visit www.oracle.com if you need additional information or have any
0N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A * @test
0N/A * @bug 7142086
0N/A * @summary performance problem in Check.checkOverrideClashes(...)
0N/A * @run main/timeout=10 T7142086
0N/A */
0N/A
0N/Aimport com.sun.source.util.JavacTask;
0N/Aimport java.net.URI;
0N/Aimport java.util.List;
0N/Aimport java.util.ArrayList;
0N/Aimport java.util.Locale;
0N/Aimport javax.tools.Diagnostic;
0N/Aimport javax.tools.JavaCompiler;
0N/Aimport javax.tools.JavaFileObject;
0N/Aimport javax.tools.SimpleJavaFileObject;
0N/Aimport javax.tools.StandardJavaFileManager;
0N/Aimport javax.tools.ToolProvider;
0N/A
0N/Apublic class T7142086 {
0N/A
0N/A final static int N_METHODS = 1000;
295N/A
0N/A static class TestClass extends SimpleJavaFileObject {
0N/A
0N/A String methTemplate = "abstract void m(A#N p);";
0N/A String classTemplate = "abstract class Test { #M }";
0N/A
0N/A String source;
0N/A
0N/A public TestClass() {
0N/A super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
0N/A StringBuilder buf = new StringBuilder();
0N/A for (int i = 0 ; i < N_METHODS ; i++) {
0N/A buf.append(methTemplate.replace("#N", String.valueOf(i)));
0N/A buf.append("\n");
0N/A }
0N/A source = classTemplate.replace("#M", buf.toString());
0N/A }
0N/A
0N/A @Override
0N/A public CharSequence getCharContent(boolean ignoreEncodingErrors) {
0N/A return source;
0N/A }
0N/A }
0N/A
0N/A static class AnSource extends SimpleJavaFileObject {
0N/A
0N/A String classTemplate = "abstract class A#N { }";
0N/A
0N/A String source;
0N/A
0N/A public AnSource(int n) {
0N/A super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
0N/A source = classTemplate.replace("#N", String.valueOf(n));
0N/A }
0N/A
0N/A @Override
0N/A public CharSequence getCharContent(boolean ignoreEncodingErrors) {
0N/A return source;
0N/A }
0N/A }
0N/A
0N/A public static void main(String... args) throws Exception {
0N/A ArrayList<JavaFileObject> sources = new ArrayList<>();
0N/A for (int i = 0 ; i < N_METHODS ; i++) {
0N/A sources.add(new AnSource(i));
0N/A }
0N/A sources.add(new TestClass());
0N/A new T7142086().run(sources);
0N/A }
0N/A
0N/A void run(List<JavaFileObject> sources) throws Exception {
0N/A DiagnosticChecker dc = new DiagnosticChecker();
0N/A JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
0N/A StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null);
0N/A JavacTask ct = (JavacTask)comp.getTask(null, fm, dc,
0N/A null, null, sources);
0N/A ct.analyze();
0N/A }
0N/A
0N/A static class DiagnosticChecker implements javax.tools.DiagnosticListener<JavaFileObject> {
0N/A
0N/A boolean errorFound;
0N/A
0N/A public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
0N/A if (diagnostic.getKind() == Diagnostic.Kind.ERROR) {
0N/A throw new AssertionError("unexpected diagnostic: " + diagnostic.getMessage(Locale.getDefault()));
0N/A }
0N/A }
0N/A }
0N/A}
0N/A