author | sogoel |
Fri, 05 Sep 2014 16:43:00 -0700 | |
changeset 26528 | a1a7ad15183e |
parent 26264 | a09fedde76be |
child 30730 | d3ce7619db2c |
permissions | -rw-r--r-- |
10 | 1 |
/* |
24897
655b72d7b96e
7026941: 199: path options ignored when reusing filemanager across tasks
jjg
parents:
10193
diff
changeset
|
2 |
* Copyright (c) 2006, 2014, 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 |
|
28 |
*/ |
|
29 |
||
30 |
import java.io.*; |
|
31 |
import java.util.*; |
|
26264
a09fedde76be
8044859: javac duplicates option processing when using Compiler API
jjg
parents:
24897
diff
changeset
|
32 |
|
10 | 33 |
import javax.annotation.processing.*; |
34 |
import javax.lang.model.element.*; |
|
35 |
import javax.tools.*; |
|
26264
a09fedde76be
8044859: javac duplicates option processing when using Compiler API
jjg
parents:
24897
diff
changeset
|
36 |
|
a09fedde76be
8044859: javac duplicates option processing when using Compiler API
jjg
parents:
24897
diff
changeset
|
37 |
import com.sun.tools.javac.api.JavacTaskImpl; |
a09fedde76be
8044859: javac duplicates option processing when using Compiler API
jjg
parents:
24897
diff
changeset
|
38 |
import com.sun.tools.javac.api.JavacTool; |
a09fedde76be
8044859: javac duplicates option processing when using Compiler API
jjg
parents:
24897
diff
changeset
|
39 |
import com.sun.tools.javac.file.JavacFileManager; |
10 | 40 |
import com.sun.tools.javac.main.JavaCompiler; |
41 |
import com.sun.tools.javac.util.*; |
|
42 |
import com.sun.tools.javac.util.List; // disambiguate |
|
43 |
||
44 |
||
45 |
@SupportedAnnotationTypes("*") |
|
46 |
public class T6358166 extends AbstractProcessor { |
|
47 |
public static void main(String... args) throws Throwable { |
|
48 |
String self = T6358166.class.getName(); |
|
49 |
||
50 |
String testSrc = System.getProperty("test.src"); |
|
51 |
||
52 |
JavacFileManager fm = new JavacFileManager(new Context(), false, null); |
|
53 |
JavaFileObject f = fm.getFileForInput(testSrc + File.separatorChar + self + ".java"); |
|
54 |
||
55 |
test(fm, f, "-verbose", "-d", "."); |
|
56 |
||
57 |
test(fm, f, "-verbose", "-d", ".", "-XprintRounds", "-processorpath", ".", "-processor", self); |
|
58 |
} |
|
59 |
||
60 |
static void test(JavacFileManager fm, JavaFileObject f, String... args) throws Throwable { |
|
61 |
Context context = new Context(); |
|
62 |
||
26264
a09fedde76be
8044859: javac duplicates option processing when using Compiler API
jjg
parents:
24897
diff
changeset
|
63 |
JavacTool tool = JavacTool.create(); |
a09fedde76be
8044859: javac duplicates option processing when using Compiler API
jjg
parents:
24897
diff
changeset
|
64 |
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
|
65 |
task.call(); |
10 | 66 |
|
67 |
JavaCompiler c = JavaCompiler.instance(context); |
|
68 |
if (c.errorCount() != 0) |
|
69 |
throw new AssertionError("compilation failed"); |
|
70 |
||
71 |
long msec = c.elapsed_msec; |
|
72 |
if (msec < 0 || msec > 5 * 60 * 1000) // allow test 5 mins to execute, should be more than enough! |
|
73 |
throw new AssertionError("elapsed time is suspect: " + msec); |
|
74 |
} |
|
75 |
||
76 |
public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) { |
|
77 |
return true; |
|
78 |
} |
|
79 |
} |