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, 90 BiConsumer<Versions, String[]> checker) { 91 this.dotOne = dotOne; 92 this.classFileVer = classFileVer; 93 this.target = target; 94 this.checker = checker; 95 } 96 97 public void checksrc(Versions version, String... args) { 98 checker.accept(version, args); 99 } 100 101 public boolean dotOne() { 102 return dotOne; 273 pass(newargs); 274 } 275 276 protected void checksrc111(String... args) { 277 printargs("checksrc111", args); 278 int asize = args.length; 279 String[] newargs = new String[asize+1]; 280 System.arraycopy(args, 0, newargs,0 , asize); 281 newargs[asize] = "New17.java"; 282 pass(newargs); 283 newargs[asize] = "New18.java"; 284 pass(newargs); 285 newargs[asize] = "New110.java"; 286 pass(newargs); 287 newargs[asize] = "New111.java"; 288 pass(newargs); 289 } 290 291 protected void checksrc112(String... args) { 292 printargs("checksrc112", args); 293 checksrc111(args); 294 } 295 296 protected void pass(String... args) { 297 printargs("pass", args); 298 299 List<String> jcargs = new ArrayList<String>(); 300 jcargs.add("-Xlint:-options"); 301 302 // add in args conforming to List requrements of JavaCompiler 303 for (String onearg : args) { 304 String[] fields = onearg.split(" "); 305 for (String onefield : fields) { 306 jcargs.add(onefield); 307 } 308 } 309 310 // empty list is error 311 if (jcargs.isEmpty()) { 312 System.err.println("error: test error in pass() - No arguments"); | 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", "13"); 73 74 public static final String LATEST_MAJOR_VERSION = "57.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 THIRTEEN(false, "57.0", "13", Versions::checksrc113); 84 85 private final boolean dotOne; 86 private final String classFileVer; 87 private final String target; 88 private final BiConsumer<Versions, String[]> checker; 89 90 private SourceTarget(boolean dotOne, String classFileVer, String target, 91 BiConsumer<Versions, String[]> checker) { 92 this.dotOne = dotOne; 93 this.classFileVer = classFileVer; 94 this.target = target; 95 this.checker = checker; 96 } 97 98 public void checksrc(Versions version, String... args) { 99 checker.accept(version, args); 100 } 101 102 public boolean dotOne() { 103 return dotOne; 274 pass(newargs); 275 } 276 277 protected void checksrc111(String... args) { 278 printargs("checksrc111", args); 279 int asize = args.length; 280 String[] newargs = new String[asize+1]; 281 System.arraycopy(args, 0, newargs,0 , asize); 282 newargs[asize] = "New17.java"; 283 pass(newargs); 284 newargs[asize] = "New18.java"; 285 pass(newargs); 286 newargs[asize] = "New110.java"; 287 pass(newargs); 288 newargs[asize] = "New111.java"; 289 pass(newargs); 290 } 291 292 protected void checksrc112(String... args) { 293 printargs("checksrc112", args); 294 checksrc111(args); 295 } 296 297 protected void checksrc113(String... args) { 298 printargs("checksrc113", args); 299 checksrc111(args); 300 } 301 302 protected void pass(String... args) { 303 printargs("pass", args); 304 305 List<String> jcargs = new ArrayList<String>(); 306 jcargs.add("-Xlint:-options"); 307 308 // add in args conforming to List requrements of JavaCompiler 309 for (String onearg : args) { 310 String[] fields = onearg.split(" "); 311 for (String onefield : fields) { 312 jcargs.add(onefield); 313 } 314 } 315 316 // empty list is error 317 if (jcargs.isEmpty()) { 318 System.err.println("error: test error in pass() - No arguments"); |