21 * questions. 22 */ 23 24 /* 25 * @test 26 * @bug 7157626 8001112 27 * @summary Test major version for all legal combinations for -source and -target 28 * @author sgoel 29 * 30 * @modules jdk.compiler 31 */ 32 33 import java.io.*; 34 import java.nio.*; 35 import java.util.*; 36 import java.util.regex.*; 37 38 public class ClassVersionChecker { 39 40 int errors; 41 String[] jdk = {"","1.6","1.7","1.8"}; 42 File javaFile = null; 43 44 public static void main(String[] args) throws Throwable { 45 new ClassVersionChecker().run(); 46 } 47 48 void run() throws Exception { 49 writeTestFile(); 50 /* Rules applicable for -source and -target combinations 51 * 1. If both empty, version num is for the current release 52 * 2. If source is not empty and target is empty, version is based on source 53 * 3. If both non-empty, version is based on target 54 */ 55 56 /* -source (0=>empty,1=>1.2,...) X -target (0=>empty,1=>1.2,...) 57 * ver[0][0] => no -source or -target was given 58 * -1 => invalid combinations 59 */ 60 int[][] ver = 61 {{52, -1, -1, -1}, 62 {52, 50, 51, 52}, 63 {52, -1, 51, 52}, 64 {52, -1, -1, 52}}; 65 66 // Loop to run all possible combinations of source/target values 67 for (int i = 0; i< ver.length; i++) { 68 for (int j = 0 ; j< ver[i].length; j++) { 69 if(ver[i][j] != -1) { 70 logMsg("Index values for i = " + i + " j = " + j); 71 logMsg("Running for src = " + jdk[i] + " target = "+jdk[j] +" expected = " + ver[i][j]); 72 test(i,j, ver[i][j]); 73 } 74 } 75 } 76 77 if (errors > 0) 78 throw new Exception(errors + " errors found"); 79 } 80 81 void test (int i, int j, int expected) { 82 File classFile = compileTestFile(i, j, javaFile); 83 short majorVer = getMajorVersion(classFile); 84 checkVersion(majorVer, expected); | 21 * questions. 22 */ 23 24 /* 25 * @test 26 * @bug 7157626 8001112 27 * @summary Test major version for all legal combinations for -source and -target 28 * @author sgoel 29 * 30 * @modules jdk.compiler 31 */ 32 33 import java.io.*; 34 import java.nio.*; 35 import java.util.*; 36 import java.util.regex.*; 37 38 public class ClassVersionChecker { 39 40 int errors; 41 String[] jdk = {"", "1.6", "1.7", "1.8", "1.9"}; 42 File javaFile = null; 43 44 public static void main(String[] args) throws Throwable { 45 new ClassVersionChecker().run(); 46 } 47 48 void run() throws Exception { 49 writeTestFile(); 50 /* Rules applicable for -source and -target combinations 51 * 1. If both empty, version num is for the current release 52 * 2. If source is not empty and target is empty, version is based on source 53 * 3. If both non-empty, version is based on target 54 */ 55 56 /* -source (0=>empty,1=>1.2,...) X -target (0=>empty,1=>1.2,...) 57 * ver[0][0] => no -source or -target was given 58 * -1 => invalid combinations 59 */ 60 int[][] ver = 61 {{53, -1, -1, -1, -1}, 62 {53, 50, 51, 52, 53}, 63 {53, -1, 51, 52, 53}, 64 {53, -1, -1, 52, 53}}; 65 66 // Loop to run all possible combinations of source/target values 67 for (int i = 0; i< ver.length; i++) { 68 for (int j = 0 ; j< ver[i].length; j++) { 69 if(ver[i][j] != -1) { 70 logMsg("Index values for i = " + i + " j = " + j); 71 logMsg("Running for src = " + jdk[i] + " target = "+jdk[j] +" expected = " + ver[i][j]); 72 test(i,j, ver[i][j]); 73 } 74 } 75 } 76 77 if (errors > 0) 78 throw new Exception(errors + " errors found"); 79 } 80 81 void test (int i, int j, int expected) { 82 File classFile = compileTestFile(i, j, javaFile); 83 short majorVer = getMajorVersion(classFile); 84 checkVersion(majorVer, expected); |