1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/classes/com/sun/tools/javap/DisassemblerTool.java Tue Jun 03 13:26:47 2008 -0700 1.3 @@ -0,0 +1,150 @@ 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.javap; //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.6 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 DisassemblerTool extends Tool, OptionChecker { 1.56 + 1.57 + /** 1.58 + * Creates a future for a disassembly task with the given 1.59 + * components and arguments. The task might not have 1.60 + * completed as described in the DissemblerTask 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 compiler; 1.66 + * use {@code System.err} if {@code null} 1.67 + * @param fileManager a file manager; if {@code null} use the 1.68 + * compiler'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 compiler options, {@code null} means no options 1.73 + * @param classes class names (for annotation processing), {@code 1.74 + * null} means no class names 1.75 + * @param compilationUnits the compilation units to compile, {@code 1.76 + * null} means no compilation units 1.77 + * @return an object representing the compilation 1.78 + * @throws RuntimeException if an unrecoverable error 1.79 + * occurred in a user supplied component. The 1.80 + * {@linkplain Throwable#getCause() cause} will be the error in 1.81 + * user code. 1.82 + * @throws IllegalArgumentException if any of the given 1.83 + * compilation units are of other kind than 1.84 + * {@linkplain JavaFileObject.Kind#SOURCE source} 1.85 + */ 1.86 + DisassemblerTask getTask(Writer out, 1.87 + JavaFileManager fileManager, 1.88 + DiagnosticListener<? super JavaFileObject> diagnosticListener, 1.89 + Iterable<String> options, 1.90 + Iterable<String> classes); 1.91 + 1.92 + /** 1.93 + * Gets a new instance of the standard file manager implementation 1.94 + * for this tool. The file manager will use the given diagnostic 1.95 + * listener for producing any non-fatal diagnostics. Fatal errors 1.96 + * will be signalled with the appropriate exceptions. 1.97 + * 1.98 + * <p>The standard file manager will be automatically reopened if 1.99 + * it is accessed after calls to {@code flush} or {@code close}. 1.100 + * The standard file manager must be usable with other tools. 1.101 + * 1.102 + * @param diagnosticListener a diagnostic listener for non-fatal 1.103 + * diagnostics; if {@code null} use the compiler's default method 1.104 + * for reporting diagnostics 1.105 + * @param locale the locale to apply when formatting diagnostics; 1.106 + * {@code null} means the {@linkplain Locale#getDefault() default locale}. 1.107 + * @param charset the character set used for decoding bytes; if 1.108 + * {@code null} use the platform default 1.109 + * @return the standard file manager 1.110 + */ 1.111 + StandardJavaFileManager getStandardFileManager( 1.112 + DiagnosticListener<? super JavaFileObject> diagnosticListener, 1.113 + Locale locale, 1.114 + Charset charset); 1.115 + 1.116 + /** 1.117 + * Interface representing a future for a disassembly task. The 1.118 + * task has not yet started. To start the task, call 1.119 + * the {@linkplain #call call} method. 1.120 + * 1.121 + * <p>Before calling the call method, additional aspects of the 1.122 + * task can be configured, for example, by calling the 1.123 + * {@linkplain #setLocale setLocale} method. 1.124 + */ 1.125 + interface DisassemblerTask extends Callable<Boolean> { 1.126 + 1.127 + /** 1.128 + * Set the locale to be applied when formatting diagnostics and 1.129 + * other localized data. 1.130 + * 1.131 + * @param locale the locale to apply; {@code null} means apply no 1.132 + * locale 1.133 + * @throws IllegalStateException if the task has started 1.134 + */ 1.135 + void setLocale(Locale locale); 1.136 + 1.137 + /** 1.138 + * Performs this compilation task. The compilation may only 1.139 + * be performed once. Subsequent calls to this method throw 1.140 + * IllegalStateException. 1.141 + * 1.142 + * @return true if and only all the files compiled without errors; 1.143 + * false otherwise 1.144 + * 1.145 + * @throws RuntimeException if an unrecoverable error occurred 1.146 + * in a user-supplied component. The 1.147 + * {@linkplain Throwable#getCause() cause} will be the error 1.148 + * in user code. 1.149 + * @throws IllegalStateException if called more than once 1.150 + */ 1.151 + Boolean call(); 1.152 + } 1.153 +}