/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* Wrap objects to enable unchecked exceptions to be caught and handled.
*
* For each method, exceptions are handled as follows:
* <ul>
* <li>Checked exceptions are left alone and propogate upwards in the
* obvious way, since they are an expected aspect of the method's
* specification.
* <li>Unchecked exceptions which have already been caught and wrapped in
* ClientCodeException are left alone to continue propogating upwards.
* <li>All other unchecked exceptions (i.e. subtypes of RuntimeException
* and Error) and caught, and rethrown as a ClientCodeException with
* its cause set to the original exception.
* </ul>
*
* The intent is that ClientCodeException can be caught at an appropriate point
* in the program and can be distinguished from any unanticipated unchecked
* exceptions arising in the main body of the code (i.e. bugs.) When the
* ClientCodeException has been caught, either a suitable message can be
* generated, or if appropriate, the original cause can be rethrown.
*
* <p><b>This is NOT part of any supported API.
* If you write code that depends on this, you do so at your own risk.
* This code and its internal interfaces are subject to change or
* deletion without notice.</b>
*/
public class ClientCodeWrapper {
public @interface Trusted { }
return instance;
}
/**
* A map to cache the results of whether or not a specific classes can
* be "trusted", and thus does not need to be wrapped.
*/
}
return fm;
return new WrappedJavaFileManager(fm);
}
return fo;
return new WrappedFileObject(fo);
}
if (fo instanceof WrappedFileObject)
else
return fo;
}
return fo;
return new WrappedJavaFileObject(fo);
}
}
if (fo instanceof WrappedJavaFileObject)
else
return fo;
}
return dl;
return new WrappedDiagnosticListener<T>(dl);
}
return tl;
return new WrappedTaskListener(tl);
}
@SuppressWarnings("unchecked")
if (diagnostic instanceof JCDiagnostic) {
return (Diagnostic<T>) new DiagnosticSourceUnwrapper(d);
} else {
return diagnostic;
}
}
|| c.isAnnotationPresent(Trusted.class);
}
return trusted;
}
// <editor-fold defaultstate="collapsed" desc="Wrapper classes">
// FIXME: all these classes should be converted to use multi-catch when
// that is available in the bootstrap compiler.
}
try {
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
public Iterable<JavaFileObject> list(Location location, String packageName, Set<Kind> kinds, boolean recurse) throws IOException {
try {
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
try {
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
try {
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
try {
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
try {
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
public JavaFileObject getJavaFileForInput(Location location, String className, Kind kind) throws IOException {
try {
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
public JavaFileObject getJavaFileForOutput(Location location, String className, Kind kind, FileObject sibling) throws IOException {
try {
return wrap(clientJavaFileManager.getJavaFileForOutput(location, className, kind, unwrap(sibling)));
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
public FileObject getFileForInput(Location location, String packageName, String relativeName) throws IOException {
try {
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
public FileObject getFileForOutput(Location location, String packageName, String relativeName, FileObject sibling) throws IOException {
try {
return wrap(clientJavaFileManager.getFileForOutput(location, packageName, relativeName, unwrap(sibling)));
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
try {
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
try {
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
try {
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
}
this.clientFileObject = clientFileObject;
}
try {
return clientFileObject.toUri();
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
try {
return clientFileObject.getName();
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
try {
return clientFileObject.openInputStream();
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
try {
return clientFileObject.openOutputStream();
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
try {
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
try {
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
try {
return clientFileObject.openWriter();
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
public long getLastModified() {
try {
return clientFileObject.getLastModified();
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
public boolean delete() {
try {
return clientFileObject.delete();
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
}
super(clientJavaFileObject);
}
try {
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
try {
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
try {
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
try {
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
}
protected class WrappedDiagnosticListener<T /*super JavaFileObject*/> implements DiagnosticListener<T> {
}
try {
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
}
public final JCDiagnostic d;
this.d = d;
}
return d.getKind();
}
}
public long getPosition() {
return d.getPosition();
}
public long getStartPosition() {
return d.getStartPosition();
}
public long getEndPosition() {
return d.getEndPosition();
}
public long getLineNumber() {
return d.getLineNumber();
}
public long getColumnNumber() {
return d.getColumnNumber();
}
return d.getCode();
}
return d.getMessage(locale);
}
return d.toString();
}
}
this.clientTaskListener = clientTaskListener;
}
try {
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
try {
} catch (ClientCodeException e) {
throw e;
} catch (RuntimeException e) {
throw new ClientCodeException(e);
} catch (Error e) {
throw new ClientCodeException(e);
}
}
}
// </editor-fold>
}