1 /*
   2  * Copyright (c) 2014, 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
  23  * questions.
  24  */
  25 
  26 package com.sun.tools.javac.platform;
  27 
  28 import java.io.Closeable;
  29 import java.io.IOException;
  30 import java.nio.file.Path;
  31 import java.util.Collection;
  32 import java.util.List;
  33 import java.util.Map;
  34 
  35 import javax.annotation.processing.Processor;
  36 
  37 import com.sun.source.util.Plugin;
  38 
  39 /**A description of settings needed for a particular {@code -release name} option.
  40  *
  41  *  <p><b>This is NOT part of any supported API.
  42  *  If you write code that depends on this, you do so at your own risk.
  43  *  This code and its internal interfaces are subject to change or
  44  *  deletion without notice.</b>
  45  */
  46 public interface PlatformDescription extends Closeable {
  47 
  48     /**Returns paths that should be used as the current platform's bootclasspath, or null if
  49      * the default should be used.
  50      *
  51      * @return the current platforms's bootclasspath, or null for default
  52      */
  53     Collection<Path> getPlatformPath();
  54 
  55     /**Returns the source version that should be selected.
  56      * Equivalent to {@code -source N} on the command line.
  57      *
  58      * @return the required source version
  59      */
  60     String getSourceVersion();
  61 
  62     /**Returns the target version that should be selected.
  63      * Equivalent to {@code -target N} on the command line.
  64      *
  65      * @return the required target version
  66      */
  67     String getTargetVersion();
  68 
  69     /**Returns the description of annotation Processor or javac Plugin that should be enabled
  70      * in the current javac run.
  71      *
  72      * @param <T> either Processor or Plugin
  73      */
  74     interface PluginInfo<T> {
  75 
  76         /**Returns the name of the Processor or Plugin.
  77          *
  78          * @return name of the Processor or Plugin.
  79          */
  80         String getName();
  81 
  82         /**Returns the options for the Processor or Plugin. For plugin, the map will be converted to a collection
  83          * by concatenating the map's keys, the '=' sign and the map's values.
  84          *
  85          *
  86          * @return the options
  87          */
  88         Map<String, String> getOptions();
  89 
  90         /**Returns the Processor or Plugin instance.
  91          *
  92          * @return the Processor or Plugin instance.
  93          */
  94         T getPlugin();
  95     }
  96 
  97     /**Returns the annotation Processors that should be enabled in the current javac run.
  98      *
  99      * @return annotation Processors
 100      */
 101     List<PluginInfo<Processor>> getAnnotationProcessors();
 102 
 103     /**Returns the javac Plugins that should be enabled in the current javac run.
 104      *
 105      * @return javac Plugins
 106      */
 107     List<PluginInfo<Plugin>> getPlugins();
 108 
 109     /**Returns the additional command line options that should be passed to javac.
 110      *
 111      * @return additional command line options
 112      */
 113     List<String> getAdditionalOptions();
 114 
 115     /**Perform cleanup for this PlatformProvider - this instance won't be used after this method
 116      * is called.
 117      *
 118      * @throws IOException if unexpected problems occur during closing this provider
 119      */
 120     void close() throws IOException;
 121 }