author | akulyakh |
Thu, 21 May 2015 11:41:04 -0700 | |
changeset 30730 | d3ce7619db2c |
parent 26264 | a09fedde76be |
child 34560 | b6a567b677f7 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
26264
diff
changeset
|
2 |
* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved. |
10 | 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 |
* |
|
5520 | 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. |
|
10 | 22 |
*/ |
23 |
||
24 |
/* |
|
25 |
* @test |
|
26 |
* @bug 6358166 |
|
27 |
* @summary -verbose reports absurd times when annotation processing involved |
|
30730
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
26264
diff
changeset
|
28 |
* @modules jdk.compiler/com.sun.tools.javac.api |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
26264
diff
changeset
|
29 |
* jdk.compiler/com.sun.tools.javac.file |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
26264
diff
changeset
|
30 |
* jdk.compiler/com.sun.tools.javac.main |
d3ce7619db2c
8076543: Add @modules as needed to the langtools tests
akulyakh
parents:
26264
diff
changeset
|
31 |
* jdk.compiler/com.sun.tools.javac.util |
10 | 32 |
*/ |
33 |
||
34 |
import java.io.*; |
|
35 |
import java.util.*; |
|
26264
a09fedde76be
8044859: javac duplicates option processing when using Compiler API
jjg
parents:
24897
diff
changeset
|
36 |
|
10 | 37 |
import javax.annotation.processing.*; |
38 |
import javax.lang.model.element.*; |
|
39 |
import javax.tools.*; |
|
26264
a09fedde76be
8044859: javac duplicates option processing when using Compiler API
jjg
parents:
24897
diff
changeset
|
40 |
|
a09fedde76be
8044859: javac duplicates option processing when using Compiler API
jjg
parents:
24897
diff
changeset
|
41 |
import com.sun.tools.javac.api.JavacTaskImpl; |
a09fedde76be
8044859: javac duplicates option processing when using Compiler API
jjg
parents:
24897
diff
changeset
|
42 |
import com.sun.tools.javac.api.JavacTool; |
a09fedde76be
8044859: javac duplicates option processing when using Compiler API
jjg
parents:
24897
diff
changeset
|
43 |
import com.sun.tools.javac.file.JavacFileManager; |
10 | 44 |
import com.sun.tools.javac.main.JavaCompiler; |
45 |
import com.sun.tools.javac.util.*; |
|
46 |
import com.sun.tools.javac.util.List; // disambiguate |
|
47 |
||
48 |
||
49 |
@SupportedAnnotationTypes("*") |
|
50 |
public class T6358166 extends AbstractProcessor { |
|
51 |
public static void main(String... args) throws Throwable { |
|
52 |
String self = T6358166.class.getName(); |
|
53 |
||
54 |
String testSrc = System.getProperty("test.src"); |
|
55 |
||
56 |
JavacFileManager fm = new JavacFileManager(new Context(), false, null); |
|
57 |
JavaFileObject f = fm.getFileForInput(testSrc + File.separatorChar + self + ".java"); |
|
58 |
||
59 |
test(fm, f, "-verbose", "-d", "."); |
|
60 |
||
61 |
test(fm, f, "-verbose", "-d", ".", "-XprintRounds", "-processorpath", ".", "-processor", self); |
|
62 |
} |
|
63 |
||
64 |
static void test(JavacFileManager fm, JavaFileObject f, String... args) throws Throwable { |
|
65 |
Context context = new Context(); |
|
66 |
||
26264
a09fedde76be
8044859: javac duplicates option processing when using Compiler API
jjg
parents:
24897
diff
changeset
|
67 |
JavacTool tool = JavacTool.create(); |
a09fedde76be
8044859: javac duplicates option processing when using Compiler API
jjg
parents:
24897
diff
changeset
|
68 |
JavacTaskImpl task = (JavacTaskImpl) tool.getTask(null, fm, null, Arrays.asList(args), null, List.of(f), context); |
a09fedde76be
8044859: javac duplicates option processing when using Compiler API
jjg
parents:
24897
diff
changeset
|
69 |
task.call(); |
10 | 70 |
|
71 |
JavaCompiler c = JavaCompiler.instance(context); |
|
72 |
if (c.errorCount() != 0) |
|
73 |
throw new AssertionError("compilation failed"); |
|
74 |
||
75 |
long msec = c.elapsed_msec; |
|
76 |
if (msec < 0 || msec > 5 * 60 * 1000) // allow test 5 mins to execute, should be more than enough! |
|
77 |
throw new AssertionError("elapsed time is suspect: " + msec); |
|
78 |
} |
|
79 |
||
80 |
public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) { |
|
81 |
return true; |
|
82 |
} |
|
83 |
} |