75 files = new ArrayList<String>(); 76 files.addAll(base_files); 77 files.addAll(extra_files); 78 files.remove(f); 79 files.add("Test.java"); 80 compile(false, files); 81 } 82 83 if (errors > 0) 84 throw new Exception(errors + " errors occurred"); 85 } 86 87 void compile(boolean stdBootClassPath, String... files) { 88 compile(stdBootClassPath, Arrays.asList(files)); 89 } 90 91 void compile(boolean stdBootClassPath, List<String> files) { 92 File empty = new File("empty"); 93 empty.mkdirs(); 94 95 List<String> args = new ArrayList<String>(); 96 args.add("-classpath"); 97 args.add("empty"); 98 99 if (stdBootClassPath) { 100 args.add("-Xmodule:java.base"); 101 } else { 102 args.add("--system"); 103 args.add("none"); 104 files.add("module-info.java"); 105 } 106 107 108 args.add("-d"); 109 args.add("."); 110 111 // files to compile are in a separate directory from test to avoid 112 // confusing jtreg 113 File src = new File(testSrc, "src"); 114 for (String f: files) 115 args.add(new File(src, f).getPath()); 116 117 System.out.println("Compile: " + args); 118 StringWriter out = new StringWriter(); 119 int rc = com.sun.tools.javac.Main.compile(args.toArray(new String[args.size()]), 120 new PrintWriter(out)); 121 System.out.println(out.toString()); 122 System.out.println("result: " + rc); 123 System.out.println(); 124 125 if (rc != 0) 126 errors++; 127 } 128 129 private int errors; 130 } 131 132 | 75 files = new ArrayList<String>(); 76 files.addAll(base_files); 77 files.addAll(extra_files); 78 files.remove(f); 79 files.add("Test.java"); 80 compile(false, files); 81 } 82 83 if (errors > 0) 84 throw new Exception(errors + " errors occurred"); 85 } 86 87 void compile(boolean stdBootClassPath, String... files) { 88 compile(stdBootClassPath, Arrays.asList(files)); 89 } 90 91 void compile(boolean stdBootClassPath, List<String> files) { 92 File empty = new File("empty"); 93 empty.mkdirs(); 94 95 // files to compile are in a separate directory from test to avoid 96 // confusing jtreg 97 File src = new File(testSrc, "src"); 98 99 List<String> args = new ArrayList<String>(); 100 args.add("-classpath"); 101 args.add("empty"); 102 103 if (stdBootClassPath) { 104 args.add("--patch-module"); 105 args.add("java.base=" + testSrc.getAbsolutePath()); 106 } else { 107 args.add("--system"); 108 args.add("none"); 109 files.add("module-info.java"); 110 } 111 112 113 args.add("-d"); 114 args.add("."); 115 116 for (String f: files) 117 args.add(new File(src, f).getPath()); 118 119 System.out.println("Compile: " + args); 120 StringWriter out = new StringWriter(); 121 int rc = com.sun.tools.javac.Main.compile(args.toArray(new String[args.size()]), 122 new PrintWriter(out)); 123 System.out.println(out.toString()); 124 System.out.println("result: " + rc); 125 System.out.println(); 126 127 if (rc != 0) 128 errors++; 129 } 130 131 private int errors; 132 } 133 134 |