langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java
changeset 1471 57506cdfb7b4
parent 1355 74cc97efef51
child 3149 0cd06d598d6f
equal deleted inserted replaced
1470:6ff8524783fa 1471:57506cdfb7b4
    66  */
    66  */
    67 public class JavacTaskImpl extends JavacTask {
    67 public class JavacTaskImpl extends JavacTask {
    68     private JavacTool tool;
    68     private JavacTool tool;
    69     private Main compilerMain;
    69     private Main compilerMain;
    70     private JavaCompiler compiler;
    70     private JavaCompiler compiler;
       
    71     private Locale locale;
    71     private String[] args;
    72     private String[] args;
    72     private Context context;
    73     private Context context;
    73     private List<JavaFileObject> fileObjects;
    74     private List<JavaFileObject> fileObjects;
    74     private Map<JavaFileObject, JCCompilationUnit> notYetEntered;
    75     private Map<JavaFileObject, JCCompilationUnit> notYetEntered;
    75     private ListBuffer<Env<AttrContext>> genList;
    76     private ListBuffer<Env<AttrContext>> genList;
    87         this.tool = tool;
    88         this.tool = tool;
    88         this.compilerMain = compilerMain;
    89         this.compilerMain = compilerMain;
    89         this.args = args;
    90         this.args = args;
    90         this.context = context;
    91         this.context = context;
    91         this.fileObjects = fileObjects;
    92         this.fileObjects = fileObjects;
       
    93         setLocale(Locale.getDefault());
    92         // null checks
    94         // null checks
    93         compilerMain.getClass();
    95         compilerMain.getClass();
    94         args.getClass();
    96         args.getClass();
    95         context.getClass();
    97         context.getClass();
    96         fileObjects.getClass();
    98         fileObjects.getClass();
   154             throw new IllegalStateException();
   156             throw new IllegalStateException();
   155         this.processors = processors;
   157         this.processors = processors;
   156     }
   158     }
   157 
   159 
   158     public void setLocale(Locale locale) {
   160     public void setLocale(Locale locale) {
   159         // locale argument is ignored, see RFE 6443132
       
   160         if (used.get())
   161         if (used.get())
   161             throw new IllegalStateException();
   162             throw new IllegalStateException();
       
   163         this.locale = locale;
   162     }
   164     }
   163 
   165 
   164     private void prepareCompiler() throws IOException {
   166     private void prepareCompiler() throws IOException {
   165         if (!used.getAndSet(true)) {
   167         if (!used.getAndSet(true)) {
   166             beginContext();
   168             beginContext();
   189         if (context.get(TaskListener.class) != null)
   191         if (context.get(TaskListener.class) != null)
   190             context.put(TaskListener.class, (TaskListener)null);
   192             context.put(TaskListener.class, (TaskListener)null);
   191         if (taskListener != null)
   193         if (taskListener != null)
   192             context.put(TaskListener.class, wrap(taskListener));
   194             context.put(TaskListener.class, wrap(taskListener));
   193         tool.beginContext(context);
   195         tool.beginContext(context);
       
   196         //initialize compiler's default locale
       
   197         JavacMessages.instance(context).setCurrentLocale(locale);
   194     }
   198     }
   195     // where
   199     // where
   196     private TaskListener wrap(final TaskListener tl) {
   200     private TaskListener wrap(final TaskListener tl) {
   197         tl.getClass(); // null check
   201         tl.getClass(); // null check
   198         return new TaskListener() {
   202         return new TaskListener() {