Path: blob/aarch64-shenandoah-jdk8u272-b10/langtools/src/share/classes/com/sun/tools/javah/NativeHeaderTool.java
38899 views
/*1* Copyright (c) 2005, 2012, 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; //javax.tools;2627import java.io.Writer;28import java.nio.charset.Charset;29import java.util.Locale;30import java.util.concurrent.Callable;31import javax.tools.Diagnostic;32import javax.tools.DiagnosticListener;33import javax.tools.JavaFileManager;34import javax.tools.JavaFileObject;35import javax.tools.OptionChecker;36import javax.tools.StandardJavaFileManager;37import javax.tools.StandardLocation;38import javax.tools.Tool;3940/**41* This class is intended to be put in javax.tools.42*43* @see DiagnosticListener44* @see Diagnostic45* @see JavaFileManager46* @since 1.747*48* <p><b>This is NOT part of any supported API.49* If you write code that depends on this, you do so at your own risk.50* This code and its internal interfaces are subject to change or51* deletion without notice.</b>52*/53public interface NativeHeaderTool extends Tool, OptionChecker {5455/**56* Creates a future for a native header task with the given57* components and arguments. The task might not have58* completed as described in the NativeHeaderTask interface.59*60* <p>If a file manager is provided, it must be able to handle all61* locations defined in {@link StandardLocation}.62*63* @param out a Writer for additional output from the task;64* use {@code System.err} if {@code null}65* @param fileManager a file manager; if {@code null} use the66* task's standard filemanager67* @param diagnosticListener a diagnostic listener; if {@code68* null} use the compiler's default method for reporting69* diagnostics70* @param options task options, {@code null} means no options71* @param classes class names for which native headers should be generated72* @return an object representing the task to be done73* @throws RuntimeException if an unrecoverable error74* occurred in a user supplied component. The75* {@linkplain Throwable#getCause() cause} will be the error in76* user code.77* @throws IllegalArgumentException if any of the given78* compilation units are of other kind than79* {@linkplain JavaFileObject.Kind#SOURCE source}80*/81NativeHeaderTask getTask(Writer out,82JavaFileManager fileManager,83DiagnosticListener<? super JavaFileObject> diagnosticListener,84Iterable<String> options,85Iterable<String> classes);8687/**88* Gets a new instance of the standard file manager implementation89* for this tool. The file manager will use the given diagnostic90* listener for producing any non-fatal diagnostics. Fatal errors91* will be signalled with the appropriate exceptions.92*93* <p>The standard file manager will be automatically reopened if94* it is accessed after calls to {@code flush} or {@code close}.95* The standard file manager must be usable with other tools.96*97* @param diagnosticListener a diagnostic listener for non-fatal98* diagnostics; if {@code null} use the tool's default method99* for reporting diagnostics100* @param locale the locale to apply when formatting diagnostics;101* {@code null} means the {@linkplain Locale#getDefault() default locale}.102* @param charset the character set used for decoding bytes; if103* {@code null} use the platform default104* @return the standard file manager105*/106StandardJavaFileManager getStandardFileManager(107DiagnosticListener<? super JavaFileObject> diagnosticListener,108Locale locale,109Charset charset);110111/**112* Interface representing a future for a native header task. The113* task has not yet started. To start the task, call114* the {@linkplain #call call} method.115*116* <p>Before calling the call method, additional aspects of the117* task can be configured, for example, by calling the118* {@linkplain #setLocale setLocale} method.119*/120interface NativeHeaderTask extends Callable<Boolean> {121122/**123* Set the locale to be applied when formatting diagnostics and124* other localized data.125*126* @param locale the locale to apply; {@code null} means apply no127* locale128* @throws IllegalStateException if the task has started129*/130void setLocale(Locale locale);131132/**133* Performs this native header task. The task may only134* be performed once. Subsequent calls to this method throw135* IllegalStateException.136*137* @return true if and only all the files were processed without errors;138* false otherwise139*140* @throws RuntimeException if an unrecoverable error occurred141* in a user-supplied component. The142* {@linkplain Throwable#getCause() cause} will be the error143* in user code.144* @throws IllegalStateException if called more than once145*/146Boolean call();147}148}149150151