author | jlahoda |
Wed, 27 Aug 2014 07:44:00 +0200 | |
changeset 26266 | 2d24bda701dc |
parent 25874 | 83c19f00452c |
permissions | -rw-r--r-- |
3996
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
1 |
/* |
5520 | 2 |
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. |
3996
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
4 |
* |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
5520 | 7 |
* published by the Free Software Foundation. Oracle designates this |
3996
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
5520 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
3996
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
10 |
* |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
15 |
* accompanied this code). |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
16 |
* |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
20 |
* |
5520 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
3996
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
24 |
*/ |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
25 |
|
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
26 |
package com.sun.tools.javah; |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
27 |
|
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
28 |
import java.io.InputStream; |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
29 |
import java.io.OutputStream; |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
30 |
import java.io.Writer; |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
31 |
import java.nio.charset.Charset; |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
32 |
import java.util.Arrays; |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
33 |
import java.util.EnumSet; |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
34 |
import java.util.Locale; |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
35 |
import java.util.Set; |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
36 |
import javax.lang.model.SourceVersion; |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
37 |
import javax.tools.DiagnosticListener; |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
38 |
import javax.tools.JavaFileManager; |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
39 |
import javax.tools.JavaFileObject; |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
40 |
import javax.tools.StandardJavaFileManager; |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
41 |
|
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
42 |
import com.sun.tools.javac.util.DefinedBy; |
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
43 |
import com.sun.tools.javac.util.DefinedBy.Api; |
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
44 |
|
3996
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
45 |
/* |
5847
1908176fd6e3
6944312: Potential rebranding issues in openjdk/langtools repository sources
jjg
parents:
5520
diff
changeset
|
46 |
* <p><b>This is NOT part of any supported API. |
3996
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
47 |
* If you write code that depends on this, you do so at your own |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
48 |
* risk. This code and its internal interfaces are subject to change |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
49 |
* or deletion without notice.</b></p> |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
50 |
*/ |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
51 |
public class JavahTool implements NativeHeaderTool { |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
52 |
|
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
53 |
public NativeHeaderTask getTask(Writer out, |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
54 |
JavaFileManager fileManager, |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
55 |
DiagnosticListener<? super JavaFileObject> diagnosticListener, |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
56 |
Iterable<String> options, |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
57 |
Iterable<String> classes) { |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
58 |
return new JavahTask(out, fileManager, diagnosticListener, options, classes); |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
59 |
} |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
60 |
|
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
61 |
public StandardJavaFileManager getStandardFileManager(DiagnosticListener<? super JavaFileObject> diagnosticListener, Locale locale, Charset charset) { |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
62 |
return JavahTask.getDefaultFileManager(diagnosticListener, null); |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
63 |
} |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
64 |
|
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
65 |
@DefinedBy(Api.COMPILER) |
3996
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
66 |
public int run(InputStream in, OutputStream out, OutputStream err, String... arguments) { |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
67 |
JavahTask t = new JavahTask( |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
68 |
JavahTask.getPrintWriterForStream(out), |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
69 |
null, |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
70 |
null, |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
71 |
Arrays.asList(arguments), |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
72 |
null); |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
73 |
return (t.run() ? 0 : 1); |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
74 |
} |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
75 |
|
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
76 |
@DefinedBy(Api.COMPILER) |
3996
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
77 |
public Set<SourceVersion> getSourceVersions() { |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
78 |
return EnumSet.allOf(SourceVersion.class); |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
79 |
} |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
80 |
|
26266
2d24bda701dc
8056061: Mark implementations of public interfaces with an annotation
jlahoda
parents:
25874
diff
changeset
|
81 |
@DefinedBy(Api.COMPILER) |
3996
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
82 |
public int isSupportedOption(String option) { |
22159
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
5847
diff
changeset
|
83 |
for (JavahTask.Option opt : JavahTask.recognizedOptions) { |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
5847
diff
changeset
|
84 |
if (opt.matches(option)) |
682da512ec17
8030253: Update langtools to use strings-in-switch
briangoetz
parents:
5847
diff
changeset
|
85 |
return (opt.hasArg ? 1 : 0); |
3996
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
86 |
} |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
87 |
return -1; |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
88 |
} |
dc676a9093b3
6572945: javah should be written as an annotation processor, not a doclet
jjg
parents:
diff
changeset
|
89 |
} |