001 /*
002 * Copyright 2005-2008 Sun Microsystems, Inc. All Rights Reserved.
003 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004 *
005 * This code is free software; you can redistribute it and/or modify it
006 * under the terms of the GNU General Public License version 2 only, as
007 * published by the Free Software Foundation. Sun designates this
008 * particular file as subject to the "Classpath" exception as provided
009 * by Sun in the LICENSE file that accompanied this code.
010 *
011 * This code is distributed in the hope that it will be useful, but WITHOUT
012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014 * version 2 for more details (a copy is included in the LICENSE file that
015 * accompanied this code).
016 *
017 * You should have received a copy of the GNU General Public License version
018 * 2 along with this work; if not, write to the Free Software Foundation,
019 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020 *
021 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022 * CA 95054 USA or visit www.sun.com if you need additional information or
023 * have any questions.
024 */
025
026 package com.sun.tools.javap; //javax.tools;
027
028 import java.io.Writer;
029 import java.nio.charset.Charset;
030 import java.util.Locale;
031 import java.util.concurrent.Callable;
032 import javax.tools.DiagnosticListener;
033 import javax.tools.JavaFileManager;
034 import javax.tools.JavaFileObject;
035 import javax.tools.OptionChecker;
036 import javax.tools.StandardJavaFileManager;
037 import javax.tools.Tool;
038
039 /**
040 * This class is intended to be put in javax.tools.
041 *
042 * @see DiagnosticListener
043 * @see Diagnostic
044 * @see JavaFileManager
045 * @since 1.6
046 *
047 * <p><b>This is NOT part of any API supported by Sun Microsystems. If
048 * you write code that depends on this, you do so at your own risk.
049 * This code and its internal interfaces are subject to change or
050 * deletion without notice.</b>
051 */
052 public interface DisassemblerTool extends Tool, OptionChecker {
053
054 /**
055 * Creates a future for a disassembly task with the given
056 * components and arguments. The task might not have
057 * completed as described in the DissemblerTask interface.
058 *
059 * <p>If a file manager is provided, it must be able to handle all
060 * locations defined in {@link StandardLocation}.
061 *
062 * @param out a Writer for additional output from the compiler;
063 * use {@code System.err} if {@code null}
064 * @param fileManager a file manager; if {@code null} use the
065 * compiler's standard filemanager
066 * @param diagnosticListener a diagnostic listener; if {@code
067 * null} use the compiler's default method for reporting
068 * diagnostics
069 * @param options compiler options, {@code null} means no options
070 * @param classes class names (for annotation processing), {@code
071 * null} means no class names
072 * @param compilationUnits the compilation units to compile, {@code
073 * null} means no compilation units
074 * @return an object representing the compilation
075 * @throws RuntimeException if an unrecoverable error
076 * occurred in a user supplied component. The
077 * {@linkplain Throwable#getCause() cause} will be the error in
078 * user code.
079 * @throws IllegalArgumentException if any of the given
080 * compilation units are of other kind than
081 * {@linkplain JavaFileObject.Kind#SOURCE source}
082 */
083 DisassemblerTask getTask(Writer out,
084 JavaFileManager fileManager,
085 DiagnosticListener<? super JavaFileObject> diagnosticListener,
086 Iterable<String> options,
087 Iterable<String> classes);
088
089 /**
090 * Gets a new instance of the standard file manager implementation
091 * for this tool. The file manager will use the given diagnostic
092 * listener for producing any non-fatal diagnostics. Fatal errors
093 * will be signalled with the appropriate exceptions.
094 *
095 * <p>The standard file manager will be automatically reopened if
096 * it is accessed after calls to {@code flush} or {@code close}.
097 * The standard file manager must be usable with other tools.
098 *
099 * @param diagnosticListener a diagnostic listener for non-fatal
100 * diagnostics; if {@code null} use the compiler's default method
101 * for reporting diagnostics
102 * @param locale the locale to apply when formatting diagnostics;
103 * {@code null} means the {@linkplain Locale#getDefault() default locale}.
104 * @param charset the character set used for decoding bytes; if
105 * {@code null} use the platform default
106 * @return the standard file manager
107 */
108 StandardJavaFileManager getStandardFileManager(
109 DiagnosticListener<? super JavaFileObject> diagnosticListener,
110 Locale locale,
111 Charset charset);
112
113 /**
114 * Interface representing a future for a disassembly task. The
115 * task has not yet started. To start the task, call
116 * the {@linkplain #call call} method.
117 *
118 * <p>Before calling the call method, additional aspects of the
119 * task can be configured, for example, by calling the
120 * {@linkplain #setLocale setLocale} method.
121 */
122 interface DisassemblerTask extends Callable<Boolean> {
123
124 /**
125 * Set the locale to be applied when formatting diagnostics and
126 * other localized data.
127 *
128 * @param locale the locale to apply; {@code null} means apply no
129 * locale
130 * @throws IllegalStateException if the task has started
131 */
132 void setLocale(Locale locale);
133
134 /**
135 * Performs this compilation task. The compilation may only
136 * be performed once. Subsequent calls to this method throw
137 * IllegalStateException.
138 *
139 * @return true if and only all the files compiled without errors;
140 * false otherwise
141 *
142 * @throws RuntimeException if an unrecoverable error occurred
143 * in a user-supplied component. The
144 * {@linkplain Throwable#getCause() cause} will be the error
145 * in user code.
146 * @throws IllegalStateException if called more than once
147 */
148 Boolean call();
149 }
150 }