< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/api/ClientCodeWrapper.java

Print this page


   1 /*
   2  * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  29 import java.io.IOException;
  30 import java.io.InputStream;
  31 import java.io.OutputStream;
  32 import java.io.Reader;
  33 import java.io.Writer;
  34 import java.lang.annotation.ElementType;
  35 import java.lang.annotation.Retention;
  36 import java.lang.annotation.RetentionPolicy;
  37 import java.lang.annotation.Target;
  38 import java.net.URI;
  39 import java.nio.file.Path;
  40 import java.util.ArrayList;
  41 import java.util.Collection;
  42 import java.util.Collections;
  43 import java.util.HashMap;
  44 import java.util.Iterator;
  45 import java.util.List;
  46 import java.util.Locale;
  47 import java.util.Map;
  48 import java.util.Objects;
  49 import java.util.ServiceLoader;
  50 import java.util.Set;
  51 
  52 import javax.lang.model.element.Modifier;
  53 import javax.lang.model.element.NestingKind;
  54 import javax.tools.Diagnostic;
  55 import javax.tools.DiagnosticListener;
  56 import javax.tools.FileObject;
  57 import javax.tools.JavaFileManager;
  58 import javax.tools.JavaFileManager.Location;
  59 import javax.tools.JavaFileObject;
  60 import javax.tools.JavaFileObject.Kind;
  61 import javax.tools.StandardJavaFileManager;
  62 
  63 import com.sun.source.util.TaskEvent;
  64 import com.sun.source.util.TaskListener;
  65 import com.sun.tools.javac.util.ClientCodeException;
  66 import com.sun.tools.javac.util.Context;
  67 import com.sun.tools.javac.util.DefinedBy;
  68 import com.sun.tools.javac.util.DefinedBy.Api;
  69 import com.sun.tools.javac.util.JCDiagnostic;


 401             } catch (RuntimeException | Error e) {
 402                 throw new ClientCodeException(e);
 403             }
 404         }
 405 
 406         @Override @DefinedBy(Api.COMPILER)
 407         public int isSupportedOption(String option) {
 408             try {
 409                 return clientJavaFileManager.isSupportedOption(option);
 410             } catch (ClientCodeException e) {
 411                 throw e;
 412             } catch (RuntimeException | Error e) {
 413                 throw new ClientCodeException(e);
 414             }
 415         }
 416 
 417         @Override
 418         public String toString() {
 419             return wrappedToString(getClass(), clientJavaFileManager);
 420         }
 421 
 422         @Override @DefinedBy(Api.COMPILER)
 423         public <S> ServiceLoader<S> getServiceLoader(Location location, Class<S> service) throws IOException {
 424             try {
 425                 return clientJavaFileManager.getServiceLoader(location, service);
 426             } catch (ClientCodeException e) {
 427                 throw e;
 428             } catch (RuntimeException | Error e) {
 429                 throw new ClientCodeException(e);
 430             }
 431         }
 432     }
 433 
 434     protected class WrappedStandardJavaFileManager extends WrappedJavaFileManager
 435             implements StandardJavaFileManager {
 436         WrappedStandardJavaFileManager(StandardJavaFileManager clientJavaFileManager) {
 437             super(clientJavaFileManager);
 438         }
 439 
 440         @Override @DefinedBy(Api.COMPILER)
 441         public Iterable<? extends JavaFileObject> getJavaFileObjectsFromFiles(Iterable<? extends File> files) {
 442             try {
 443                 return ((StandardJavaFileManager)clientJavaFileManager).getJavaFileObjectsFromFiles(files);
 444             } catch (ClientCodeException e) {
 445                 throw e;
 446             } catch (RuntimeException | Error e) {
 447                 throw new ClientCodeException(e);
 448             }
 449         }
 450 
 451         @Override @DefinedBy(Api.COMPILER)


 557             } catch (RuntimeException | Error e) {
 558                 throw new ClientCodeException(e);
 559             }
 560         }
 561 
 562         @Override @DefinedBy(Api.COMPILER)
 563         public Path asPath(FileObject file) {
 564             try {
 565                 return ((StandardJavaFileManager)clientJavaFileManager).asPath(file);
 566             } catch (ClientCodeException e) {
 567                 throw e;
 568             } catch (RuntimeException | Error e) {
 569                 throw new ClientCodeException(e);
 570             }
 571         }
 572 
 573         @Override @DefinedBy(Api.COMPILER)
 574         public void setPathFactory(PathFactory f) {
 575             try {
 576                 ((StandardJavaFileManager)clientJavaFileManager).setPathFactory(f);
 577             } catch (ClientCodeException e) {
 578                 throw e;
 579             } catch (RuntimeException | Error e) {
 580                 throw new ClientCodeException(e);
 581             }
 582         }
 583 
 584         @Override @DefinedBy(Api.COMPILER)
 585         public void setLocationForModule(Location location, String moduleName, Collection<? extends Path> paths) throws IOException {
 586             try {
 587                 System.out.println("invoking wrapped setLocationForModule");
 588                 ((StandardJavaFileManager)clientJavaFileManager).setLocationForModule(location, moduleName, paths);
 589             } catch (ClientCodeException e) {
 590                 throw e;
 591             } catch (RuntimeException | Error e) {
 592                 throw new ClientCodeException(e);
 593             }
 594         }
 595     }
 596 
 597     protected class WrappedFileObject implements FileObject {
 598         protected FileObject clientFileObject;
 599         WrappedFileObject(FileObject clientFileObject) {
 600             this.clientFileObject = Objects.requireNonNull(clientFileObject);
 601         }
 602 
 603         @Override @DefinedBy(Api.COMPILER)
 604         public URI toUri() {
 605             try {
 606                 return clientFileObject.toUri();
 607             } catch (ClientCodeException e) {
 608                 throw e;


   1 /*
   2  * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  29 import java.io.IOException;
  30 import java.io.InputStream;
  31 import java.io.OutputStream;
  32 import java.io.Reader;
  33 import java.io.Writer;
  34 import java.lang.annotation.ElementType;
  35 import java.lang.annotation.Retention;
  36 import java.lang.annotation.RetentionPolicy;
  37 import java.lang.annotation.Target;
  38 import java.net.URI;
  39 import java.nio.file.Path;
  40 import java.util.ArrayList;
  41 import java.util.Collection;
  42 import java.util.Collections;
  43 import java.util.HashMap;
  44 import java.util.Iterator;
  45 import java.util.List;
  46 import java.util.Locale;
  47 import java.util.Map;
  48 import java.util.Objects;

  49 import java.util.Set;
  50 
  51 import javax.lang.model.element.Modifier;
  52 import javax.lang.model.element.NestingKind;
  53 import javax.tools.Diagnostic;
  54 import javax.tools.DiagnosticListener;
  55 import javax.tools.FileObject;
  56 import javax.tools.JavaFileManager;
  57 import javax.tools.JavaFileManager.Location;
  58 import javax.tools.JavaFileObject;
  59 import javax.tools.JavaFileObject.Kind;
  60 import javax.tools.StandardJavaFileManager;
  61 
  62 import com.sun.source.util.TaskEvent;
  63 import com.sun.source.util.TaskListener;
  64 import com.sun.tools.javac.util.ClientCodeException;
  65 import com.sun.tools.javac.util.Context;
  66 import com.sun.tools.javac.util.DefinedBy;
  67 import com.sun.tools.javac.util.DefinedBy.Api;
  68 import com.sun.tools.javac.util.JCDiagnostic;


 400             } catch (RuntimeException | Error e) {
 401                 throw new ClientCodeException(e);
 402             }
 403         }
 404 
 405         @Override @DefinedBy(Api.COMPILER)
 406         public int isSupportedOption(String option) {
 407             try {
 408                 return clientJavaFileManager.isSupportedOption(option);
 409             } catch (ClientCodeException e) {
 410                 throw e;
 411             } catch (RuntimeException | Error e) {
 412                 throw new ClientCodeException(e);
 413             }
 414         }
 415 
 416         @Override
 417         public String toString() {
 418             return wrappedToString(getClass(), clientJavaFileManager);
 419         }











 420     }
 421 
 422     protected class WrappedStandardJavaFileManager extends WrappedJavaFileManager
 423             implements StandardJavaFileManager {
 424         WrappedStandardJavaFileManager(StandardJavaFileManager clientJavaFileManager) {
 425             super(clientJavaFileManager);
 426         }
 427 
 428         @Override @DefinedBy(Api.COMPILER)
 429         public Iterable<? extends JavaFileObject> getJavaFileObjectsFromFiles(Iterable<? extends File> files) {
 430             try {
 431                 return ((StandardJavaFileManager)clientJavaFileManager).getJavaFileObjectsFromFiles(files);
 432             } catch (ClientCodeException e) {
 433                 throw e;
 434             } catch (RuntimeException | Error e) {
 435                 throw new ClientCodeException(e);
 436             }
 437         }
 438 
 439         @Override @DefinedBy(Api.COMPILER)


 545             } catch (RuntimeException | Error e) {
 546                 throw new ClientCodeException(e);
 547             }
 548         }
 549 
 550         @Override @DefinedBy(Api.COMPILER)
 551         public Path asPath(FileObject file) {
 552             try {
 553                 return ((StandardJavaFileManager)clientJavaFileManager).asPath(file);
 554             } catch (ClientCodeException e) {
 555                 throw e;
 556             } catch (RuntimeException | Error e) {
 557                 throw new ClientCodeException(e);
 558             }
 559         }
 560 
 561         @Override @DefinedBy(Api.COMPILER)
 562         public void setPathFactory(PathFactory f) {
 563             try {
 564                 ((StandardJavaFileManager)clientJavaFileManager).setPathFactory(f);












 565             } catch (ClientCodeException e) {
 566                 throw e;
 567             } catch (RuntimeException | Error e) {
 568                 throw new ClientCodeException(e);
 569             }
 570         }
 571     }
 572 
 573     protected class WrappedFileObject implements FileObject {
 574         protected FileObject clientFileObject;
 575         WrappedFileObject(FileObject clientFileObject) {
 576             this.clientFileObject = Objects.requireNonNull(clientFileObject);
 577         }
 578 
 579         @Override @DefinedBy(Api.COMPILER)
 580         public URI toUri() {
 581             try {
 582                 return clientFileObject.toUri();
 583             } catch (ClientCodeException e) {
 584                 throw e;


< prev index next >