Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/src/share/classes/com/sun/tools/javah/JavahTool.java
38899 views
/*1* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.sun.tools.javah;2627import java.io.InputStream;28import java.io.OutputStream;29import java.io.Writer;30import java.nio.charset.Charset;31import java.util.Arrays;32import java.util.EnumSet;33import java.util.Locale;34import java.util.Set;35import javax.lang.model.SourceVersion;36import javax.tools.DiagnosticListener;37import javax.tools.JavaFileManager;38import javax.tools.JavaFileObject;39import javax.tools.StandardJavaFileManager;4041/*42* <p><b>This is NOT part of any supported API.43* If you write code that depends on this, you do so at your own44* risk. This code and its internal interfaces are subject to change45* or deletion without notice.</b></p>46*/47public class JavahTool implements NativeHeaderTool {4849public NativeHeaderTask getTask(Writer out,50JavaFileManager fileManager,51DiagnosticListener<? super JavaFileObject> diagnosticListener,52Iterable<String> options,53Iterable<String> classes) {54return new JavahTask(out, fileManager, diagnosticListener, options, classes);55}5657public StandardJavaFileManager getStandardFileManager(DiagnosticListener<? super JavaFileObject> diagnosticListener, Locale locale, Charset charset) {58return JavahTask.getDefaultFileManager(diagnosticListener, null);59}6061public int run(InputStream in, OutputStream out, OutputStream err, String... arguments) {62JavahTask t = new JavahTask(63JavahTask.getPrintWriterForStream(out),64null,65null,66Arrays.asList(arguments),67null);68return (t.run() ? 0 : 1);69}7071public Set<SourceVersion> getSourceVersions() {72return EnumSet.allOf(SourceVersion.class);73}7475public int isSupportedOption(String option) {76JavahTask.Option[] options = JavahTask.recognizedOptions;77for (int i = 0; i < options.length; i++) {78if (options[i].matches(option))79return (options[i].hasArg ? 1 : 0);80}81return -1;82}83}848586