author | peterz |
Fri, 28 May 2010 13:32:40 +0400 | |
changeset 5594 | 3db39773da2e |
parent 164 | c1e219636b4e |
child 5520 | 86e4b9a9da40 |
permissions | -rw-r--r-- |
164
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
1 |
/* |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
2 |
* Copyright 2008 Sun Microsystems, Inc. All Rights Reserved. |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
4 |
* |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
8 |
* |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
13 |
* accompanied this code). |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
14 |
* |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
18 |
* |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
19 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
20 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
21 |
* have any questions. |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
22 |
*/ |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
23 |
|
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
24 |
/* |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
25 |
* @test |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
26 |
* @bug 6608214 |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
27 |
* @summary Exception throw while analysing a file with error |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
28 |
* @author Maurizio Cimadamore |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
29 |
*/ |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
30 |
|
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
31 |
import com.sun.source.util.JavacTask; |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
32 |
import java.io.IOException; |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
33 |
import java.net.URI; |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
34 |
import java.util.Arrays; |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
35 |
import java.util.List; |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
36 |
import javax.tools.JavaCompiler; |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
37 |
import javax.tools.JavaFileObject; |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
38 |
import javax.tools.SimpleJavaFileObject; |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
39 |
import javax.tools.ToolProvider; |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
40 |
import static javax.tools.JavaFileObject.Kind; |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
41 |
|
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
42 |
public class T6608214 { |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
43 |
public static void main(String[] args) throws IOException { |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
44 |
JavaFileObject sfo = new SimpleJavaFileObject(URI.create(""),Kind.SOURCE) { |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
45 |
public CharSequence getCharContent(boolean ignoreEncodingErrors) { |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
46 |
return "class Test<S> { <T extends S & Runnable> void test(){}}"; |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
47 |
} |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
48 |
}; |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
49 |
List<? extends JavaFileObject> files = Arrays.asList(sfo); |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
50 |
String bootPath = System.getProperty("sun.boot.class.path"); |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
51 |
List<String> opts = Arrays.asList("-bootclasspath", bootPath, "-Xjcov"); |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
52 |
JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
53 |
JavacTask ct = (JavacTask)tool.getTask(null, null, null,opts,null,files); |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
54 |
ct.analyze(); |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
55 |
} |
c1e219636b4e
6608214: Exception throw while analysing a file with error
mcimadamore
parents:
diff
changeset
|
56 |
} |