1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/classes/com/sun/tools/javah/NativeHeaderTool.java Wed Sep 23 19:15:04 2009 -0700 1.3 @@ -0,0 +1,147 @@ 1.4 +/* 1.5 + * Copyright 2005-2006 Sun Microsystems, Inc. All Rights Reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. Sun designates this 1.11 + * particular file as subject to the "Classpath" exception as provided 1.12 + * by Sun in the LICENSE file that accompanied this code. 1.13 + * 1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.17 + * version 2 for more details (a copy is included in the LICENSE file that 1.18 + * accompanied this code). 1.19 + * 1.20 + * You should have received a copy of the GNU General Public License version 1.21 + * 2 along with this work; if not, write to the Free Software Foundation, 1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.23 + * 1.24 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 1.25 + * CA 95054 USA or visit www.sun.com if you need additional information or 1.26 + * have any questions. 1.27 + */ 1.28 + 1.29 +package com.sun.tools.javah; //javax.tools; 1.30 + 1.31 +import java.io.Writer; 1.32 +import java.nio.charset.Charset; 1.33 +import java.util.Locale; 1.34 +import java.util.concurrent.Callable; 1.35 +import javax.tools.DiagnosticListener; 1.36 +import javax.tools.JavaFileManager; 1.37 +import javax.tools.JavaFileObject; 1.38 +import javax.tools.OptionChecker; 1.39 +import javax.tools.StandardJavaFileManager; 1.40 +import javax.tools.Tool; 1.41 + 1.42 +/** 1.43 + * This class is intended to be put in javax.tools. 1.44 + * 1.45 + * @see DiagnosticListener 1.46 + * @see Diagnostic 1.47 + * @see JavaFileManager 1.48 + * @since 1.7 1.49 + * 1.50 + * <p><b>This is NOT part of any API supported by Sun Microsystems. If 1.51 + * you write code that depends on this, you do so at your own risk. 1.52 + * This code and its internal interfaces are subject to change or 1.53 + * deletion without notice.</b> 1.54 + */ 1.55 +public interface NativeHeaderTool extends Tool, OptionChecker { 1.56 + 1.57 + /** 1.58 + * Creates a future for a native header task with the given 1.59 + * components and arguments. The task might not have 1.60 + * completed as described in the NativeHeaderTask interface. 1.61 + * 1.62 + * <p>If a file manager is provided, it must be able to handle all 1.63 + * locations defined in {@link StandardLocation}. 1.64 + * 1.65 + * @param out a Writer for additional output from the task; 1.66 + * use {@code System.err} if {@code null} 1.67 + * @param fileManager a file manager; if {@code null} use the 1.68 + * task's standard filemanager 1.69 + * @param diagnosticListener a diagnostic listener; if {@code 1.70 + * null} use the compiler's default method for reporting 1.71 + * diagnostics 1.72 + * @param options task options, {@code null} means no options 1.73 + * @param classes class names for which native headers should be generated 1.74 + * @return an object representing the task to be done 1.75 + * @throws RuntimeException if an unrecoverable error 1.76 + * occurred in a user supplied component. The 1.77 + * {@linkplain Throwable#getCause() cause} will be the error in 1.78 + * user code. 1.79 + * @throws IllegalArgumentException if any of the given 1.80 + * compilation units are of other kind than 1.81 + * {@linkplain JavaFileObject.Kind#SOURCE source} 1.82 + */ 1.83 + NativeHeaderTask getTask(Writer out, 1.84 + JavaFileManager fileManager, 1.85 + DiagnosticListener<? super JavaFileObject> diagnosticListener, 1.86 + Iterable<String> options, 1.87 + Iterable<String> classes); 1.88 + 1.89 + /** 1.90 + * Gets a new instance of the standard file manager implementation 1.91 + * for this tool. The file manager will use the given diagnostic 1.92 + * listener for producing any non-fatal diagnostics. Fatal errors 1.93 + * will be signalled with the appropriate exceptions. 1.94 + * 1.95 + * <p>The standard file manager will be automatically reopened if 1.96 + * it is accessed after calls to {@code flush} or {@code close}. 1.97 + * The standard file manager must be usable with other tools. 1.98 + * 1.99 + * @param diagnosticListener a diagnostic listener for non-fatal 1.100 + * diagnostics; if {@code null} use the tool's default method 1.101 + * for reporting diagnostics 1.102 + * @param locale the locale to apply when formatting diagnostics; 1.103 + * {@code null} means the {@linkplain Locale#getDefault() default locale}. 1.104 + * @param charset the character set used for decoding bytes; if 1.105 + * {@code null} use the platform default 1.106 + * @return the standard file manager 1.107 + */ 1.108 + StandardJavaFileManager getStandardFileManager( 1.109 + DiagnosticListener<? super JavaFileObject> diagnosticListener, 1.110 + Locale locale, 1.111 + Charset charset); 1.112 + 1.113 + /** 1.114 + * Interface representing a future for a native header task. The 1.115 + * task has not yet started. To start the task, call 1.116 + * the {@linkplain #call call} method. 1.117 + * 1.118 + * <p>Before calling the call method, additional aspects of the 1.119 + * task can be configured, for example, by calling the 1.120 + * {@linkplain #setLocale setLocale} method. 1.121 + */ 1.122 + interface NativeHeaderTask extends Callable<Boolean> { 1.123 + 1.124 + /** 1.125 + * Set the locale to be applied when formatting diagnostics and 1.126 + * other localized data. 1.127 + * 1.128 + * @param locale the locale to apply; {@code null} means apply no 1.129 + * locale 1.130 + * @throws IllegalStateException if the task has started 1.131 + */ 1.132 + void setLocale(Locale locale); 1.133 + 1.134 + /** 1.135 + * Performs this native header task. The task may only 1.136 + * be performed once. Subsequent calls to this method throw 1.137 + * IllegalStateException. 1.138 + * 1.139 + * @return true if and only all the files were processed without errors; 1.140 + * false otherwise 1.141 + * 1.142 + * @throws RuntimeException if an unrecoverable error occurred 1.143 + * in a user-supplied component. The 1.144 + * {@linkplain Throwable#getCause() cause} will be the error 1.145 + * in user code. 1.146 + * @throws IllegalStateException if called more than once 1.147 + */ 1.148 + Boolean call(); 1.149 + } 1.150 +}