< prev index next >

test/langtools/tools/javac/versions/Versions.java

Print this page




   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 4981566 5028634 5094412 6304984 7025786 7025789 8001112 8028545 8000961 8030610 8028546 8188870 8173382 8173382 8193290 8205619
  27  * @summary Check interpretation of -target and -source options
  28  * @modules java.compiler
  29  *          jdk.compiler
  30  * @run main Versions
  31  */
  32 
  33 import java.io.*;
  34 import java.nio.*;
  35 import java.nio.channels.*;
  36 
  37 import javax.tools.JavaCompiler;
  38 import javax.tools.ToolProvider;
  39 import javax.tools.JavaFileObject;
  40 import javax.tools.StandardJavaFileManager;
  41 import java.util.List;
  42 import java.util.ArrayList;
  43 import java.util.Arrays;
  44 import java.util.Set;
  45 import java.util.function.BiConsumer;
  46 


  49  * values are the defaults. If explicitly specified, the target value
  50  * has to be greater than or equal to the source value.
  51  */
  52 public class Versions {
  53 
  54     protected JavaCompiler javacompiler;
  55     protected int failedCases;
  56 
  57     public Versions() throws IOException {
  58         javacompiler = ToolProvider.getSystemJavaCompiler();
  59         genSourceFiles();
  60         failedCases = 0;
  61     }
  62 
  63     public static void main(String... args) throws IOException {
  64         Versions versions = new Versions();
  65         versions.run();
  66     }
  67 
  68     public static final Set<String> RETIRED_SOURCES =
  69         Set.of("1.2", "1.3", "1.4", "1.5" /*, 1.6 */);
  70 
  71     public static final Set<String> VALID_SOURCES =
  72         Set.of("1.7", "1.8", "1.9", "1.10", "11", "12");
  73 
  74     public static final String LATEST_MAJOR_VERSION = "56.0";
  75 
  76     static enum SourceTarget {
  77         SEVEN(true,   "51.0",  "7", Versions::checksrc17),
  78         EIGHT(true,   "52.0",  "8", Versions::checksrc18),
  79         NINE(true,    "53.0",  "9", Versions::checksrc19),
  80         TEN(true,     "54.0", "10", Versions::checksrc110),
  81         ELEVEN(false, "55.0", "11", Versions::checksrc111),
  82         TWELVE(false, "56.0", "12", Versions::checksrc112);
  83 
  84         private final boolean dotOne;
  85         private final String classFileVer;
  86         private final String target;
  87         private final BiConsumer<Versions, String[]> checker;
  88 
  89         private SourceTarget(boolean dotOne, String classFileVer, String target,




   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 4981566 5028634 5094412 6304984 7025786 7025789 8001112 8028545 8000961 8030610 8028546 8188870 8173382 8173382 8193290 8205619 8028563
  27  * @summary Check interpretation of -target and -source options
  28  * @modules java.compiler
  29  *          jdk.compiler
  30  * @run main Versions
  31  */
  32 
  33 import java.io.*;
  34 import java.nio.*;
  35 import java.nio.channels.*;
  36 
  37 import javax.tools.JavaCompiler;
  38 import javax.tools.ToolProvider;
  39 import javax.tools.JavaFileObject;
  40 import javax.tools.StandardJavaFileManager;
  41 import java.util.List;
  42 import java.util.ArrayList;
  43 import java.util.Arrays;
  44 import java.util.Set;
  45 import java.util.function.BiConsumer;
  46 


  49  * values are the defaults. If explicitly specified, the target value
  50  * has to be greater than or equal to the source value.
  51  */
  52 public class Versions {
  53 
  54     protected JavaCompiler javacompiler;
  55     protected int failedCases;
  56 
  57     public Versions() throws IOException {
  58         javacompiler = ToolProvider.getSystemJavaCompiler();
  59         genSourceFiles();
  60         failedCases = 0;
  61     }
  62 
  63     public static void main(String... args) throws IOException {
  64         Versions versions = new Versions();
  65         versions.run();
  66     }
  67 
  68     public static final Set<String> RETIRED_SOURCES =
  69         Set.of("1.2", "1.3", "1.4", "1.5", "1.6");
  70 
  71     public static final Set<String> VALID_SOURCES =
  72         Set.of("1.7", "1.8", "1.9", "1.10", "11", "12");
  73 
  74     public static final String LATEST_MAJOR_VERSION = "56.0";
  75 
  76     static enum SourceTarget {
  77         SEVEN(true,   "51.0",  "7", Versions::checksrc17),
  78         EIGHT(true,   "52.0",  "8", Versions::checksrc18),
  79         NINE(true,    "53.0",  "9", Versions::checksrc19),
  80         TEN(true,     "54.0", "10", Versions::checksrc110),
  81         ELEVEN(false, "55.0", "11", Versions::checksrc111),
  82         TWELVE(false, "56.0", "12", Versions::checksrc112);
  83 
  84         private final boolean dotOne;
  85         private final String classFileVer;
  86         private final String target;
  87         private final BiConsumer<Versions, String[]> checker;
  88 
  89         private SourceTarget(boolean dotOne, String classFileVer, String target,


< prev index next >