src/share/classes/com/sun/tools/javah/NativeHeaderTool.java

Wed, 02 Jun 2010 19:08:47 -0700

author
darcy
date
Wed, 02 Jun 2010 19:08:47 -0700
changeset 575
9a7c998bf2fc
parent 554
9d9f26857129
child 581
f2fdd52e4e87
permissions
-rw-r--r--

6933147: Provided new utility visitors supporting SourceVersion.RELEASE_7
Reviewed-by: jjg

jjg@416 1 /*
ohair@554 2 * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
jjg@416 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
jjg@416 4 *
jjg@416 5 * This code is free software; you can redistribute it and/or modify it
jjg@416 6 * under the terms of the GNU General Public License version 2 only, as
ohair@554 7 * published by the Free Software Foundation. Oracle designates this
jjg@416 8 * particular file as subject to the "Classpath" exception as provided
ohair@554 9 * by Oracle in the LICENSE file that accompanied this code.
jjg@416 10 *
jjg@416 11 * This code is distributed in the hope that it will be useful, but WITHOUT
jjg@416 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
jjg@416 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
jjg@416 14 * version 2 for more details (a copy is included in the LICENSE file that
jjg@416 15 * accompanied this code).
jjg@416 16 *
jjg@416 17 * You should have received a copy of the GNU General Public License version
jjg@416 18 * 2 along with this work; if not, write to the Free Software Foundation,
jjg@416 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
jjg@416 20 *
ohair@554 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ohair@554 22 * or visit www.oracle.com if you need additional information or have any
ohair@554 23 * questions.
jjg@416 24 */
jjg@416 25
jjg@416 26 package com.sun.tools.javah; //javax.tools;
jjg@416 27
jjg@416 28 import java.io.Writer;
jjg@416 29 import java.nio.charset.Charset;
jjg@416 30 import java.util.Locale;
jjg@416 31 import java.util.concurrent.Callable;
jjg@416 32 import javax.tools.DiagnosticListener;
jjg@416 33 import javax.tools.JavaFileManager;
jjg@416 34 import javax.tools.JavaFileObject;
jjg@416 35 import javax.tools.OptionChecker;
jjg@416 36 import javax.tools.StandardJavaFileManager;
jjg@416 37 import javax.tools.Tool;
jjg@416 38
jjg@416 39 /**
jjg@416 40 * This class is intended to be put in javax.tools.
jjg@416 41 *
jjg@416 42 * @see DiagnosticListener
jjg@416 43 * @see Diagnostic
jjg@416 44 * @see JavaFileManager
jjg@416 45 * @since 1.7
jjg@416 46 *
jjg@416 47 * <p><b>This is NOT part of any API supported by Sun Microsystems. If
jjg@416 48 * you write code that depends on this, you do so at your own risk.
jjg@416 49 * This code and its internal interfaces are subject to change or
jjg@416 50 * deletion without notice.</b>
jjg@416 51 */
jjg@416 52 public interface NativeHeaderTool extends Tool, OptionChecker {
jjg@416 53
jjg@416 54 /**
jjg@416 55 * Creates a future for a native header task with the given
jjg@416 56 * components and arguments. The task might not have
jjg@416 57 * completed as described in the NativeHeaderTask interface.
jjg@416 58 *
jjg@416 59 * <p>If a file manager is provided, it must be able to handle all
jjg@416 60 * locations defined in {@link StandardLocation}.
jjg@416 61 *
jjg@416 62 * @param out a Writer for additional output from the task;
jjg@416 63 * use {@code System.err} if {@code null}
jjg@416 64 * @param fileManager a file manager; if {@code null} use the
jjg@416 65 * task's standard filemanager
jjg@416 66 * @param diagnosticListener a diagnostic listener; if {@code
jjg@416 67 * null} use the compiler's default method for reporting
jjg@416 68 * diagnostics
jjg@416 69 * @param options task options, {@code null} means no options
jjg@416 70 * @param classes class names for which native headers should be generated
jjg@416 71 * @return an object representing the task to be done
jjg@416 72 * @throws RuntimeException if an unrecoverable error
jjg@416 73 * occurred in a user supplied component. The
jjg@416 74 * {@linkplain Throwable#getCause() cause} will be the error in
jjg@416 75 * user code.
jjg@416 76 * @throws IllegalArgumentException if any of the given
jjg@416 77 * compilation units are of other kind than
jjg@416 78 * {@linkplain JavaFileObject.Kind#SOURCE source}
jjg@416 79 */
jjg@416 80 NativeHeaderTask getTask(Writer out,
jjg@416 81 JavaFileManager fileManager,
jjg@416 82 DiagnosticListener<? super JavaFileObject> diagnosticListener,
jjg@416 83 Iterable<String> options,
jjg@416 84 Iterable<String> classes);
jjg@416 85
jjg@416 86 /**
jjg@416 87 * Gets a new instance of the standard file manager implementation
jjg@416 88 * for this tool. The file manager will use the given diagnostic
jjg@416 89 * listener for producing any non-fatal diagnostics. Fatal errors
jjg@416 90 * will be signalled with the appropriate exceptions.
jjg@416 91 *
jjg@416 92 * <p>The standard file manager will be automatically reopened if
jjg@416 93 * it is accessed after calls to {@code flush} or {@code close}.
jjg@416 94 * The standard file manager must be usable with other tools.
jjg@416 95 *
jjg@416 96 * @param diagnosticListener a diagnostic listener for non-fatal
jjg@416 97 * diagnostics; if {@code null} use the tool's default method
jjg@416 98 * for reporting diagnostics
jjg@416 99 * @param locale the locale to apply when formatting diagnostics;
jjg@416 100 * {@code null} means the {@linkplain Locale#getDefault() default locale}.
jjg@416 101 * @param charset the character set used for decoding bytes; if
jjg@416 102 * {@code null} use the platform default
jjg@416 103 * @return the standard file manager
jjg@416 104 */
jjg@416 105 StandardJavaFileManager getStandardFileManager(
jjg@416 106 DiagnosticListener<? super JavaFileObject> diagnosticListener,
jjg@416 107 Locale locale,
jjg@416 108 Charset charset);
jjg@416 109
jjg@416 110 /**
jjg@416 111 * Interface representing a future for a native header task. The
jjg@416 112 * task has not yet started. To start the task, call
jjg@416 113 * the {@linkplain #call call} method.
jjg@416 114 *
jjg@416 115 * <p>Before calling the call method, additional aspects of the
jjg@416 116 * task can be configured, for example, by calling the
jjg@416 117 * {@linkplain #setLocale setLocale} method.
jjg@416 118 */
jjg@416 119 interface NativeHeaderTask extends Callable<Boolean> {
jjg@416 120
jjg@416 121 /**
jjg@416 122 * Set the locale to be applied when formatting diagnostics and
jjg@416 123 * other localized data.
jjg@416 124 *
jjg@416 125 * @param locale the locale to apply; {@code null} means apply no
jjg@416 126 * locale
jjg@416 127 * @throws IllegalStateException if the task has started
jjg@416 128 */
jjg@416 129 void setLocale(Locale locale);
jjg@416 130
jjg@416 131 /**
jjg@416 132 * Performs this native header task. The task may only
jjg@416 133 * be performed once. Subsequent calls to this method throw
jjg@416 134 * IllegalStateException.
jjg@416 135 *
jjg@416 136 * @return true if and only all the files were processed without errors;
jjg@416 137 * false otherwise
jjg@416 138 *
jjg@416 139 * @throws RuntimeException if an unrecoverable error occurred
jjg@416 140 * in a user-supplied component. The
jjg@416 141 * {@linkplain Throwable#getCause() cause} will be the error
jjg@416 142 * in user code.
jjg@416 143 * @throws IllegalStateException if called more than once
jjg@416 144 */
jjg@416 145 Boolean call();
jjg@416 146 }
jjg@416 147 }

mercurial