Commits

Jan Lahoda committed 98f74d1

Need to be more careful when creating the JDK8 javac with the NB features.

  • Participants
  • Parent commits 28f455c

Comments (0)

Files changed (1)

language/server/web/language.web.api/src/org/netbeans/modules/jackpot30/backend/language/api/JavacCreatorImpl.java

 package org.netbeans.modules.jackpot30.backend.language.api;
 
 import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.api.JavacTool;
 import com.sun.tools.javac.main.JavaCompiler;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javadoc.Messager;
 import javax.tools.DiagnosticListener;
 import javax.tools.JavaFileManager;
 import javax.tools.JavaFileObject;
-import javax.tools.ToolProvider;
 import org.netbeans.lib.nbjavac.services.NBAttr;
 import org.netbeans.lib.nbjavac.services.NBClassReader;
 import org.netbeans.lib.nbjavac.services.NBClassWriter;
         realOptions.add("-XDallowStringFolding=false"); //NOI18N
         realOptions.add("-XDshouldStopPolicy=GENERATE");   // NOI18N, parsing should not stop in phase where an error is found
         realOptions.add("-XDsuppressAbortOnBadClassFile=true");
-        JavacTaskImpl task = (JavacTaskImpl) ToolProvider.getSystemJavaCompiler().getTask(out, fileManager, diagnosticListener, realOptions, classes, compilationUnits);
-        Context context = task.getContext();
+        Context context = new Context();
+        //need to preregister the Messages here, because the getTask below requires Log instance:
+        Messager.preRegister(context, null, DEV_NULL, DEV_NULL, DEV_NULL);
+        JavacTaskImpl task = (JavacTaskImpl) JavacTool.create().getTask(out, fileManager, diagnosticListener, realOptions, classes, compilationUnits, context);
         NBClassReader.preRegister(context, true);
-        Messager.preRegister(context, null, DEV_NULL, DEV_NULL, DEV_NULL);
         NBAttr.preRegister(context);
         NBClassWriter.preRegister(context);
         NBParserFactory.preRegister(context);