7018753: tools/javac/varargs/warning/Warn5.java times out on slow machines

Use a single file manager for all JavacTasks

Reviewed-by: jjg, mcimadamore
This commit is contained in:
Jim Holmlund 2011-02-24 08:40:49 -08:00
parent b6bfe0166b
commit 6d172a6a63
3 changed files with 18 additions and 3 deletions

View File

@ -37,6 +37,7 @@ import com.sun.tools.classfile.ClassFile;
import com.sun.tools.classfile.Code_attribute;
import com.sun.tools.classfile.ConstantPool.*;
import com.sun.tools.classfile.Method;
import com.sun.tools.javac.api.JavacTool;
import com.sun.tools.javac.util.List;
import java.io.File;
@ -47,6 +48,7 @@ import javax.tools.Diagnostic;
import javax.tools.JavaCompiler;
import javax.tools.JavaFileObject;
import javax.tools.SimpleJavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;
public class T6199075 {
@ -157,11 +159,14 @@ public class T6199075 {
System.out.println("Bytecode checks made: " + bytecodeCheckCount);
}
// Create a single file manager and reuse it for each compile to save time.
StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
void compileAndCheck(VarargsMethod m1, VarargsMethod m2, TypeKind actual, ArgumentsArity argsArity) throws Exception {
final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
JavaSource source = new JavaSource(m1, m2, actual, argsArity);
ErrorChecker ec = new ErrorChecker();
JavacTask ct = (JavacTask)tool.getTask(null, null, ec,
JavacTask ct = (JavacTask)tool.getTask(null, fm, ec,
null, null, Arrays.asList(source));
ct.generate();
check(source, ec, m1, m2, actual, argsArity);

View File

@ -29,6 +29,7 @@
* @run main Warn4
*/
import com.sun.source.util.JavacTask;
import com.sun.tools.javac.api.JavacTool;
import java.net.URI;
import java.util.Arrays;
import java.util.Set;
@ -37,6 +38,7 @@ import javax.tools.Diagnostic;
import javax.tools.JavaCompiler;
import javax.tools.JavaFileObject;
import javax.tools.SimpleJavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;
public class Warn4 {
@ -187,12 +189,15 @@ public class Warn4 {
}
}
// Create a single file manager and reuse it for each compile to save time.
static StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
static void test(SourceLevel sourceLevel, TrustMe trustMe, SuppressLevel suppressLevelClient,
SuppressLevel suppressLevelDecl, ModifierKind modKind, Signature vararg_meth, Signature client_meth) throws Exception {
final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
JavaSource source = new JavaSource(trustMe, suppressLevelClient, suppressLevelDecl, modKind, vararg_meth, client_meth);
DiagnosticChecker dc = new DiagnosticChecker();
JavacTask ct = (JavacTask)tool.getTask(null, null, dc,
JavacTask ct = (JavacTask)tool.getTask(null, fm, dc,
Arrays.asList("-Xlint:unchecked", "-source", sourceLevel.sourceKey),
null, Arrays.asList(source));
ct.generate(); //to get mandatory notes

View File

@ -29,6 +29,7 @@
* @run main Warn5
*/
import com.sun.source.util.JavacTask;
import com.sun.tools.javac.api.JavacTool;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
@ -36,6 +37,7 @@ import javax.tools.Diagnostic;
import javax.tools.JavaCompiler;
import javax.tools.JavaFileObject;
import javax.tools.SimpleJavaFileObject;
import javax.tools.StandardJavaFileManager;
import javax.tools.ToolProvider;
public class Warn5 {
@ -207,12 +209,15 @@ public class Warn5 {
}
}
// Create a single file manager and reuse it for each compile to save time.
static StandardJavaFileManager fm = JavacTool.create().getStandardFileManager(null, null, null);
static void test(SourceLevel sourceLevel, XlintOption xlint, TrustMe trustMe, SuppressLevel suppressLevel,
ModifierKind modKind, MethodKind methKind, SignatureKind sig, BodyKind body) throws Exception {
final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
JavaSource source = new JavaSource(trustMe, suppressLevel, modKind, methKind, sig, body);
DiagnosticChecker dc = new DiagnosticChecker();
JavacTask ct = (JavacTask)tool.getTask(null, null, dc,
JavacTask ct = (JavacTask)tool.getTask(null, fm, dc,
Arrays.asList(xlint.getXlintOption(), "-source", sourceLevel.sourceKey), null, Arrays.asList(source));
ct.analyze();
check(sourceLevel, dc, source, xlint, trustMe,