langtools/test/tools/javac/T6358166.java
changeset 24897 655b72d7b96e
parent 10193 3e1ef5e9f4fd
child 26264 a09fedde76be
--- a/langtools/test/tools/javac/T6358166.java	Fri Jun 06 16:08:46 2014 -0400
+++ b/langtools/test/tools/javac/T6358166.java	Sun Jun 08 15:02:34 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -57,12 +57,8 @@
 
     static void test(JavacFileManager fm, JavaFileObject f, String... args) throws Throwable {
         Context context = new Context();
-        fm.setContext(context);
 
-        Main compilerMain = new Main("javac", new PrintWriter(System.err, true));
-        compilerMain.setOptions(Options.instance(context));
-        compilerMain.filenames = new LinkedHashSet<File>();
-        compilerMain.processArgs(args);
+        Main compilerMain = initCompilerMain(context, fm, args);
 
         JavaCompiler c = JavaCompiler.instance(context);
 
@@ -76,6 +72,19 @@
             throw new AssertionError("elapsed time is suspect: " + msec);
     }
 
+    static Main initCompilerMain(Context context, JavacFileManager fm, String... args) {
+        fm.setContext(context);
+        context.put(JavaFileManager.class, fm);
+
+        Main compilerMain = new Main("javac", new PrintWriter(System.err, true));
+        compilerMain.setOptions(Options.instance(context));
+        compilerMain.filenames = new LinkedHashSet<File>();
+        compilerMain.deferredFileManagerOptions = new LinkedHashMap<>();
+        compilerMain.processArgs(args);
+        fm.handleOptions(compilerMain.deferredFileManagerOptions);
+        return compilerMain;
+    }
+
     public boolean process(Set<? extends TypeElement> tes, RoundEnvironment renv) {
         return true;
     }