test/tools/javac/varargs/warning/Warn4.java

changeset 892
3e30c95da3c6
parent 795
7b99f98b3035
child 962
0ff2bbd38f10
equal deleted inserted replaced
891:4b0491db73af 892:3e30c95da3c6
27 * @summary Project Coin: Simplified Varargs Method Invocation 27 * @summary Project Coin: Simplified Varargs Method Invocation
28 * @author mcimadamore 28 * @author mcimadamore
29 * @run main Warn4 29 * @run main Warn4
30 */ 30 */
31 import com.sun.source.util.JavacTask; 31 import com.sun.source.util.JavacTask;
32 import com.sun.tools.javac.api.JavacTool;
32 import java.net.URI; 33 import java.net.URI;
33 import java.util.Arrays; 34 import java.util.Arrays;
34 import java.util.Set; 35 import java.util.Set;
35 import java.util.HashSet; 36 import java.util.HashSet;
36 import javax.tools.Diagnostic; 37 import javax.tools.Diagnostic;
37 import javax.tools.JavaCompiler; 38 import javax.tools.JavaCompiler;
38 import javax.tools.JavaFileObject; 39 import javax.tools.JavaFileObject;
39 import javax.tools.SimpleJavaFileObject; 40 import javax.tools.SimpleJavaFileObject;
41 import javax.tools.StandardJavaFileManager;
40 import javax.tools.ToolProvider; 42 import javax.tools.ToolProvider;
41 43
42 public class Warn4 { 44 public class Warn4 {
43 45
44 final static Warning[] error = null; 46 final static Warning[] error = null;
185 } 187 }
186 } 188 }
187 } 189 }
188 } 190 }
189 191
192 // Create a single file manager and reuse it for each compile to save time.
193 static StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
194
190 static void test(SourceLevel sourceLevel, TrustMe trustMe, SuppressLevel suppressLevelClient, 195 static void test(SourceLevel sourceLevel, TrustMe trustMe, SuppressLevel suppressLevelClient,
191 SuppressLevel suppressLevelDecl, ModifierKind modKind, Signature vararg_meth, Signature client_meth) throws Exception { 196 SuppressLevel suppressLevelDecl, ModifierKind modKind, Signature vararg_meth, Signature client_meth) throws Exception {
192 final JavaCompiler tool = ToolProvider.getSystemJavaCompiler(); 197 final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
193 JavaSource source = new JavaSource(trustMe, suppressLevelClient, suppressLevelDecl, modKind, vararg_meth, client_meth); 198 JavaSource source = new JavaSource(trustMe, suppressLevelClient, suppressLevelDecl, modKind, vararg_meth, client_meth);
194 DiagnosticChecker dc = new DiagnosticChecker(); 199 DiagnosticChecker dc = new DiagnosticChecker();
195 JavacTask ct = (JavacTask)tool.getTask(null, null, dc, 200 JavacTask ct = (JavacTask)tool.getTask(null, fm, dc,
196 Arrays.asList("-Xlint:unchecked", "-source", sourceLevel.sourceKey), 201 Arrays.asList("-Xlint:unchecked", "-source", sourceLevel.sourceKey),
197 null, Arrays.asList(source)); 202 null, Arrays.asList(source));
198 ct.generate(); //to get mandatory notes 203 ct.generate(); //to get mandatory notes
199 check(dc.warnings, sourceLevel, 204 check(dc.warnings, sourceLevel,
200 new boolean[] {vararg_meth.giveUnchecked(client_meth), 205 new boolean[] {vararg_meth.giveUnchecked(client_meth),

mercurial