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