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