You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2017/12/21 11:39:17 UTC

[GitHub] JaroslavTulach closed pull request #333: Making nb-javac optional

JaroslavTulach closed pull request #333: Making nb-javac optional
URL: https://github.com/apache/incubator-netbeans/pull/333
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/.travis.yml b/.travis.yml
index 2a5cc1917..aa2b4e0db 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -18,8 +18,8 @@ language: java
 jdk:
   - oraclejdk8
 script:
-  - (ant -quiet -Dcluster.config=platform build-source-config && mkdir scratch && cd scratch && unzip -qq ../nbbuild/build/platform-src* && ant -quiet rat -Dcluster.config=platform -Drat-report.haltonfailure=true && cd .. && rm -rf scratch)
+  - ant -quiet rat -Drat-report.haltonfailure=true
   - ant -quiet build -Djavac.compilerargs=-nowarn -Dbuild.compiler.deprecation=false
   - ant -quiet test -Djavac.compilerargs=-nowarn -Dbuild.compiler.deprecation=false -Dtest.includes=NoTestsJustBuild
-  - ant -quiet verify-libs-and-licenses -Dcluster.config=platform -Dverify-libs-and-licenses.haltonfailure=true
+  - ant -quiet verify-libs-and-licenses -Dverify-libs-and-licenses.haltonfailure=true
   - ./travis-check-line-endings.sh
diff --git a/apisupport.project/nbproject/project.properties b/apisupport.project/nbproject/project.properties
index c947b08c9..73392e5cc 100644
--- a/apisupport.project/nbproject/project.properties
+++ b/apisupport.project/nbproject/project.properties
@@ -25,3 +25,4 @@ test-unit-sys-prop.java.awt.headless=true
 test.config.stableBTD.includes=**/*Test.class
 test.config.stableBTD.excludes=\
     **/ModuleOperationsTest.class
+requires.nb.javac=true
diff --git a/apisupport.wizards/nbproject/project.properties b/apisupport.wizards/nbproject/project.properties
index c0af75f0c..315878a03 100644
--- a/apisupport.wizards/nbproject/project.properties
+++ b/apisupport.wizards/nbproject/project.properties
@@ -16,3 +16,4 @@
 # under the License.
 javac.source=1.6
 javac.compilerargs=-Xlint -Xlint:-serial
+requires.nb.javac=true
diff --git a/beans/nbproject/project.properties b/beans/nbproject/project.properties
index 915c8bff6..893067523 100644
--- a/beans/nbproject/project.properties
+++ b/beans/nbproject/project.properties
@@ -30,3 +30,4 @@ test.config.beaninfo.includes=\
 
 test.config.stable.include=\
     **/StableSuite.class
+requires.nb.javac=true
diff --git a/beans/src/org/netbeans/modules/beans/addproperty/AddPropertyCodeGenerator.java b/beans/src/org/netbeans/modules/beans/addproperty/AddPropertyCodeGenerator.java
index 8affaa49e..64dcd804f 100644
--- a/beans/src/org/netbeans/modules/beans/addproperty/AddPropertyCodeGenerator.java
+++ b/beans/src/org/netbeans/modules/beans/addproperty/AddPropertyCodeGenerator.java
@@ -25,7 +25,7 @@
 import com.sun.source.tree.Tree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.io.IOException;
 import java.util.Collections;
@@ -301,7 +301,7 @@ private static int scanForSemicolon(Document doc, int[] offset, int start, int e
         return semicolon;
     }
 
-    private static final class ImportFQNsHack extends TreePathScanner<Void, Void> {
+    private static final class ImportFQNsHack extends ErrorAwareTreePathScanner<Void, Void> {
 
         private WorkingCopy wc;
         private int start;
diff --git a/core.startup/src/org/netbeans/core/startup/NbInstaller.java b/core.startup/src/org/netbeans/core/startup/NbInstaller.java
index fb93ac9c9..e7b0df333 100644
--- a/core.startup/src/org/netbeans/core/startup/NbInstaller.java
+++ b/core.startup/src/org/netbeans/core/startup/NbInstaller.java
@@ -230,11 +230,13 @@ private void checkForHiddenPackages(Module m) throws InvalidException {
         List<Module.PackageExport> hiddenPackages = new ArrayList<Module.PackageExport>();
         List<Module> mWithDeps = new LinkedList<Module>();
         mWithDeps.add(m);
+        mWithDeps.addAll(mgr.getAttachedFragments(m));
         for (Dependency d : m.getDependencies()) {
             if (d.getType() == Dependency.TYPE_MODULE) {
                 Module _m = mgr.get((String) Util.parseCodeName(d.getName())[0]);
                 assert _m != null : d;
                 mWithDeps.add(_m);
+                mWithDeps.addAll(mgr.getAttachedFragments(_m));
             }
         }
         for (Module _m : mWithDeps) {
diff --git a/debugger.jpda.ant/nbproject/project.properties b/debugger.jpda.ant/nbproject/project.properties
index 0d7b6d55c..773b2c0d0 100644
--- a/debugger.jpda.ant/nbproject/project.properties
+++ b/debugger.jpda.ant/nbproject/project.properties
@@ -20,3 +20,4 @@ ant.jar=${ant.core.lib}
 javac.compilerargs=-Xlint:unchecked
 javac.source=1.6
 javadoc.arch=${basedir}/arch.xml
+requires.nb.javac=true
diff --git a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ClassScanner.java b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ClassScanner.java
index fd4fa6147..a9e5583b3 100644
--- a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ClassScanner.java
+++ b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ClassScanner.java
@@ -20,7 +20,7 @@
 package org.netbeans.modules.debugger.jpda.projects;
 
 import com.sun.source.tree.ClassTree;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.util.Elements;
@@ -30,7 +30,7 @@
  * 
  * @author martin
  */
-class ClassScanner extends TreePathScanner<TypeElement, Void> {
+class ClassScanner extends ErrorAwareTreePathScanner<TypeElement, Void> {
     
     private Trees trees;
     private Elements elements;
diff --git a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/EditorContextSupport.java b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/EditorContextSupport.java
index 037f43f22..fbdb8e535 100644
--- a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/EditorContextSupport.java
+++ b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/EditorContextSupport.java
@@ -32,7 +32,7 @@
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
@@ -1428,8 +1428,8 @@ public String getMessage() {
     
     public static <R,D> R interpretOrCompileCode(final Expression<Object> expression,
                                                  final String url, final int line,
-                                                 final TreePathScanner<Boolean,D> canInterpret,
-                                                 final TreePathScanner<R,D> interpreter,
+                                                 final ErrorAwareTreePathScanner<Boolean,D> canInterpret,
+                                                 final ErrorAwareTreePathScanner<R,D> interpreter,
                                                  final D context, boolean staticContext,
                                                  final Function<Pair<String, byte[]>, Boolean> compiledClassHandler,
                                                  final SourcePathProvider sp) throws InvalidExpressionException {
diff --git a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ExpressionScanner.java b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ExpressionScanner.java
index d0b20f824..ef36e38fb 100644
--- a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ExpressionScanner.java
+++ b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ExpressionScanner.java
@@ -52,7 +52,7 @@
 import com.sun.source.tree.VariableTree;
 import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.util.SourcePositions;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -69,7 +69,7 @@
  * 
  * @author Martin Entlicher
  */
-class ExpressionScanner extends TreeScanner<List<Tree>, ExpressionScanner.ExpressionsInfo> {
+class ExpressionScanner extends ErrorAwareTreeScanner<List<Tree>, ExpressionScanner.ExpressionsInfo> {
     
     private int lineNumber;
     private int statementStart;
diff --git a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/MethodArgumentsScanner.java b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/MethodArgumentsScanner.java
index e5e5c0f54..9b36ca168 100644
--- a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/MethodArgumentsScanner.java
+++ b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/MethodArgumentsScanner.java
@@ -29,7 +29,7 @@
 import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.util.List;
 import javax.tools.Diagnostic;
 import org.netbeans.spi.debugger.jpda.EditorContext.MethodArgument;
@@ -39,7 +39,7 @@
  * 
  * @author Martin Entlicher
  */
-class MethodArgumentsScanner extends TreeScanner<MethodArgument[], Object> {
+class MethodArgumentsScanner extends ErrorAwareTreeScanner<MethodArgument[], Object> {
     
     private int offset;
     private CompilationUnitTree tree;
diff --git a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/PreferredCCParser.java b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/PreferredCCParser.java
index 6e9aad223..57b11b5d0 100644
--- a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/PreferredCCParser.java
+++ b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/PreferredCCParser.java
@@ -27,7 +27,7 @@
 import com.sun.source.tree.Tree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.io.IOException;
 import java.net.MalformedURLException;
@@ -404,8 +404,8 @@ private static JavaSource getJavaSource(SourcePathProvider sp) {
     @NbBundle.Messages("MSG_NoParseNoEval=Can not evaluate expression - parsing failed.")
     public <R,D> R interpretOrCompileCode(final Expression<Object> expression,
                                           final String url, final int line,
-                                          final TreePathScanner<Boolean,D> canInterpret,
-                                          final TreePathScanner<R,D> interpreter,
+                                          final ErrorAwareTreePathScanner<Boolean,D> canInterpret,
+                                          final ErrorAwareTreePathScanner<R,D> interpreter,
                                           final D context, boolean staticContext,
                                           final Function<Pair<String, byte[]>, Boolean> compiledClassHandler,
                                           final SourcePathProvider sp) throws InvalidExpressionException {
@@ -654,7 +654,7 @@ public int getCodeOffset() {
 
     private static boolean isErroneous(Tree tree) {
 
-        class TreeChecker extends TreePathScanner<Boolean,Void> {
+        class TreeChecker extends ErrorAwareTreePathScanner<Boolean,Void> {
 
             @Override
             public Boolean scan(Tree tree, Void p) {
diff --git a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ScanLocalVars.java b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ScanLocalVars.java
index e55e21633..b14bc6a0f 100644
--- a/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ScanLocalVars.java
+++ b/debugger.jpda.projects/src/org/netbeans/modules/debugger/jpda/projects/ScanLocalVars.java
@@ -30,7 +30,7 @@
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.EnumSet;
 import java.util.HashSet;
 import java.util.LinkedHashSet;
@@ -51,7 +51,7 @@
  *
  * @author sdedic, Martin Entlicher
  */
-final class ScanLocalVars extends TreePathScanner<Void, Void> {
+final class ScanLocalVars extends ErrorAwareTreePathScanner<Void, Void> {
     
     private static final Set<ElementKind> LOCAL_VARIABLES = EnumSet.of(ElementKind.EXCEPTION_PARAMETER,
                                                                        ElementKind.LOCAL_VARIABLE,
diff --git a/debugger.jpda.projectsui/src/org/netbeans/modules/debugger/jpda/projectsui/EditorContextImpl.java b/debugger.jpda.projectsui/src/org/netbeans/modules/debugger/jpda/projectsui/EditorContextImpl.java
index 9bd7f58a4..f607ad053 100644
--- a/debugger.jpda.projectsui/src/org/netbeans/modules/debugger/jpda/projectsui/EditorContextImpl.java
+++ b/debugger.jpda.projectsui/src/org/netbeans/modules/debugger/jpda/projectsui/EditorContextImpl.java
@@ -19,7 +19,7 @@
 
 package org.netbeans.modules.debugger.jpda.projectsui;
 
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.awt.Color;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
@@ -817,8 +817,8 @@ private static int findLineOffset(StyledDocument doc, int lineNumber) {
     }
     
     public <R,D> R interpretOrCompileCode(final Expression<Object> expression, String url, final int line,
-                                          final TreePathScanner<Boolean,D> canInterpret,
-                                          final TreePathScanner<R,D> interpreter,
+                                          final ErrorAwareTreePathScanner<Boolean,D> canInterpret,
+                                          final ErrorAwareTreePathScanner<R,D> interpreter,
                                           final D context, final boolean staticContext,
                                           final Function<Pair<String, byte[]>, Boolean> compiledClassHandler,
                                           final SourcePathProvider sp) throws InvalidExpressionException {
diff --git a/debugger.jpda.visual/nbproject/project.xml b/debugger.jpda.visual/nbproject/project.xml
index d7112771e..8c5bea1ee 100644
--- a/debugger.jpda.visual/nbproject/project.xml
+++ b/debugger.jpda.visual/nbproject/project.xml
@@ -100,6 +100,14 @@
                         <specification-version>1.0</specification-version>
                     </run-dependency>
                 </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.modules.java.source.base</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <specification-version>2.30</specification-version>
+                    </run-dependency>
+                </dependency>
                 <dependency>
                     <code-name-base>org.netbeans.modules.options.api</code-name-base>
                     <build-prerequisite/>
diff --git a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/EditorContextBridge.java b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/EditorContextBridge.java
index 21bb6de92..065b05cf6 100644
--- a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/EditorContextBridge.java
+++ b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/EditorContextBridge.java
@@ -19,7 +19,7 @@
 package org.netbeans.modules.debugger.jpda;
 
 import com.sun.jdi.AbsentInformationException;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.beans.PropertyChangeListener;
 import java.io.File;
 import java.net.MalformedURLException;
@@ -96,8 +96,8 @@ public static Tree getExpressionTree(final String expression, String url, final
 
     public static <R,D> R interpretOrCompileCode(final Expression<Object> expression,
                                                  final String url, final int line,
-                                                 final TreePathScanner<Boolean,D> canInterpret,
-                                                 final TreePathScanner<R,D> interpreter,
+                                                 final ErrorAwareTreePathScanner<Boolean,D> canInterpret,
+                                                 final ErrorAwareTreePathScanner<R,D> interpreter,
                                                  final D context, final boolean staticContext,
                                                  final Function<Pair<String, byte[]>, Boolean> compiledClassHandler,
                                                  final SourcePathProvider sp) throws InvalidExpressionException {
@@ -105,7 +105,7 @@ public static Tree getExpressionTree(final String expression, String url, final
             return (R) getContext ().getClass().getMethod(
                     "interpretOrCompileCode",
                     new Class[] { Expression.class, String.class, Integer.TYPE,
-                                  TreePathScanner.class, TreePathScanner.class,
+                                  ErrorAwareTreePathScanner.class, ErrorAwareTreePathScanner.class,
                                   Object.class, Boolean.TYPE, Function.class,
                                   SourcePathProvider.class }).
                         invoke(getContext(), new Object[] { expression, url, line,
@@ -347,8 +347,8 @@ public Object annotate (
 
         public <R,D> R interpretOrCompileCode(final Expression<Object> expression,
                                               final String url, final int line,
-                                              final TreePathScanner<Boolean,D> canInterpret,
-                                              final TreePathScanner<R,D> interpreter,
+                                              final ErrorAwareTreePathScanner<Boolean,D> canInterpret,
+                                              final ErrorAwareTreePathScanner<R,D> interpreter,
                                               final D context, final boolean staticContext,
                                               final Function<Pair<String, byte[]>, Boolean> compiledClassHandler,
                                               final SourcePathProvider sp) throws InvalidExpressionException {
@@ -356,8 +356,8 @@ public Object annotate (
             try {
                 ret = (R) cp1.getClass().getMethod(
                     "interpretOrCompileCode",
-                    new Class[] { Expression.class, String.class, Integer.TYPE, TreePathScanner.class,
-                                  TreePathScanner.class, Object.class, Boolean.TYPE, Function.class,
+                    new Class[] { Expression.class, String.class, Integer.TYPE, ErrorAwareTreePathScanner.class,
+                                  ErrorAwareTreePathScanner.class, Object.class, Boolean.TYPE, Function.class,
                                   SourcePathProvider.class }).
                         invoke(cp1, new Object[] { expression, url, line, canInterpret, interpreter,
                                                    context, staticContext, compiledClassHandler, sp });
@@ -375,8 +375,8 @@ public Object annotate (
                 try {
                     ret = (R) cp2.getClass().getMethod(
                     "interpretOrCompileCode",
-                    new Class[] { Expression.class, String.class, Integer.TYPE, TreePathScanner.class,
-                                  TreePathScanner.class, Object.class, Boolean.TYPE, Function.class,
+                    new Class[] { Expression.class, String.class, Integer.TYPE, ErrorAwareTreePathScanner.class,
+                                  ErrorAwareTreePathScanner.class, Object.class, Boolean.TYPE, Function.class,
                                   SourcePathProvider.class }).
                         invoke(cp2, new Object[] { expression, url, line, canInterpret, interpreter,
                                                    context, staticContext, compiledClassHandler, sp });
diff --git a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/CanInterpretVisitor.java b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/CanInterpretVisitor.java
index cd2a581a8..ba0313e7e 100644
--- a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/CanInterpretVisitor.java
+++ b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/CanInterpretVisitor.java
@@ -32,14 +32,14 @@
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.UsesTree;
 import com.sun.source.tree.WhileLoopTree;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 
 /**
  * Test of ability and suitability of an interpreter or compiler when evaluating.
  * 
  * @author Martin
  */
-class CanInterpretVisitor extends TreePathScanner<Boolean, EvaluationContext> {
+class CanInterpretVisitor extends ErrorAwareTreePathScanner<Boolean, EvaluationContext> {
 
     @Override
     public Boolean reduce(Boolean r1, Boolean r2) {
diff --git a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/EvaluatorVisitor.java b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/EvaluatorVisitor.java
index 88f438800..d7554830c 100644
--- a/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/EvaluatorVisitor.java
+++ b/debugger.jpda/src/org/netbeans/modules/debugger/jpda/expr/EvaluatorVisitor.java
@@ -128,7 +128,7 @@
 import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.tree.WildcardTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -184,7 +184,7 @@
  * @author Martin Entlicher
  */
 @SuppressWarnings("ClassWithMultipleLoggers")
-public class EvaluatorVisitor extends TreePathScanner<Mirror, EvaluationContext> {
+public class EvaluatorVisitor extends ErrorAwareTreePathScanner<Mirror, EvaluationContext> {
 
     private static final Logger loggerMethod = Logger.getLogger("org.netbeans.modules.debugger.jpda.invokeMethod"); // NOI18N
     private static final Logger loggerValue = Logger.getLogger("org.netbeans.modules.debugger.jpda.getValue"); // NOI18N
diff --git a/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/JDIWrappersTest.java b/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/JDIWrappersTest.java
index ecccbb5ec..d377ca3f3 100644
--- a/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/JDIWrappersTest.java
+++ b/debugger.jpda/test/unit/src/org/netbeans/api/debugger/jpda/JDIWrappersTest.java
@@ -30,7 +30,7 @@
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.TypeCastTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import java.util.List;
 import javax.lang.model.element.Element;
@@ -142,7 +142,7 @@ public void run(CompilationController ci) throws Exception {
         return successPtr[0];
     }
 
-    private static class JDICallsScanner extends TreeScanner<Void, Object> {
+    private static class JDICallsScanner extends ErrorAwareTreeScanner<Void, Object> {
 
         private Trees trees;
         private Types types;
diff --git a/form.binding/nbproject/project.properties b/form.binding/nbproject/project.properties
index 2b2204905..9924871d7 100644
--- a/form.binding/nbproject/project.properties
+++ b/form.binding/nbproject/project.properties
@@ -18,3 +18,4 @@
 is.eager=true
 javac.source=1.6
 spec.version.base=0.18.0
+requires.nb.javac=true
diff --git a/form.j2ee/nbproject/project.properties b/form.j2ee/nbproject/project.properties
index f4bc62ba3..6b1d98d71 100644
--- a/form.j2ee/nbproject/project.properties
+++ b/form.j2ee/nbproject/project.properties
@@ -18,3 +18,4 @@
 is.eager=true
 javac.source=1.6
 spec.version.base=0.34.0
+requires.nb.javac=true
diff --git a/form.nb/nbproject/project.properties b/form.nb/nbproject/project.properties
index 982a0776a..5c8755749 100644
--- a/form.nb/nbproject/project.properties
+++ b/form.nb/nbproject/project.properties
@@ -18,3 +18,4 @@
 is.eager=true
 javac.source=1.6
 spec.version.base=0.19.0
+requires.nb.javac=true
diff --git a/form.refactoring/nbproject/project.properties b/form.refactoring/nbproject/project.properties
index 2b2204905..9924871d7 100644
--- a/form.refactoring/nbproject/project.properties
+++ b/form.refactoring/nbproject/project.properties
@@ -18,3 +18,4 @@
 is.eager=true
 javac.source=1.6
 spec.version.base=0.18.0
+requires.nb.javac=true
diff --git a/form.refactoring/src/org/netbeans/modules/form/refactoring/RADComponentRenameRefactoringSupport.java b/form.refactoring/src/org/netbeans/modules/form/refactoring/RADComponentRenameRefactoringSupport.java
index 0d0d795a9..578d554c6 100644
--- a/form.refactoring/src/org/netbeans/modules/form/refactoring/RADComponentRenameRefactoringSupport.java
+++ b/form.refactoring/src/org/netbeans/modules/form/refactoring/RADComponentRenameRefactoringSupport.java
@@ -22,7 +22,7 @@
 import com.sun.source.tree.IdentifierTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -106,7 +106,7 @@ private static boolean emptyOrWhite(String s){
     }
 
     private static class MemberVisitor
-            extends TreePathScanner<Void, Void>
+            extends ErrorAwareTreePathScanner<Void, Void>
             implements CancellableTask<CompilationController>{
         
         private CompilationInfo info;
diff --git a/hibernate/nbproject/project.properties b/hibernate/nbproject/project.properties
index 931ad2ea7..83b9fdc2c 100644
--- a/hibernate/nbproject/project.properties
+++ b/hibernate/nbproject/project.properties
@@ -37,3 +37,5 @@ test.config.stableBTD.excludes=\
     **/HibernateEnvironmentTest.class,\
     **/HibernateMappingCompletionManagerTest.class,\
     **/HibernateMappingHyperlinkProviderTest.class
+
+requires.nb.javac=true
diff --git a/i18n/nbproject/project.properties b/i18n/nbproject/project.properties
index def229133..73e1ef5eb 100644
--- a/i18n/nbproject/project.properties
+++ b/i18n/nbproject/project.properties
@@ -20,3 +20,4 @@ javadoc.arch=${basedir}/arch.xml
 disable.qa-functional.tests=true
 
 test.config.stableBTD.includes=**/*Test.class
+requires.nb.javac=true
diff --git a/ide/launcher/netbeans.conf b/ide/launcher/netbeans.conf
index 6628c383c..877ea18b0 100644
--- a/ide/launcher/netbeans.conf
+++ b/ide/launcher/netbeans.conf
@@ -60,7 +60,7 @@ netbeans_default_cachedir="${DEFAULT_CACHEDIR_ROOT}/dev"
 # Concurrent Mark & Sweep garbage collector.
 # (see http://wiki.netbeans.org/FaqGCPauses)
 #
-netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-Dnetbeans.logger.console=true -J-ea -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.java2d.dpiaware=true -J-Dsun.zip.disableMemoryMapping=true -J-Dplugin.manager.check.updates=false -J-Dnetbeans.extbrowser.manual_chrome_plugin_install=yes -J--add-opens=java.base/java.net=ALL-UNNAMED -J--add-opens=java.base/java.lang.ref=ALL-UNNAMED -J--add-opens=java.base/java.lang=ALL-UNNAMED -J--add-opens=java.base/java.security=ALL-UNNAMED -J--add-opens=java.base/java.util=ALL-UNNAMED -J--add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED -J--add-opens=java.desktop/javax.swing.text=ALL-UNNAMED -J--add-opens=java.desktop/javax.swing=ALL-UNNAMED -J--add-opens=java.desktop/java.awt=ALL-UNNAMED -J--add-opens=java.desktop/java.awt.event=ALL-UNNAMED -J--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED -J--add-opens=jdk.jshell/jdk.jshell=ALL-UNNAMED -J--add-modules=java.activation,jdk.jshell,java.xml.bind -J--add-exports=java.desktop/sun.awt=ALL-UNNAMED -J--add-exports=java.desktop/java.awt.peer=ALL-UNNAMED -J--add-exports=java.desktop/com.sun.beans.editors=ALL-UNNAMED -J--add-exports=java.desktop/sun.swing=ALL-UNNAMED -J--add-exports=java.desktop/sun.awt.im=ALL-UNNAMED -J--add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED -J--add-exports=java.management/sun.management=ALL-UNNAMED -J--add-exports=java.base/sun.reflect.annotation=ALL-UNNAMED -J-XX:+IgnoreUnrecognizedVMOptions"
+netbeans_default_options="-J-client -J-Xss2m -J-Xms32m -J-Dnetbeans.logger.console=true -J-ea -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.java2d.dpiaware=true -J-Dsun.zip.disableMemoryMapping=true -J-Dplugin.manager.check.updates=false -J-Dnetbeans.extbrowser.manual_chrome_plugin_install=yes -J--add-opens=java.base/java.net=ALL-UNNAMED -J--add-opens=java.base/java.lang.ref=ALL-UNNAMED -J--add-opens=java.base/java.lang=ALL-UNNAMED -J--add-opens=java.base/java.security=ALL-UNNAMED -J--add-opens=java.base/java.util=ALL-UNNAMED -J--add-opens=java.desktop/javax.swing.plaf.basic=ALL-UNNAMED -J--add-opens=java.desktop/javax.swing.text=ALL-UNNAMED -J--add-opens=java.desktop/javax.swing=ALL-UNNAMED -J--add-opens=java.desktop/java.awt=ALL-UNNAMED -J--add-opens=java.desktop/java.awt.event=ALL-UNNAMED -J--add-opens=java.prefs/java.util.prefs=ALL-UNNAMED -J--add-opens=jdk.jshell/jdk.jshell=ALL-UNNAMED -J--add-modules=java.activation,jdk.jshell,java.xml.bind -J--add-exports=java.desktop/sun.awt=ALL-UNNAMED -J--add-exports=java.desktop/java.awt.peer=ALL-UNNAMED -J--add-exports=java.desktop/com.sun.beans.editors=ALL-UNNAMED -J--add-exports=java.desktop/sun.swing=ALL-UNNAMED -J--add-exports=java.desktop/sun.awt.im=ALL-UNNAMED -J--add-exports=jdk.internal.jvmstat/sun.jvmstat.monitor=ALL-UNNAMED -J--add-exports=java.management/sun.management=ALL-UNNAMED -J--add-exports=java.base/sun.reflect.annotation=ALL-UNNAMED -J--add-exports=jdk.javadoc/com.sun.tools.javadoc.main=ALL-UNNAMED -J-XX:+IgnoreUnrecognizedVMOptions"
 
 # Default location of JDK:
 # (set by installer or commented out if launcher should decide)
diff --git a/j2ee.core.utilities/nbproject/project.properties b/j2ee.core.utilities/nbproject/project.properties
index cf40f2968..95da0b41d 100644
--- a/j2ee.core.utilities/nbproject/project.properties
+++ b/j2ee.core.utilities/nbproject/project.properties
@@ -23,3 +23,5 @@ is.autoload=true
 test.config.stableBTD.includes=**/*Test.class
 test.config.stableBTD.excludes=\
     **/SourceGroupsTest.class
+
+requires.nb.javac=true
diff --git a/java.api.common/src/org/netbeans/modules/java/api/common/classpath/ModuleClassPaths.java b/java.api.common/src/org/netbeans/modules/java/api/common/classpath/ModuleClassPaths.java
index 8c4e98c50..10c6606c5 100644
--- a/java.api.common/src/org/netbeans/modules/java/api/common/classpath/ModuleClassPaths.java
+++ b/java.api.common/src/org/netbeans/modules/java/api/common/classpath/ModuleClassPaths.java
@@ -20,7 +20,7 @@
 
 import com.sun.source.tree.ModuleTree;
 import com.sun.source.tree.RequiresTree;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeSupport;
@@ -1249,7 +1249,7 @@ private static boolean collectRequiredModulesImpl(
                 }
                 if (moduleTree != null) {
                     //Add dependencies for non resolvable modules.
-                    moduleTree.accept(new TreeScanner<Void, Void>() {
+                    moduleTree.accept(new ErrorAwareTreeScanner<Void, Void>() {
                                 @Override
                                 public Void visitRequires(RequiresTree node, Void p) {
                                     final String moduleName = node.getModuleName().toString();
diff --git a/java.api.common/src/org/netbeans/modules/java/api/common/impl/DefaultProjectModulesModifier.java b/java.api.common/src/org/netbeans/modules/java/api/common/impl/DefaultProjectModulesModifier.java
index db6f7b96b..15f872844 100644
--- a/java.api.common/src/org/netbeans/modules/java/api/common/impl/DefaultProjectModulesModifier.java
+++ b/java.api.common/src/org/netbeans/modules/java/api/common/impl/DefaultProjectModulesModifier.java
@@ -22,7 +22,7 @@
 import com.sun.source.tree.DirectiveTree;
 import com.sun.source.tree.ModuleTree;
 import com.sun.source.tree.RequiresTree;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
@@ -190,7 +190,7 @@ public static boolean addRequiredModules(
             final Set<String> knownModules = new HashSet<>();
             final ModuleTree[] module = new ModuleTree[1];
             final RequiresTree[] lastRequires = new RequiresTree[1];
-            cu.accept(new TreeScanner<Void, Void>() {
+            cu.accept(new ErrorAwareTreeScanner<Void, Void>() {
                         @Override
                         public Void visitModule(ModuleTree m, Void p) {
                             module[0] = m;
@@ -259,7 +259,7 @@ public static boolean removeRequiredModules(FileObject moduleInfo, Collection<St
                     final Set<DirectiveTree> toRemove = new HashSet<>();
                     final ModuleTree[] module = new ModuleTree[1];
                     cu.accept(
-                            new TreeScanner<Void, Set<DirectiveTree>>() {
+                            new ErrorAwareTreeScanner<Void, Set<DirectiveTree>>() {
                                 @Override
                                 public Void visitModule(final ModuleTree node, Set<DirectiveTree> param) {
                                     module[0] = node;
@@ -339,7 +339,7 @@ public Void visitRequires(final RequiresTree node, final Set<DirectiveTree> para
         return resultMap;
     }
     
-    private static class S extends TreeScanner implements Task<CompilationController> {
+    private static class S extends ErrorAwareTreeScanner implements Task<CompilationController> {
         final Map<URL, Collection<ClassPath>> resultMap;
         final ClassPath g;
         final Map<String, URL> modLocations;
diff --git a/java.api.common/src/org/netbeans/modules/java/api/common/impl/TemplateModuleDeclarator.java b/java.api.common/src/org/netbeans/modules/java/api/common/impl/TemplateModuleDeclarator.java
index 5cda1143b..434525f02 100644
--- a/java.api.common/src/org/netbeans/modules/java/api/common/impl/TemplateModuleDeclarator.java
+++ b/java.api.common/src/org/netbeans/modules/java/api/common/impl/TemplateModuleDeclarator.java
@@ -23,7 +23,7 @@
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -201,7 +201,7 @@ private void findModuleNames(String fqn, ClassPath searchPath, Set<String> modul
         }
     }
    
-    private static class Scanner extends TreePathScanner<Boolean, Boolean> {
+    private static class Scanner extends ErrorAwareTreePathScanner<Boolean, Boolean> {
         private final CompilationInfo info;
         private final Set<String> unresolved;
         
diff --git a/java.completion/nbproject/project.xml b/java.completion/nbproject/project.xml
index d60395477..4b3df6b14 100644
--- a/java.completion/nbproject/project.xml
+++ b/java.completion/nbproject/project.xml
@@ -149,6 +149,10 @@
                         <code-name-base>org.netbeans.modules.java.editor</code-name-base>
                         <compile-dependency/>
                     </test-dependency>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.modules.java.j2seplatform</code-name-base>
+                        <compile-dependency/>
+                    </test-dependency>
                     <test-dependency>
                         <code-name-base>org.netbeans.modules.java.source</code-name-base>
                         <compile-dependency/>
diff --git a/java.completion/src/org/netbeans/modules/java/completion/BaseTask.java b/java.completion/src/org/netbeans/modules/java/completion/BaseTask.java
index 3be35112e..e1d04f816 100644
--- a/java.completion/src/org/netbeans/modules/java/completion/BaseTask.java
+++ b/java.completion/src/org/netbeans/modules/java/completion/BaseTask.java
@@ -37,7 +37,7 @@
 import com.sun.source.tree.*;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import javax.lang.model.element.Name;
 
 import org.netbeans.api.java.lexer.JavaTokenId;
@@ -572,7 +572,7 @@ private static String whitespaceString(int length) {
         return sb.toString();
     }
 
-    private static class SourcePositionsImpl extends TreeScanner<Void, Tree> implements SourcePositions {
+    private static class SourcePositionsImpl extends ErrorAwareTreeScanner<Void, Tree> implements SourcePositions {
 
         private final Tree root;
         private final SourcePositions original;
@@ -619,6 +619,7 @@ public Void scan(Tree node, Tree p) {
             }
             return null;
         }
+
     }
 
     private static boolean isCamelCasePrefix(String prefix) {
diff --git a/java.completion/src/org/netbeans/modules/java/completion/JavaCompletionTask.java b/java.completion/src/org/netbeans/modules/java/completion/JavaCompletionTask.java
index 096df6c0d..23e9f3276 100644
--- a/java.completion/src/org/netbeans/modules/java/completion/JavaCompletionTask.java
+++ b/java.completion/src/org/netbeans/modules/java/completion/JavaCompletionTask.java
@@ -45,6 +45,7 @@
 import org.netbeans.api.java.source.JavaSource.Phase;
 import org.netbeans.api.java.source.ClassIndex;
 import org.netbeans.api.java.source.ClassIndex.Symbols;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import org.netbeans.api.java.source.support.ReferencesCount;
 import org.netbeans.api.lexer.TokenSequence;
 import org.netbeans.modules.parsing.api.Source;
@@ -5626,7 +5627,7 @@ private TypeMirror adjustType(Env env, TypeMirror original, Element element, Tre
                             if (element == trees.getElement(new TreePath(path, instTree.getExpression()))) {
                                 TypeMirror tm = trees.getTypeMirror(new TreePath(path, instTree.getType()));
                                 if (tm != null && tu.isCastable(original, tm)) {
-                                    Boolean used = new TreePathScanner<Boolean, Element>() {
+                                    Boolean used = new ErrorAwareTreePathScanner<Boolean, Element>() {
                                         @Override
                                         public Boolean reduce(Boolean r1, Boolean r2) {
                                             return r1 == Boolean.TRUE ? r1 : r2;
diff --git a/java.completion/test/unit/src/org/netbeans/modules/java/completion/CompletionTestBase.java b/java.completion/test/unit/src/org/netbeans/modules/java/completion/CompletionTestBase.java
index 96d47dc20..7e77cfe08 100644
--- a/java.completion/test/unit/src/org/netbeans/modules/java/completion/CompletionTestBase.java
+++ b/java.completion/test/unit/src/org/netbeans/modules/java/completion/CompletionTestBase.java
@@ -47,6 +47,7 @@
 
 import org.netbeans.api.editor.mimelookup.MimeLookup;
 import org.netbeans.api.java.classpath.ClassPath;
+import org.netbeans.api.java.classpath.JavaClassPathConstants;
 import org.netbeans.api.java.lexer.JavaTokenId;
 import org.netbeans.api.java.source.*;
 import org.netbeans.api.java.source.support.ReferencesCount;
@@ -54,7 +55,7 @@
 import org.netbeans.core.startup.Main;
 import org.netbeans.junit.NbTestCase;
 import org.netbeans.modules.java.JavaDataLoader;
-import org.netbeans.modules.java.source.TreeLoader;
+import org.netbeans.modules.java.source.TestUtil;
 import org.netbeans.modules.java.source.indexing.TransactionContext;
 import org.netbeans.modules.java.source.usages.BinaryAnalyser;
 import org.netbeans.modules.java.source.usages.ClassIndexImpl;
@@ -83,7 +84,7 @@
     
     static {
         JavaCompletionTaskBasicTest.class.getClassLoader().setDefaultAssertionStatus(true);
-        TreeLoader.DISABLE_ARTIFICAL_PARAMETER_NAMES = true;
+        SourceUtilsTestUtil2.disableArtificalParameterNames();
     }
 
     static final int FINISH_OUTTIME = 5 * 60 * 1000;
@@ -126,10 +127,10 @@ public ClassPath findClassPath(FileObject file, String type) {
                     if (type.equals(ClassPath.COMPILE)) {
                         return ClassPathSupport.createClassPath(new FileObject[0]);
                     }
-                    if (type.equals(ClassPath.BOOT)) {
+                    if (type.equals(ClassPath.BOOT) || type.equals(JavaClassPathConstants.MODULE_BOOT_PATH)) {
                         ClassPath cp = bootCache;
                         if (cp == null) {
-                            bootCache = cp = createClassPath(System.getProperty("sun.boot.class.path"));
+                            cp = TestUtil.getBootClassPath();
                         }
                         return cp;
                     }
@@ -255,13 +256,29 @@ protected void performTest(String source, int caretPos, String textToInsert, Str
         }
         
         
-        File goldenFile = new File(getDataDir(), "/goldenfiles/org/netbeans/modules/java/completion/JavaCompletionTaskTest/" + version + "/" + goldenFileName);
+        File goldenFile = null;
+        for (String variant : VERSION_VARIANTS.get(version)) {
+            goldenFile = new File(getDataDir(), "/goldenfiles/org/netbeans/modules/java/completion/JavaCompletionTaskTest/" + variant + "/" + goldenFileName);
+            if (goldenFile.exists())
+                break;
+        }
+        assertNotNull(goldenFile);
         File diffFile = new File(getWorkDir(), getName() + ".diff");        
         assertFile(output, goldenFile, diffFile);
         
         LifecycleManager.getDefault().saveAll();
     }
 
+    private static final Map<String, List<String>> VERSION_VARIANTS = new HashMap<>();
+
+    static {
+        VERSION_VARIANTS.put("1.8", Arrays.asList("1.8"));
+        VERSION_VARIANTS.put("9", Arrays.asList("9", "1.8"));
+        VERSION_VARIANTS.put("1.9", Arrays.asList("9", "1.8"));
+        VERSION_VARIANTS.put("10", Arrays.asList("10", "9", "1.8"));
+        VERSION_VARIANTS.put("1.10", Arrays.asList("10", "9", "1.8"));
+    }
+
     private void copyToWorkDir(File resource, File toFile) throws IOException {
         InputStream is = new FileInputStream(resource);
         OutputStream outs = new FileOutputStream(toFile);
diff --git a/java.debug/src/org/netbeans/modules/java/debug/TreeNavigatorProviderImpl.java b/java.debug/src/org/netbeans/modules/java/debug/TreeNavigatorProviderImpl.java
index 822b10622..ab9e668a0 100644
--- a/java.debug/src/org/netbeans/modules/java/debug/TreeNavigatorProviderImpl.java
+++ b/java.debug/src/org/netbeans/modules/java/debug/TreeNavigatorProviderImpl.java
@@ -23,7 +23,7 @@
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.awt.BorderLayout;
 import java.awt.Color;
 import java.beans.PropertyChangeEvent;
@@ -228,7 +228,7 @@ private static TreePath plainPathFor(final CompilationInfo info, int pos) {
             }
         }
 
-        class PathFinder extends TreePathScanner<Void,Void> {
+        class PathFinder extends ErrorAwareTreePathScanner<Void,Void> {
             private int pos;
             private SourcePositions sourcePositions;
 
diff --git a/java.editor.base/src/org/netbeans/modules/java/editor/base/imports/UnusedImports.java b/java.editor.base/src/org/netbeans/modules/java/editor/base/imports/UnusedImports.java
index 43185b318..bb6ff1210 100644
--- a/java.editor.base/src/org/netbeans/modules/java/editor/base/imports/UnusedImports.java
+++ b/java.editor.base/src/org/netbeans/modules/java/editor/base/imports/UnusedImports.java
@@ -28,7 +28,7 @@
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -192,7 +192,7 @@ private boolean isStar(ImportTree tree) {
         private boolean parseErrorInImport(ImportTree imp) {
             if (isStar(imp)) return false;
             final StringBuilder fqn = new StringBuilder();
-            new TreeScanner<Void, Void>() {
+            new ErrorAwareTreeScanner<Void, Void>() {
                 @Override
                 public Void visitMemberSelect(MemberSelectTree node, Void p) {
                     super.visitMemberSelect(node, p);
diff --git a/java.editor.base/src/org/netbeans/modules/java/editor/base/javadoc/JavadocImports.java b/java.editor.base/src/org/netbeans/modules/java/editor/base/javadoc/JavadocImports.java
index 0a5878373..42a22dd1e 100644
--- a/java.editor.base/src/org/netbeans/modules/java/editor/base/javadoc/JavadocImports.java
+++ b/java.editor.base/src/org/netbeans/modules/java/editor/base/javadoc/JavadocImports.java
@@ -36,7 +36,7 @@
 import com.sun.source.util.DocTreePathScanner;
 import com.sun.source.util.DocTrees;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -98,7 +98,7 @@ private JavadocImports() {
         
         new DocTreePathScanner<Void, Void>() {
             @Override public Void visitReference(ReferenceTree node, Void p) {
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override public Void visitIdentifier(IdentifierTree node, Void p) {
                         Element el = trees.getElement(getCurrentPath());
                         
@@ -143,7 +143,7 @@ public Void scan(Iterable<? extends TreePath> toAnalyze, Void p) {
         
         new DocTreePathScanner<Void, Void>() {
             @Override public Void visitReference(ReferenceTree node, Void p) {
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override public Void visitIdentifier(IdentifierTree node, Void p) {
                         if (toFind.equals(trees.getElement(getCurrentPath()))) {
                             handleUsage((int) trees.getSourcePositions().getStartPosition(javac.getCompilationUnit(), node));
@@ -269,7 +269,7 @@ public static Element findReferencedElement(final CompilationInfo javac, final i
                     result[0] = trees.getElement(getCurrentPath());
                     return null;
                 }
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override public Void visitIdentifier(IdentifierTree node, Void p) {
                         if (   positions.getStartPosition(javac.getCompilationUnit(), node) <= offset
                             && positions.getEndPosition(javac.getCompilationUnit(), node) >= offset) {
@@ -350,7 +350,7 @@ public static Token findNameTokenOfReferencedElement(final CompilationInfo javac
                     handleUsage(offset);
                     return null;
                 }
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override public Void visitIdentifier(IdentifierTree node, Void p) {
                         if (   positions.getStartPosition(javac.getCompilationUnit(), node) <= offset
                             && positions.getEndPosition(javac.getCompilationUnit(), node) >= offset) {
@@ -509,7 +509,7 @@ private static boolean isReferenceTag(Token<JavadocTokenId> tag) {
         return javadoc;
     }
 
-    private static final class UnresolvedImportScanner extends TreePathScanner<Void, Void> {
+    private static final class UnresolvedImportScanner extends ErrorAwareTreePathScanner<Void, Void> {
         
         private final CompilationInfo javac;
         private Set<String> unresolved = new HashSet<String>();
@@ -544,7 +544,7 @@ private void resolveElement() {
             
             new DocTreePathScanner<Void, Void>() {
                 @Override public Void visitReference(ReferenceTree node, Void p) {
-                    new TreePathScanner<Void, Void>() {
+                    new ErrorAwareTreePathScanner<Void, Void>() {
                         @Override public Void visitIdentifier(IdentifierTree node, Void p) {
                             Element el = trees.getElement(getCurrentPath());
                             
diff --git a/java.editor.base/src/org/netbeans/modules/java/editor/base/semantic/MarkOccurrencesHighlighterBase.java b/java.editor.base/src/org/netbeans/modules/java/editor/base/semantic/MarkOccurrencesHighlighterBase.java
index 08b14bc78..c60c51a7a 100644
--- a/java.editor.base/src/org/netbeans/modules/java/editor/base/semantic/MarkOccurrencesHighlighterBase.java
+++ b/java.editor.base/src/org/netbeans/modules/java/editor/base/semantic/MarkOccurrencesHighlighterBase.java
@@ -37,7 +37,7 @@
 import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -555,7 +555,7 @@ protected final synchronized void resume() {
         final List<int[]> result = new ArrayList<int[]>();
         if (labeledStatement.getLeaf().getKind() == Kind.LABELED_STATEMENT) {
             final Name label = ((LabeledStatementTree)labeledStatement.getLeaf()).getLabel();
-            new TreePathScanner <Void, Void>() {
+            new ErrorAwareTreePathScanner <Void, Void>() {
                 @Override
                 public Void visitBreak(BreakTree node, Void p) {
                     if (node.getLabel() != null && label.contentEquals(node.getLabel())) {
diff --git a/java.editor.base/test/unit/src/org/netbeans/modules/java/editor/base/semantic/UnusedImportsTest.java b/java.editor.base/test/unit/src/org/netbeans/modules/java/editor/base/semantic/UnusedImportsTest.java
index df4a05801..069767ecb 100644
--- a/java.editor.base/test/unit/src/org/netbeans/modules/java/editor/base/semantic/UnusedImportsTest.java
+++ b/java.editor.base/test/unit/src/org/netbeans/modules/java/editor/base/semantic/UnusedImportsTest.java
@@ -34,13 +34,13 @@
 import org.netbeans.api.java.source.JavaSource.Phase;
 import org.netbeans.api.java.source.SourceUtils;
 import org.netbeans.api.java.source.SourceUtilsTestUtil;
+import org.netbeans.api.java.source.SourceUtilsTestUtil2;
 import org.netbeans.api.java.source.TestUtilities;
 import org.netbeans.api.java.source.TreePathHandle;
 import org.netbeans.api.lexer.Language;
 import org.netbeans.core.startup.Main;
 import org.netbeans.junit.NbTestCase;
 import org.netbeans.modules.java.editor.base.imports.UnusedImports;
-import org.netbeans.modules.java.source.TreeLoader;
 import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
 import org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater;
 import org.netbeans.spi.java.classpath.support.ClassPathSupport;
@@ -335,7 +335,7 @@ public void testBrokenSource() throws Exception {
 
     private void performUnusedImportsTest(String... golden) throws Exception {
         CompilationInfo ci = SourceUtilsTestUtil.getCompilationInfo(JavaSource.forFileObject(src.getFileObject("test/Main.java")), Phase.RESOLVED);
-        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
+        SourceUtilsTestUtil2.disableConfinementTest();
         Document doc = ci.getSnapshot().getSource().getDocument(true);
         doc.putProperty(Language.class, JavaTokenId.language());
         List<TreePathHandle> unused = UnusedImports.computeUnusedImports(ci);
diff --git a/java.editor/nbproject/project.xml b/java.editor/nbproject/project.xml
index ebb367662..98e78586b 100644
--- a/java.editor/nbproject/project.xml
+++ b/java.editor/nbproject/project.xml
@@ -534,6 +534,10 @@
                         <compile-dependency/>
                         <test/>
                     </test-dependency>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.modules.java.j2seplatform</code-name-base>
+                        <compile-dependency/>
+                    </test-dependency>
                     <test-dependency>
                         <code-name-base>org.netbeans.modules.java.source.base</code-name-base>
                         <recursive/>
diff --git a/java.editor/src/org/netbeans/modules/editor/java/GoToSupport.java b/java.editor/src/org/netbeans/modules/editor/java/GoToSupport.java
index bec14ba38..1a68977a3 100644
--- a/java.editor/src/org/netbeans/modules/editor/java/GoToSupport.java
+++ b/java.editor/src/org/netbeans/modules/editor/java/GoToSupport.java
@@ -38,7 +38,7 @@
 import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.awt.Toolkit;
 import java.awt.event.KeyEvent;
@@ -706,7 +706,7 @@ private static TreePath adjustPathForModuleName(TreePath path) {
     private static TreePath getPath(final CompilationInfo info, Element el) {
         final Element toFind = info.getElementUtilities().isSynthetic(el) ? el.getEnclosingElement() : el;
 
-        class S extends TreePathScanner<Void, Void> {
+        class S extends ErrorAwareTreePathScanner<Void, Void> {
             private TreePath found;
             @Override
             public Void scan(Tree tree, Void p) {
@@ -760,7 +760,7 @@ public Void visitTypeParameter(TypeParameterTree node, Void p) {
         return search.found;
     }
 
-    private static final class FindSuperConstructorCall extends TreePathScanner<TreePath, Void> {
+    private static final class FindSuperConstructorCall extends ErrorAwareTreePathScanner<TreePath, Void> {
         
         @Override
         public TreePath visitMethodInvocation(MethodInvocationTree tree, Void v) {
diff --git a/java.editor/src/org/netbeans/modules/editor/java/JavaCodeTemplateProcessor.java b/java.editor/src/org/netbeans/modules/editor/java/JavaCodeTemplateProcessor.java
index 7eead5bba..e5bb351d7 100644
--- a/java.editor/src/org/netbeans/modules/editor/java/JavaCodeTemplateProcessor.java
+++ b/java.editor/src/org/netbeans/modules/editor/java/JavaCodeTemplateProcessor.java
@@ -34,6 +34,7 @@
 import javax.swing.text.JTextComponent;
 
 import org.netbeans.api.java.source.*;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import org.netbeans.api.java.source.ui.ElementHeaders;
 import org.netbeans.api.progress.ProgressUtils;
 import org.netbeans.lib.editor.codetemplates.spi.*;
@@ -245,7 +246,7 @@ private void updateTemplateBasedOnSelection() {
                                 final SourcePositions sp = trees.getSourcePositions();
                                 final Map<VariableElement, VariableTree> vars = new HashMap<>();
                                 final LinkedList<VariableTree> varList = new LinkedList<>();
-                                TreePathScanner scanner = new TreePathScanner() {
+                                ErrorAwareTreePathScanner scanner = new ErrorAwareTreePathScanner() {
                                     private int cnt = 0;
                                     @Override
                                     public Object visitIdentifier(IdentifierTree node, Object p) {
diff --git a/java.editor/src/org/netbeans/modules/editor/java/Utilities.java b/java.editor/src/org/netbeans/modules/editor/java/Utilities.java
index 28caeb482..4aaa7cfaf 100644
--- a/java.editor/src/org/netbeans/modules/editor/java/Utilities.java
+++ b/java.editor/src/org/netbeans/modules/editor/java/Utilities.java
@@ -39,9 +39,9 @@
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 
 import java.awt.Color;
 import java.util.*;
@@ -467,7 +467,7 @@ public static boolean isBoolean(TypeMirror type) {
     public static Set<Element> getUsedElements(final CompilationInfo info) {
         final Set<Element> ret = new HashSet<>();
         final Trees trees = info.getTrees();
-        new TreePathScanner<Void, Void>() {
+        new ErrorAwareTreePathScanner<Void, Void>() {
 
             @Override
             public Void visitIdentifier(IdentifierTree node, Void p) {
@@ -516,7 +516,7 @@ private void addElement(Element element) {
     
     public static boolean containErrors(Tree tree) {
         final AtomicBoolean containsErrors = new AtomicBoolean();
-        new TreeScanner<Void, Void>() {
+        new ErrorAwareTreeScanner<Void, Void>() {
             @Override
             public Void visitErroneous(ErroneousTree node, Void p) {
                 containsErrors.set(true);
diff --git a/java.editor/src/org/netbeans/modules/java/editor/codegen/EqualsHashCodeGenerator.java b/java.editor/src/org/netbeans/modules/java/editor/codegen/EqualsHashCodeGenerator.java
index 81b19c813..08ebbac6c 100644
--- a/java.editor/src/org/netbeans/modules/java/editor/codegen/EqualsHashCodeGenerator.java
+++ b/java.editor/src/org/netbeans/modules/java/editor/codegen/EqualsHashCodeGenerator.java
@@ -36,7 +36,7 @@
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.awt.Dialog;
 import java.beans.PropertyChangeEvent;
@@ -182,7 +182,7 @@ static EqualsHashCodeGenerator createEqualsHashCodeGenerator(JTextComponent comp
     /** Checks whether a field is used inside given methods.
      */
     private static boolean isUsed(CompilationInfo cc, VariableElement field, ExecutableElement... methods) {
-        class Used extends TreePathScanner<Void, VariableElement> {
+        class Used extends ErrorAwareTreePathScanner<Void, VariableElement> {
             boolean found;
             
             @Override
diff --git a/java.editor/src/org/netbeans/modules/java/editor/fold/ResourceStringFoldProvider.java b/java.editor/src/org/netbeans/modules/java/editor/fold/ResourceStringFoldProvider.java
index 7ccea2e14..76f19f94e 100644
--- a/java.editor/src/org/netbeans/modules/java/editor/fold/ResourceStringFoldProvider.java
+++ b/java.editor/src/org/netbeans/modules/java/editor/fold/ResourceStringFoldProvider.java
@@ -28,7 +28,7 @@
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -177,7 +177,7 @@ public void cancel() {
     }
     
 
-    private static class V extends TreePathScanner<Void, Void> {
+    private static class V extends ErrorAwareTreePathScanner<Void, Void> {
         private final FileObject                  anchor;
         private final Proc                         proc;
         private final CompilationInfo info;
diff --git a/java.editor/src/org/netbeans/modules/java/editor/imports/ClipboardHandler.java b/java.editor/src/org/netbeans/modules/java/editor/imports/ClipboardHandler.java
index 90eaf6ea1..14adc771a 100644
--- a/java.editor/src/org/netbeans/modules/java/editor/imports/ClipboardHandler.java
+++ b/java.editor/src/org/netbeans/modules/java/editor/imports/ClipboardHandler.java
@@ -29,7 +29,7 @@
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.awt.Dialog;
 import java.awt.datatransfer.Clipboard;
 import java.awt.datatransfer.DataFlavor;
@@ -427,7 +427,7 @@ public void exportToClipboard(JComponent comp, Clipboard clip, int action) throw
                         @Override public void run(final CompilationController parameter) throws Exception {
                             parameter.toPhase(JavaSource.Phase.RESOLVED);
 
-                            new TreePathScanner<Void, Void>() {
+                            new ErrorAwareTreePathScanner<Void, Void>() {
                                 private final Set<Element> declaredInCopiedText = new HashSet<>();
                                 @Override public Void visitIdentifier(IdentifierTree node, Void p) {
                                     int s = (int) parameter.getTrees().getSourcePositions().getStartPosition(parameter.getCompilationUnit(), node);
diff --git a/java.editor/src/org/netbeans/modules/java/editor/imports/JavaFixAllImports.java b/java.editor/src/org/netbeans/modules/java/editor/imports/JavaFixAllImports.java
index fb8d1422e..469407f91 100644
--- a/java.editor/src/org/netbeans/modules/java/editor/imports/JavaFixAllImports.java
+++ b/java.editor/src/org/netbeans/modules/java/editor/imports/JavaFixAllImports.java
@@ -24,7 +24,7 @@
 import com.sun.source.tree.MemberSelectTree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.awt.Dialog;
 import java.awt.Toolkit;
 import java.awt.event.ActionEvent;
@@ -172,7 +172,7 @@ public void run() {
         return v.getImports();
     }
 
-    private static class ImportVisitor extends TreePathScanner {
+    private static class ImportVisitor extends ErrorAwareTreePathScanner {
         private CompilationInfo info;
         private String currentPackage;
         private List<TreePathHandle> imports;
diff --git a/java.editor/src/org/netbeans/modules/java/editor/rename/InstantRenamePerformer.java b/java.editor/src/org/netbeans/modules/java/editor/rename/InstantRenamePerformer.java
index a201d7bcd..ad00df518 100644
--- a/java.editor/src/org/netbeans/modules/java/editor/rename/InstantRenamePerformer.java
+++ b/java.editor/src/org/netbeans/modules/java/editor/rename/InstantRenamePerformer.java
@@ -24,7 +24,7 @@
 import com.sun.source.tree.StatementTree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 
 import java.awt.Color;
 import java.awt.event.KeyEvent;
@@ -413,7 +413,7 @@ public void run() {
         if (labeledStatement.getLeaf().getKind() == Kind.LABELED_STATEMENT) {
             result.add(org.netbeans.modules.java.editor.base.semantic.Utilities.findIdentifierSpan(info, document, labeledStatement));
             final Name label = ((LabeledStatementTree)labeledStatement.getLeaf()).getLabel();
-            new TreePathScanner <Void, Void>() {
+            new ErrorAwareTreePathScanner <Void, Void>() {
                 @Override
                 public Void visitBreak(BreakTree node, Void p) {
                     if (node.getLabel() != null && label.contentEquals(node.getLabel())) {
diff --git a/java.editor/test/unit/src/org/netbeans/modules/editor/java/GoToSupportTest.java b/java.editor/test/unit/src/org/netbeans/modules/editor/java/GoToSupportTest.java
index 39f46c995..88e61cfef 100644
--- a/java.editor/test/unit/src/org/netbeans/modules/editor/java/GoToSupportTest.java
+++ b/java.editor/test/unit/src/org/netbeans/modules/editor/java/GoToSupportTest.java
@@ -38,12 +38,13 @@
 import org.netbeans.api.java.source.ElementHandle;
 import org.netbeans.api.java.source.JavaSource;
 import org.netbeans.api.java.source.SourceUtilsTestUtil;
+import org.netbeans.api.java.source.SourceUtilsTestUtil2;
 import org.netbeans.api.java.source.Task;
 import org.netbeans.api.java.source.TestUtilities;
 import org.netbeans.api.lexer.Language;
 import org.netbeans.junit.NbTestCase;
 import org.netbeans.modules.editor.java.GoToSupport.UiUtilsCaller;
-import org.netbeans.modules.java.source.TreeLoader;
+//import org.netbeans.modules.java.source.TreeLoader;
 import org.netbeans.modules.java.source.parsing.JavacParser;
 import org.openide.cookies.EditorCookie;
 import org.openide.filesystems.FileObject;
@@ -68,7 +69,7 @@ public GoToSupportTest(String name) {
     protected void setUp() throws Exception {
         SourceUtilsTestUtil.prepareTest(new String[] {"org/netbeans/modules/java/editor/resources/layer.xml"}, new Object[0]);
         org.netbeans.api.project.ui.OpenProjects.getDefault().getOpenProjects();
-        TreeLoader.DISABLE_ARTIFICAL_PARAMETER_NAMES = true;
+        SourceUtilsTestUtil2.disableArtificalParameterNames();
         JavacParser.DISABLE_SOURCE_LEVEL_DOWNGRADE = false;
     }
     
diff --git a/java.editor/test/unit/src/org/netbeans/modules/editor/java/UtilitiesTest.java b/java.editor/test/unit/src/org/netbeans/modules/editor/java/UtilitiesTest.java
index 39d33dff3..1f6c25ee0 100644
--- a/java.editor/test/unit/src/org/netbeans/modules/editor/java/UtilitiesTest.java
+++ b/java.editor/test/unit/src/org/netbeans/modules/editor/java/UtilitiesTest.java
@@ -22,7 +22,7 @@
 import java.util.ArrayList;
 import com.sun.source.tree.MethodInvocationTree;
 import com.sun.source.tree.NewClassTree;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.Arrays;
 import java.util.LinkedList;
 import java.util.List;
@@ -226,7 +226,7 @@ private void performTest(String sourceCode, String... golden) throws Exception {
             public void run(final CompilationController cc) throws Exception {
                 cc.toPhase(Phase.RESOLVED);
                 
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethodInvocation(MethodInvocationTree node, Void p) {
                         if (!cc.getTreeUtilities().isSynthetic(getCurrentPath())) {
diff --git a/java.editor/test/unit/src/org/netbeans/modules/java/editor/codegen/DelegateMethodGeneratorTest.java b/java.editor/test/unit/src/org/netbeans/modules/java/editor/codegen/DelegateMethodGeneratorTest.java
index 0688673b6..a3be1601b 100644
--- a/java.editor/test/unit/src/org/netbeans/modules/java/editor/codegen/DelegateMethodGeneratorTest.java
+++ b/java.editor/test/unit/src/org/netbeans/modules/java/editor/codegen/DelegateMethodGeneratorTest.java
@@ -48,12 +48,12 @@
 import org.netbeans.api.java.source.JavaSource.Phase;
 import org.netbeans.api.java.source.ScanUtils;
 import org.netbeans.api.java.source.SourceUtilsTestUtil;
+import org.netbeans.api.java.source.SourceUtilsTestUtil2;
 import org.netbeans.api.java.source.Task;
 import org.netbeans.api.java.source.TreePathHandle;
 import org.netbeans.api.java.source.WorkingCopy;
 import org.netbeans.junit.NbTestCase;
 import org.netbeans.modules.java.editor.codegen.ui.ElementNode;
-import org.netbeans.modules.java.source.TreeLoader;
 import org.openide.filesystems.FileObject;
 import org.openide.filesystems.FileUtil;
 
@@ -68,7 +68,7 @@ public DelegateMethodGeneratorTest(String testName) {
     }
 
     protected void setUp() throws Exception {
-        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
+        SourceUtilsTestUtil2.disableConfinementTest();
     }
 
     public void testFindUsableFields() throws Exception {
diff --git a/java.editor/test/unit/src/org/netbeans/modules/java/editor/completion/CompletionTestBase.java b/java.editor/test/unit/src/org/netbeans/modules/java/editor/completion/CompletionTestBase.java
index 2b14d5317..6ba97315c 100644
--- a/java.editor/test/unit/src/org/netbeans/modules/java/editor/completion/CompletionTestBase.java
+++ b/java.editor/test/unit/src/org/netbeans/modules/java/editor/completion/CompletionTestBase.java
@@ -51,6 +51,7 @@
 import org.netbeans.api.java.source.ClasspathInfo;
 import org.netbeans.api.java.source.CompilationController;
 import org.netbeans.api.java.source.JavaSource;
+import org.netbeans.api.java.source.SourceUtilsTestUtil2;
 import org.netbeans.api.java.source.Task;
 import org.netbeans.api.java.source.gen.WhitespaceIgnoringDiff;
 import org.netbeans.api.lexer.Language;
@@ -60,7 +61,6 @@
 import org.netbeans.modules.editor.java.JavaCompletionProvider;
 import org.netbeans.modules.editor.java.JavaKit;
 import org.netbeans.modules.java.JavaDataLoader;
-import org.netbeans.modules.java.source.TreeLoader;
 import org.netbeans.modules.java.source.indexing.TransactionContext;
 import org.netbeans.modules.java.source.parsing.JavacParserFactory;
 import org.netbeans.modules.java.source.usages.BinaryAnalyser;
@@ -100,7 +100,7 @@
         System.setProperty("org.openide.util.Lookup", Lkp.class.getName());
         Assert.assertEquals(Lkp.class, Lookup.getDefault().getClass());
 
-        TreeLoader.DISABLE_ARTIFICAL_PARAMETER_NAMES = true;
+        SourceUtilsTestUtil2.disableArtificalParameterNames();
     }
 
     static final int FINISH_OUTTIME = 5 * 60 * 1000;
diff --git a/java.editor/test/unit/src/org/netbeans/modules/java/editor/overridden/IsOverriddenAnnotationCreatorTest.java b/java.editor/test/unit/src/org/netbeans/modules/java/editor/overridden/IsOverriddenAnnotationCreatorTest.java
index 95eab63fa..4b83a2008 100644
--- a/java.editor/test/unit/src/org/netbeans/modules/java/editor/overridden/IsOverriddenAnnotationCreatorTest.java
+++ b/java.editor/test/unit/src/org/netbeans/modules/java/editor/overridden/IsOverriddenAnnotationCreatorTest.java
@@ -32,9 +32,9 @@
 import org.netbeans.api.java.source.JavaSource;
 import org.netbeans.api.java.source.JavaSource.Phase;
 import org.netbeans.api.java.source.SourceUtilsTestUtil;
+import org.netbeans.api.java.source.SourceUtilsTestUtil2;
 import org.netbeans.junit.NbTestCase;
 import org.netbeans.modules.java.source.TestUtil;
-import org.netbeans.modules.java.source.TreeLoader;
 import org.openide.cookies.EditorCookie;
 import org.openide.filesystems.FileObject;
 import org.openide.filesystems.FileUtil;
@@ -120,8 +120,8 @@ public boolean accept(File dir, String name) {
 
         ComputeOverriders.dependenciesOverride = Collections.singletonMap(sourceRoot.getURL(), Collections.<URL>emptyList());
         ComputeOverriders.reverseSourceRootsInOrderOverride = Arrays.asList(sourceRoot.getURL());
-        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
-        TreeLoader.DISABLE_ARTIFICAL_PARAMETER_NAMES = true;
+        SourceUtilsTestUtil2.disableArtificalParameterNames();
+        SourceUtilsTestUtil2.disableConfinementTest();
     }
     
     //does not work as recursive lookup does not work:
diff --git a/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/DeclarativeHintsParser.java b/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/DeclarativeHintsParser.java
index 952a38f7e..ddfe29662 100644
--- a/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/DeclarativeHintsParser.java
+++ b/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/DeclarativeHintsParser.java
@@ -419,13 +419,14 @@ private static ClassPath getJavacApiJarClasspath() {
         if (javacApiJar != null) {
             Logger.getLogger(DeclarativeHintsParser.class.getName()).log(Level.FINE, "javacApiJar={0}", javacApiJar);
             File aj = FileUtil.archiveOrDirForURL(javacApiJar);
-            res = ClassPathSupport.createClassPath(FileUtil.urlForArchiveOrDir(aj));
-            javacApiClasspath = new WeakReference<>(res);
-            return res;
-        } else {
-            javacApiClasspath = NONE;
-            return null;
+            if (aj != null) {
+                res = ClassPathSupport.createClassPath(FileUtil.urlForArchiveOrDir(aj));
+                javacApiClasspath = new WeakReference<>(res);
+                return res;
+            }
         }
+        javacApiClasspath = NONE;
+        return null;
     }
     
     /**
diff --git a/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/conditionapi/Matcher.java b/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/conditionapi/Matcher.java
index 76fa771d2..e48a18f09 100644
--- a/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/conditionapi/Matcher.java
+++ b/java.hints.declarative/src/org/netbeans/modules/java/hints/declarative/conditionapi/Matcher.java
@@ -21,7 +21,7 @@
 
 import com.sun.source.tree.Tree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.Collection;
 import java.util.LinkedList;
 import javax.lang.model.element.Element;
@@ -69,7 +69,7 @@ public boolean containsAny(@NonNull Variable var, @NonNull final String /*of @No
 
         for (TreePath toSearch : paths) {
             //XXX:
-            new TreePathScanner<Void, Void>() {
+            new ErrorAwareTreePathScanner<Void, Void>() {
                 @Override
                 public Void scan(Tree tree, Void p) {
                     if (tree == null) return null;
@@ -98,7 +98,7 @@ public boolean referencedIn(@NonNull Variable variable, @NonNull Variable in) {
         }
 
         for (TreePath tp : ctx.getVariable(in)) {
-            boolean occurs = new TreePathScanner<Boolean, Void>() {
+            boolean occurs = new ErrorAwareTreePathScanner<Boolean, Void>() {
                 @Override
                 public Boolean scan(Tree tree, Void p) {
                     if (tree == null) {
diff --git a/java.hints.declarative/test/unit/src/org/netbeans/modules/java/hints/declarative/debugging/EvaluationSpanTaskTest.java b/java.hints.declarative/test/unit/src/org/netbeans/modules/java/hints/declarative/debugging/EvaluationSpanTaskTest.java
index 58828cb07..aa3fe7d62 100644
--- a/java.hints.declarative/test/unit/src/org/netbeans/modules/java/hints/declarative/debugging/EvaluationSpanTaskTest.java
+++ b/java.hints.declarative/test/unit/src/org/netbeans/modules/java/hints/declarative/debugging/EvaluationSpanTaskTest.java
@@ -34,10 +34,10 @@
 import org.netbeans.api.java.source.JavaSource;
 import org.netbeans.api.java.source.JavaSource.Phase;
 import org.netbeans.api.java.source.SourceUtilsTestUtil;
+import org.netbeans.api.java.source.SourceUtilsTestUtil2;
 import org.netbeans.api.java.source.TestUtilities;
 import org.netbeans.api.lexer.Language;
 import org.netbeans.junit.NbTestCase;
-import org.netbeans.modules.java.source.TreeLoader;
 import org.openide.cookies.EditorCookie;
 import org.openide.filesystems.FileObject;
 import org.openide.filesystems.FileUtil;
@@ -57,7 +57,7 @@ public EvaluationSpanTaskTest(String name) {
     protected void setUp() throws Exception {
         super.setUp();
         SourceUtilsTestUtil.prepareTest(new String[] {"org/netbeans/modules/java/editor/resources/layer.xml"}, new Object[0]);
-        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
+        SourceUtilsTestUtil2.disableConfinementTest();
     }
 
     public void testHintConditions() throws Exception {
diff --git a/java.hints.test/src/org/netbeans/modules/java/hints/test/api/HintTest.java b/java.hints.test/src/org/netbeans/modules/java/hints/test/api/HintTest.java
index f66669b8c..202f5489a 100644
--- a/java.hints.test/src/org/netbeans/modules/java/hints/test/api/HintTest.java
+++ b/java.hints.test/src/org/netbeans/modules/java/hints/test/api/HintTest.java
@@ -99,7 +99,6 @@
 import org.netbeans.modules.java.hints.spiimpl.options.HintsSettings;
 import org.netbeans.modules.java.hints.test.Utilities.TestLookup;
 import org.netbeans.modules.java.source.JavaSourceAccessor;
-import org.netbeans.modules.java.source.TreeLoader;
 import org.netbeans.modules.parsing.api.indexing.IndexingManager;
 import org.netbeans.modules.parsing.impl.indexing.CacheFolder;
 import org.netbeans.modules.parsing.impl.indexing.MimeTypes;
@@ -224,7 +223,6 @@ private HintTest() throws Exception {
         MimeTypes.setAllMimeTypes(amt);
         org.netbeans.api.project.ui.OpenProjects.getDefault().getOpenProjects();
 
-        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
         testPreferences = new TempPreferences();
         hintSettings = new HintsSettings() {
             @Override public boolean isEnabled(HintMetadata hint) {
diff --git a/java.hints.ui/nbproject/project.properties b/java.hints.ui/nbproject/project.properties
index 59289f0dd..84013ec78 100644
--- a/java.hints.ui/nbproject/project.properties
+++ b/java.hints.ui/nbproject/project.properties
@@ -17,3 +17,4 @@
 javac.source=1.7
 javac.compilerargs=-Xlint -Xlint:-serial
 spec.version.base=1.19.0
+requires.nb.javac=true
diff --git a/java.hints/src/org/netbeans/modules/java/hints/ArithmeticUtilities.java b/java.hints/src/org/netbeans/modules/java/hints/ArithmeticUtilities.java
index d6f16f7b2..e9bb4e27e 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/ArithmeticUtilities.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/ArithmeticUtilities.java
@@ -34,7 +34,7 @@
 import com.sun.source.tree.UnaryTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.EnumSet;
 import java.util.HashMap;
 import java.util.Map;
@@ -194,7 +194,7 @@ public static Object compute(CompilationInfo info, TreePath tp, boolean resolveC
         
     }
 
-    private static final class VisitorImpl extends TreePathScanner<Object, Void> {
+    private static final class VisitorImpl extends ErrorAwareTreePathScanner<Object, Void> {
         // PENDING: instanceof String could be handled
 	private static final Set<Kind> ACCEPTED_KINDS = EnumSet.of(
 		MULTIPLY, DIVIDE, REMAINDER, PLUS, MINUS,
diff --git a/java.hints/src/org/netbeans/modules/java/hints/AssignmentIssues.java b/java.hints/src/org/netbeans/modules/java/hints/AssignmentIssues.java
index 9ad0faa6a..96953a3e5 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/AssignmentIssues.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/AssignmentIssues.java
@@ -26,7 +26,7 @@
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.UnaryTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.util.ArrayList;
 import java.util.LinkedList;
@@ -169,7 +169,7 @@ public static ErrorDescription replaceAssignWithOpAssign(HintContext context) {
                 new ReplaceAssignmentFix(NbBundle.getMessage(AssignmentIssues.class, "FIX_ReplaceAssignmentWithOperatorAssignment", path.getLeaf()), TreePathHandle.create(path, context.getInfo())).toEditorFix()); //NOI18N
     }
 
-    private static final class AssignmentFinder extends TreePathScanner<Void, List<TreePath>> {
+    private static final class AssignmentFinder extends ErrorAwareTreePathScanner<Void, List<TreePath>> {
 
         private final Trees trees;
         private final Element param;
diff --git a/java.hints/src/org/netbeans/modules/java/hints/ConvertAnonymousToInner.java b/java.hints/src/org/netbeans/modules/java/hints/ConvertAnonymousToInner.java
index 5fd109c34..264fa790e 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/ConvertAnonymousToInner.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/ConvertAnonymousToInner.java
@@ -33,7 +33,7 @@
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -233,7 +233,7 @@ public void run(WorkingCopy parameter) throws Exception {
         }
     }
 
-    private static final class DetectUsedVars extends TreePathScanner<Void, Set<VariableElement>> {
+    private static final class DetectUsedVars extends ErrorAwareTreePathScanner<Void, Set<VariableElement>> {
         private CompilationInfo info;
         private TreePath newClassToConvert;
         
@@ -258,7 +258,7 @@ public Void visitIdentifier(IdentifierTree node, Set<VariableElement> p) {
 
     }
     
-    private static final class DetectUseOfNonStaticMembers extends TreePathScanner<Boolean, Void> {
+    private static final class DetectUseOfNonStaticMembers extends ErrorAwareTreePathScanner<Boolean, Void> {
         private CompilationInfo info;
         private TreePath newClassToConvert;
         
@@ -546,7 +546,7 @@ public void cancel() {
     }
 
     private static TreePath findSuperConstructorCall(final CompilationInfo info, TreePath nct) {
-        class FindSuperConstructorCall extends TreePathScanner<TreePath, Void> {
+        class FindSuperConstructorCall extends ErrorAwareTreePathScanner<TreePath, Void> {
 
             private boolean stop;
 
diff --git a/java.hints/src/org/netbeans/modules/java/hints/DoubleCheck.java b/java.hints/src/org/netbeans/modules/java/hints/DoubleCheck.java
index da4d33d7d..a805ffc62 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/DoubleCheck.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/DoubleCheck.java
@@ -34,7 +34,7 @@
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -393,7 +393,7 @@ protected void performRewrite(TransformationContext ctx) throws Exception {
         }
     }
     
-    private static final class VariableAccessWalker extends TreePathScanner {
+    private static final class VariableAccessWalker extends ErrorAwareTreePathScanner {
         private final VariableElement originalVariable;
         private final ExpressionTree  fieldAccessTree;
         /**
diff --git a/java.hints/src/org/netbeans/modules/java/hints/EqualsMethodHint.java b/java.hints/src/org/netbeans/modules/java/hints/EqualsMethodHint.java
index 52aee3c73..7570e771d 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/EqualsMethodHint.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/EqualsMethodHint.java
@@ -25,7 +25,7 @@
 import com.sun.source.tree.MethodInvocationTree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ElementKind;
 import org.netbeans.api.java.source.CompilationInfo;
@@ -69,7 +69,7 @@ public static ErrorDescription run(HintContext ctx) {
                 NbBundle.getMessage(EqualsMethodHint.class, "ERR_EQUALS_NOT_CHECKING_TYPE"));
     }
 
-    private static final class VisitorImpl extends TreePathScanner<Void, Void> {
+    private static final class VisitorImpl extends ErrorAwareTreePathScanner<Void, Void> {
         
         private CompilationInfo info;
         private Element parameter;
diff --git a/java.hints/src/org/netbeans/modules/java/hints/OrganizeImports.java b/java.hints/src/org/netbeans/modules/java/hints/OrganizeImports.java
index 52385cc43..17e17caff 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/OrganizeImports.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/OrganizeImports.java
@@ -46,7 +46,7 @@
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import com.sun.tools.javac.code.Scope;
 import com.sun.tools.javac.code.Symbol;
@@ -232,7 +232,7 @@ public int compare(ImportTree o1, ImportTree o2) {
         final Set<Element> ret = new HashSet<Element>();
         final Trees trees = info.getTrees();
         final Types types = info.getTypes();
-        new TreePathScanner<Void, Void>() {
+        new ErrorAwareTreePathScanner<Void, Void>() {
 
             @Override
             public Void visitIdentifier(IdentifierTree node, Void p) {
diff --git a/java.hints/src/org/netbeans/modules/java/hints/WrongPackageSuggestion.java b/java.hints/src/org/netbeans/modules/java/hints/WrongPackageSuggestion.java
index 6b6c37611..9bfd6a534 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/WrongPackageSuggestion.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/WrongPackageSuggestion.java
@@ -25,7 +25,7 @@
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.File;
 import java.io.IOException;
 import java.util.Arrays;
@@ -93,7 +93,7 @@ public WrongPackageSuggestion() {
         boolean hasPackageClause = tree.getPackageName() != null;
         
         if (hasPackageClause) {
-            new TreeScanner<Void, StringBuffer>() {
+            new ErrorAwareTreeScanner<Void, StringBuffer>() {
                 @Override
                 public Void visitIdentifier(IdentifierTree node, StringBuffer p) {
                     p.append(node.getName().toString());
diff --git a/java.hints/src/org/netbeans/modules/java/hints/bugs/AssertWithSideEffects.java b/java.hints/src/org/netbeans/modules/java/hints/bugs/AssertWithSideEffects.java
index 51201a713..701ce0c02 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/bugs/AssertWithSideEffects.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/bugs/AssertWithSideEffects.java
@@ -20,22 +20,8 @@
 
 import org.netbeans.modules.java.hints.SideEffectVisitor;
 import com.sun.source.tree.AssertTree;
-import com.sun.source.tree.AssignmentTree;
-import com.sun.source.tree.ClassTree;
-import com.sun.source.tree.CompoundAssignmentTree;
-import com.sun.source.tree.LambdaExpressionTree;
-import com.sun.source.tree.MethodInvocationTree;
-import com.sun.source.tree.NewClassTree;
 import com.sun.source.tree.Tree;
-import com.sun.source.tree.UnaryTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import java.util.Deque;
-import java.util.LinkedList;
-import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
-import javax.lang.model.element.ExecutableElement;
-import javax.lang.model.element.TypeElement;
 import org.netbeans.api.java.source.CompilationInfo;
 import org.netbeans.modules.java.hints.StopProcessing;
 import org.netbeans.spi.editor.hints.ErrorDescription;
diff --git a/java.hints/src/org/netbeans/modules/java/hints/bugs/CloneAndCloneable.java b/java.hints/src/org/netbeans/modules/java/hints/bugs/CloneAndCloneable.java
index 627975424..48dec22dd 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/bugs/CloneAndCloneable.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/bugs/CloneAndCloneable.java
@@ -26,7 +26,7 @@
 import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.Collections;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ExecutableElement;
@@ -93,7 +93,7 @@ public static ErrorDescription cloneWithoutSuperClone(HintContext ctx) {
      * Finder provides true, if it finds a call to 'superClone' method element passed
      * in the constructor.
      */
-    private static final class SuperCloneFinder extends TreePathScanner<Boolean, Void> {
+    private static final class SuperCloneFinder extends ErrorAwareTreePathScanner<Boolean, Void> {
         private final CompilationInfo info;
         private final ExecutableElement superClone;
 
diff --git a/java.hints/src/org/netbeans/modules/java/hints/bugs/ComparatorParameterNotUsed.java b/java.hints/src/org/netbeans/modules/java/hints/bugs/ComparatorParameterNotUsed.java
index fc7e10395..374e6838e 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/bugs/ComparatorParameterNotUsed.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/bugs/ComparatorParameterNotUsed.java
@@ -23,7 +23,7 @@
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.text.Collator;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -58,7 +58,7 @@
     "# {0} - parameter name",
     "TEXT_ComparatorParameterNotUsed=Comparator.comparable does not use parameter ''{0}''"
 })
-public class ComparatorParameterNotUsed extends TreePathScanner {
+public class ComparatorParameterNotUsed extends ErrorAwareTreePathScanner {
     private final CompilationInfo   ci;
     private final Set<VariableElement>    unusedVars;
 
diff --git a/java.hints/src/org/netbeans/modules/java/hints/bugs/InfiniteRecursion.java b/java.hints/src/org/netbeans/modules/java/hints/bugs/InfiniteRecursion.java
index a542e8758..aac9f03dc 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/bugs/InfiniteRecursion.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/bugs/InfiniteRecursion.java
@@ -41,7 +41,7 @@
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.Collections;
 import java.util.Deque;
 import java.util.EnumSet;
@@ -224,7 +224,7 @@ public State append(State other) {
      * only in the speculative for loop evaluation, otherwise for/while bodies incl any continue statements do not count.
      * 
      */
-    private static class RecursionVisitor extends TreePathScanner<State, Void> {
+    private static class RecursionVisitor extends ErrorAwareTreePathScanner<State, Void> {
         private final CompilationInfo ci;
         private final ExecutableElement checkMethod;
 
diff --git a/java.hints/src/org/netbeans/modules/java/hints/bugs/Regexp.java b/java.hints/src/org/netbeans/modules/java/hints/bugs/Regexp.java
index 99b35a721..4be2cd913 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/bugs/Regexp.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/bugs/Regexp.java
@@ -26,7 +26,7 @@
 import com.sun.source.tree.MethodInvocationTree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
 import javax.lang.model.element.Element;
@@ -97,7 +97,7 @@ public static ErrorDescription hint(final HintContext ctx) {
         final StringBuilder regexp = new StringBuilder();
         final boolean[] accept = {true};
         TreePath pattern = ctx.getVariables().get("$pattern");
-        new TreePathScanner<Void, Void>() {
+        new ErrorAwareTreePathScanner<Void, Void>() {
             @Override
             public Void visitLiteral(LiteralTree node, Void p) {
                 if (node.getValue() instanceof String) {
diff --git a/java.hints/src/org/netbeans/modules/java/hints/bugs/Tiny.java b/java.hints/src/org/netbeans/modules/java/hints/bugs/Tiny.java
index 35b8df906..fcd1eb270 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/bugs/Tiny.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/bugs/Tiny.java
@@ -37,8 +37,8 @@
 import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -342,7 +342,7 @@ public static ErrorDescription switchCaseLabelMismatch(HintContext ctx) {
         final LabeledStatementTree lt = (LabeledStatementTree)lPath.getLeaf();
         final Name l = lt.getLabel();
         final CompilationInfo info = ctx.getInfo();
-        Boolean b = new TreePathScanner<Boolean, Void>() {
+        Boolean b = new ErrorAwareTreePathScanner<Boolean, Void>() {
 
             @Override
             public Boolean reduce(Boolean r1, Boolean r2) {
diff --git a/java.hints/src/org/netbeans/modules/java/hints/bugs/TryCatchFinally.java b/java.hints/src/org/netbeans/modules/java/hints/bugs/TryCatchFinally.java
index ebbdd1c45..f5a7f080a 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/bugs/TryCatchFinally.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/bugs/TryCatchFinally.java
@@ -28,7 +28,7 @@
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.TryTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.ArrayDeque;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -226,7 +226,7 @@
         return errs;
     }
     
-    private static final class ExitsFromBranches extends TreePathScanner<Void, Collection<TreePath>> {
+    private static final class ExitsFromBranches extends ErrorAwareTreePathScanner<Void, Collection<TreePath>> {
         private final  boolean analyzeThrows;
         private final CompilationInfo info;
         private final Set<Tree> seenTrees = new HashSet<Tree>();
diff --git a/java.hints/src/org/netbeans/modules/java/hints/control/RemoveUnnecessary.java b/java.hints/src/org/netbeans/modules/java/hints/control/RemoveUnnecessary.java
index d985d23b6..ce4df37b6 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/control/RemoveUnnecessary.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/control/RemoveUnnecessary.java
@@ -44,7 +44,7 @@
 import com.sun.source.tree.TypeCastTree;
 import com.sun.source.tree.UnaryTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.ArrayList;
 import java.util.EnumSet;
 import java.util.List;
@@ -260,7 +260,7 @@ protected void performRewrite(TransformationContext ctx) throws Exception {
      * Transforms expression tree into series of statements.
      * 
      */
-    static class ExpressionToStatement extends TreePathScanner {
+    static class ExpressionToStatement extends ErrorAwareTreePathScanner {
         private boolean remove = true;
         private List<StatementTree>    statements = new ArrayList<>(); 
         private final TreeMaker mk;
diff --git a/java.hints/src/org/netbeans/modules/java/hints/errors/AddParameterOrLocalFix.java b/java.hints/src/org/netbeans/modules/java/hints/errors/AddParameterOrLocalFix.java
index 1c23bca7e..a6b59f011 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/errors/AddParameterOrLocalFix.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/errors/AddParameterOrLocalFix.java
@@ -30,7 +30,7 @@
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.util.Arrays;
 import java.util.EnumSet;
@@ -264,7 +264,7 @@ private void resolveLocalVariable(final WorkingCopy wc, TreePath tp, TreeMaker m
             return;
         }
         
-        class FirstUsage extends TreePathScanner<TreePath, Void> {
+        class FirstUsage extends ErrorAwareTreePathScanner<TreePath, Void> {
             public @Override TreePath visitIdentifier(IdentifierTree tree, Void v) {
                 if (tree.getName().contentEquals(el.getSimpleName()) && isError(wc, wc.getTrees().getElement(getCurrentPath()))) {
                     return findStatement(getCurrentPath());
diff --git a/java.hints/src/org/netbeans/modules/java/hints/errors/ImplementAllAbstractMethods.java b/java.hints/src/org/netbeans/modules/java/hints/errors/ImplementAllAbstractMethods.java
index a32d2702a..ae300a1f3 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/errors/ImplementAllAbstractMethods.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/errors/ImplementAllAbstractMethods.java
@@ -29,7 +29,7 @@
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -198,7 +198,7 @@ public String createMessage(CompilationInfo info, Diagnostic diag, int offset, T
             //(missing '()' for constructor)
             //do not propose the hint in this case:
             final boolean[] parentError = new boolean[] {false};
-            new TreePathScanner() {
+            new ErrorAwareTreePathScanner() {
                 @Override
                 public Object visitNewClass(NewClassTree nct, Object o) {
                     if (leaf == nct) {
diff --git a/java.hints/src/org/netbeans/modules/java/hints/errors/MagicSurroundWithTryCatchFix.java b/java.hints/src/org/netbeans/modules/java/hints/errors/MagicSurroundWithTryCatchFix.java
index f5a4082bb..c5de429a0 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/errors/MagicSurroundWithTryCatchFix.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/errors/MagicSurroundWithTryCatchFix.java
@@ -34,7 +34,7 @@
 import com.sun.source.tree.TryTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -187,7 +187,7 @@ static TreePath enclosingTry(TreePath from) {
         return null;
     }
     
-    private final class TransformerImpl extends TreePathScanner<Void, Void> {
+    private final class TransformerImpl extends ErrorAwareTreePathScanner<Void, Void> {
         
         private WorkingCopy info;
         private List<TypeMirrorHandle> thandles;
diff --git a/java.hints/src/org/netbeans/modules/java/hints/errors/MissingReturnStatement.java b/java.hints/src/org/netbeans/modules/java/hints/errors/MissingReturnStatement.java
index 3ec5ac2f2..401c9484a 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/errors/MissingReturnStatement.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/errors/MissingReturnStatement.java
@@ -23,12 +23,9 @@
 import com.sun.source.tree.LambdaExpressionTree;
 import com.sun.source.tree.LiteralTree;
 import com.sun.source.tree.MethodTree;
-import com.sun.source.tree.ReturnTree;
 import com.sun.source.tree.StatementTree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
-import com.sun.tools.javac.tree.JCTree;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
diff --git a/java.hints/src/org/netbeans/modules/java/hints/errors/OrigSurroundWithTryCatchFix.java b/java.hints/src/org/netbeans/modules/java/hints/errors/OrigSurroundWithTryCatchFix.java
index e24015b29..62140af3a 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/errors/OrigSurroundWithTryCatchFix.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/errors/OrigSurroundWithTryCatchFix.java
@@ -29,7 +29,7 @@
 import com.sun.source.tree.TryTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.LinkedList;
@@ -171,7 +171,7 @@ private TreePath findBlockOrCase(TreePath path) {
         return path;
     }
     
-    private static final class FindUsages extends TreePathScanner<Boolean, VariableElement> {
+    private static final class FindUsages extends ErrorAwareTreePathScanner<Boolean, VariableElement> {
 
         private Tree ignore;
         private CompilationInfo info;
diff --git a/java.hints/src/org/netbeans/modules/java/hints/errors/Utilities.java b/java.hints/src/org/netbeans/modules/java/hints/errors/Utilities.java
index aa70fa3fd..4fb6e5f81 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/errors/Utilities.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/errors/Utilities.java
@@ -30,7 +30,7 @@
 import com.sun.source.tree.IfTree;
 import com.sun.source.tree.ReturnTree;
 import com.sun.source.tree.TryTree;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import org.netbeans.api.java.source.TreeUtilities;
 import org.openide.filesystems.FileUtil;
 import org.openide.util.NbBundle;
@@ -72,7 +72,7 @@
 import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -841,7 +841,7 @@ public static String shortDisplayName(CompilationInfo info, ExpressionTree expre
     @NbBundle.Messages({
         "DisplayName_Unknown=<missing>"
     })
-    private static class HintDisplayNameVisitor extends TreeScanner<String, Void> {
+    private static class HintDisplayNameVisitor extends ErrorAwareTreeScanner<String, Void> {
 
         private CompilationInfo info;
 
@@ -1234,7 +1234,7 @@ public static boolean exitsFromAllBranchers(CompilationInfo info, TreePath from)
      * {@link #seenTrees} before processing, so if a break/continue targets such a node, such jump is not considered an exit.
      * Jumps can register the target Tree in {@link #targetTrees} which causes false to be returned from that tree's inspection.
      */
-    private static final class ExitsFromAllBranches extends TreePathScanner<Boolean, Void> {
+    private static final class ExitsFromAllBranches extends ErrorAwareTreePathScanner<Boolean, Void> {
 
         private CompilationInfo info;
         private final Set<Tree> seenTrees = new HashSet<Tree>();
@@ -1856,10 +1856,10 @@ public void report(JCDiagnostic diag) {
                 }
             }            
         };
-        ArgumentAttr argumentAttr = ArgumentAttr.instance(jti.getContext());
-        ArgumentAttr.LocalCacheContext cacheContext = argumentAttr.withLocalCacheContext();
+//        ArgumentAttr argumentAttr = ArgumentAttr.instance(jti.getContext());
+//        ArgumentAttr.LocalCacheContext cacheContext = argumentAttr.withLocalCacheContext();
         try {
-            enter.shadowTypeEnvs(true);
+//            enter.shadowTypeEnvs(true);
             Attr attr = Attr.instance(jti.getContext());
             Env<AttrContext> env = ((JavacScope) scope).getEnv();
             if (tree instanceof JCTree.JCExpression) {
@@ -1867,10 +1867,10 @@ public void report(JCDiagnostic diag) {
             }
             return attr.attribStat((JCTree) tree,env);
         } finally {
-            cacheContext.leave();
+//            cacheContext.leave();
             log.useSource(prev);
             log.popDiagnosticHandler(discardHandler);
-            enter.shadowTypeEnvs(false);
+//            enter.shadowTypeEnvs(false);
         }
     }
     // -------------------------------------------------------------------------------------
diff --git a/java.hints/src/org/netbeans/modules/java/hints/finalize/FinalizeDoesNotCallSuper.java b/java.hints/src/org/netbeans/modules/java/hints/finalize/FinalizeDoesNotCallSuper.java
index cb67b98bf..aedce5263 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/finalize/FinalizeDoesNotCallSuper.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/finalize/FinalizeDoesNotCallSuper.java
@@ -32,7 +32,7 @@
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.TryTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -77,7 +77,7 @@ public static ErrorDescription hint(final HintContext ctx) {
                 new FixImpl(TreePathHandle.create(ctx.getPath(), ctx.getInfo())).toEditorFix());
     }
 
-    static final class FindSuper extends TreeScanner<Void, Void> {
+    static final class FindSuper extends ErrorAwareTreeScanner<Void, Void> {
 
         boolean found;
 
diff --git a/java.hints/src/org/netbeans/modules/java/hints/introduce/Flow.java b/java.hints/src/org/netbeans/modules/java/hints/introduce/Flow.java
index 232613431..f1ddde1df 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/introduce/Flow.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/introduce/Flow.java
@@ -73,7 +73,7 @@
 import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.tree.WildcardTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -243,7 +243,7 @@ private void computeDataFlow() {
 
     }
     
-    private static class PathFinder extends TreePathScanner {
+    private static class PathFinder extends ErrorAwareTreePathScanner {
         final Map<Tree, TreePath> node2Path;
         final Set<Tree> interestingNodes;
 
diff --git a/java.hints/src/org/netbeans/modules/java/hints/introduce/InstanceRefFinder.java b/java.hints/src/org/netbeans/modules/java/hints/introduce/InstanceRefFinder.java
index d8be83df8..d13b38577 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/introduce/InstanceRefFinder.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/introduce/InstanceRefFinder.java
@@ -25,7 +25,7 @@
 import com.sun.source.tree.NewClassTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.Collections;
 import java.util.HashSet;
 import java.util.Set;
@@ -47,7 +47,7 @@
  *
  * @author sdedic
  */
-public class InstanceRefFinder extends TreePathScanner {
+public class InstanceRefFinder extends ErrorAwareTreePathScanner {
     /**
      * The initial path for analysis
      */
diff --git a/java.hints/src/org/netbeans/modules/java/hints/introduce/IntroduceHint.java b/java.hints/src/org/netbeans/modules/java/hints/introduce/IntroduceHint.java
index 6eaa1285f..7d2a20920 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/introduce/IntroduceHint.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/introduce/IntroduceHint.java
@@ -35,8 +35,8 @@
 import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.awt.Color;
 import java.awt.Rectangle;
 import java.util.ArrayList;
@@ -441,7 +441,7 @@ public synchronized Throwable fillInStackTrace() {
             }
 
         }
-        class ReferencesLocalVariable extends TreePathScanner<Void, Void> {
+        class ReferencesLocalVariable extends ErrorAwareTreePathScanner<Void, Void> {
             @Override
             public Void visitIdentifier(IdentifierTree node, Void p) {
                 Element e = info.getTrees().getElement(getCurrentPath());
@@ -550,7 +550,7 @@ public Void visitIdentifier(IdentifierTree node, Void p) {
         return formalArguments;
     }
     
-    static class VariableRenamer extends TreePathScanner {
+    static class VariableRenamer extends ErrorAwareTreePathScanner {
         private final Map<VariableElement, CharSequence> renamedVars;
         private final Set<Name> changedNames;
         private final WorkingCopy info;
@@ -750,7 +750,7 @@ static TreePath findTargetClassWithDuplicates(TreePath pathToClass, Collection<T
     static ClassTree insertField(final WorkingCopy parameter, ClassTree clazz, VariableTree fieldToAdd, Set<Tree> allNewUses, int offset) {
         ClassTree nueClass = INSERT_CLASS_MEMBER.insertClassMember(parameter, clazz, fieldToAdd, offset);
 
-        class Contains extends TreeScanner<Boolean, Set<Tree>> {
+        class Contains extends ErrorAwareTreeScanner<Boolean, Set<Tree>> {
             @Override public Boolean reduce(Boolean r1, Boolean r2) {
                 return r1 == Boolean.TRUE || r2 == Boolean.TRUE;
             }
@@ -809,7 +809,7 @@ static ClassTree insertField(final WorkingCopy parameter, ClassTree clazz, Varia
         final Set<Element> used = Collections.newSetFromMap(new IdentityHashMap<Element, Boolean>());
         final boolean statik = fieldToAdd.getModifiers().getFlags().contains(Modifier.STATIC);
         
-        new TreePathScanner<Void, Void>() {
+        new ErrorAwareTreePathScanner<Void, Void>() {
             @Override public Void visitIdentifier(IdentifierTree node, Void p) {
                 handleCurrentPath();
                 return super.visitIdentifier(node, p); //To change body of generated methods, choose Tools | Templates.
diff --git a/java.hints/src/org/netbeans/modules/java/hints/introduce/ReferenceTransformer.java b/java.hints/src/org/netbeans/modules/java/hints/introduce/ReferenceTransformer.java
index 0496c88e1..c02c92bc9 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/introduce/ReferenceTransformer.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/introduce/ReferenceTransformer.java
@@ -22,7 +22,7 @@
 import com.sun.source.tree.MemberSelectTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ElementKind;
 import javax.lang.model.element.Modifier;
@@ -35,7 +35,7 @@
  *
  * @author sdedic
  */
-final class ReferenceTransformer extends TreePathScanner {
+final class ReferenceTransformer extends ErrorAwareTreePathScanner {
     private final ElementKind kind;
     private final String name;
     private final WorkingCopy copy;
diff --git a/java.hints/src/org/netbeans/modules/java/hints/introduce/ScanStatement.java b/java.hints/src/org/netbeans/modules/java/hints/introduce/ScanStatement.java
index 393c14eef..bb5c758d4 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/introduce/ScanStatement.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/introduce/ScanStatement.java
@@ -32,7 +32,7 @@
 import com.sun.source.tree.VariableTree;
 import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
@@ -53,7 +53,7 @@
  *
  * @author sdedic
  */
-final class ScanStatement extends TreePathScanner<Void, Void> {
+final class ScanStatement extends ErrorAwareTreePathScanner<Void, Void> {
     private static final int PHASE_BEFORE_SELECTION = 1;
     private static final int PHASE_INSIDE_SELECTION = 2;
     private static final int PHASE_AFTER_SELECTION = 3;
diff --git a/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToARM.java b/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToARM.java
index 1e3e1c667..37a1dfc3d 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToARM.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToARM.java
@@ -32,8 +32,8 @@
 import com.sun.source.tree.TryTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -841,7 +841,7 @@ private static boolean insideARM(final HintContext ctx) {
             }
         }
         final Set<VariableTree> result = new HashSet<VariableTree>();
-        final TreeScanner<Void,Void> scanner = new TreeScanner<Void,Void>(){
+        final ErrorAwareTreeScanner<Void,Void> scanner = new ErrorAwareTreeScanner<Void,Void>(){
             @Override
             public Void visitIdentifier(IdentifierTree node, Void p) {
                 final Element elm = trees.getElement(trees.getPath(cu, node));
@@ -863,7 +863,7 @@ public Void visitIdentifier(IdentifierTree node, Void p) {
             final Trees trees) {
         final List<TreePath> usages = new LinkedList<>();
         if (statements != null) {
-            final TreePathScanner<List<TreePath>,List<TreePath>> scanner = new TreePathScanner<List<TreePath>, List<TreePath>>() {
+            final ErrorAwareTreePathScanner<List<TreePath>,List<TreePath>> scanner = new ErrorAwareTreePathScanner<List<TreePath>, List<TreePath>>() {
                 @Override
                 public List<TreePath> visitIdentifier(IdentifierTree node, List<TreePath> p) {
                     final TreePath path = getCurrentPath();
@@ -910,7 +910,7 @@ private static boolean isAssigned(
             final Element what,
             final Iterable<? extends TreePath> where,
             final Trees trees) {
-        TreePathScanner<Boolean, Void> scanner = new TreePathScanner<Boolean, Void>() {
+        ErrorAwareTreePathScanner<Boolean, Void> scanner = new ErrorAwareTreePathScanner<Boolean, Void>() {
             @Override public Boolean visitAssignment(AssignmentTree node, Void p) {
                 if (trees.getElement(new TreePath(getCurrentPath(), node.getVariable())) == what) {
                     return true;
@@ -955,7 +955,7 @@ private static boolean splitVariablesClash(
             usedAfterCloseVarNames.add(vt.getName().toString());
         }
         
-        TreeScanner<Boolean, Void> scanner = new TreeScanner<Boolean, Void>() {
+        ErrorAwareTreeScanner<Boolean, Void> scanner = new ErrorAwareTreeScanner<Boolean, Void>() {
             @Override public Boolean visitVariable(VariableTree node, Void p) {
                 if (usedAfterCloseVarNames.contains(node.getName().toString()) && !usedAfterCloseVarDecls.contains(node)) {
                     return true;
diff --git a/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToLambdaConverter.java b/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToLambdaConverter.java
index 54e494b28..ee53aca15 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToLambdaConverter.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToLambdaConverter.java
@@ -32,7 +32,7 @@
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.util.Collection;
 import java.util.Collections;
@@ -223,7 +223,7 @@ private ExpressionTree getTreeWithCastPrepended(ExpressionTree tree, Tree expect
         return make.TypeCast(expectedType, tree);
     }
 
-    private class ShadowedVariableRenameScanner extends TreePathScanner<Tree, Trees> {
+    private class ShadowedVariableRenameScanner extends ErrorAwareTreePathScanner<Tree, Trees> {
 
         private final Map<Element, CharSequence> originalToNewName = new HashMap<Element, CharSequence>();
 
diff --git a/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToLambdaPreconditionChecker.java b/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToLambdaPreconditionChecker.java
index f360d5e71..cb158c1a7 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToLambdaPreconditionChecker.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/jdk/ConvertToLambdaPreconditionChecker.java
@@ -34,7 +34,7 @@
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.util.ArrayList;
 import java.util.EnumSet;
@@ -235,7 +235,7 @@ private void checkForOverload() {
         foundOverloadWhichMakesLambdaAmbiguous = doesOverloadMakeLambdaAmbiguous();
     }
 
-    private class PreconditionScanner extends TreePathScanner<Tree, Trees> {
+    private class PreconditionScanner extends ErrorAwareTreePathScanner<Tree, Trees> {
 
         @Override
         public Tree visitClass(ClassTree node, Trees p) {
diff --git a/java.hints/src/org/netbeans/modules/java/hints/jdk/IteratorToFor.java b/java.hints/src/org/netbeans/modules/java/hints/jdk/IteratorToFor.java
index 486097a75..f8d2c6b7d 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/jdk/IteratorToFor.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/jdk/IteratorToFor.java
@@ -35,7 +35,7 @@
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.EnumSet;
@@ -269,7 +269,7 @@ private static boolean uses(final HintContext ctx, Collection<? extends TreePath
             return false;
         }
         for (TreePath tp : statements) {
-            boolean occurs = Boolean.TRUE.equals(new TreePathScanner<Boolean, Void>() {
+            boolean occurs = Boolean.TRUE.equals(new ErrorAwareTreePathScanner<Boolean, Void>() {
                 @Override public Boolean scan(Tree tree, Void p) {
                     if (tree == null) {
                         return false;
diff --git a/java.hints/src/org/netbeans/modules/java/hints/jdk/UseSpecificCatch.java b/java.hints/src/org/netbeans/modules/java/hints/jdk/UseSpecificCatch.java
index 161dfb844..a4c03d0e9 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/jdk/UseSpecificCatch.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/jdk/UseSpecificCatch.java
@@ -25,7 +25,7 @@
 import com.sun.source.tree.TryTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.ArrayDeque;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -262,7 +262,7 @@ public static boolean assignsTo(final HintContext ctx, TreePath variable, Iterab
         final boolean[] result = new boolean[1];
 
         for (TreePath tp : statements) {
-            new TreePathScanner<Void, Void>() {
+            new ErrorAwareTreePathScanner<Void, Void>() {
                 @Override
                 public Void visitAssignment(AssignmentTree node, Void p) {
                     if (tEl.equals(ctx.getInfo().getTrees().getElement(new TreePath(getCurrentPath(), node.getVariable())))) {
diff --git a/java.hints/src/org/netbeans/modules/java/hints/jdk/mapreduce/PreconditionsChecker.java b/java.hints/src/org/netbeans/modules/java/hints/jdk/mapreduce/PreconditionsChecker.java
index e33fb81c1..c314c55cc 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/jdk/mapreduce/PreconditionsChecker.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/jdk/mapreduce/PreconditionsChecker.java
@@ -34,8 +34,8 @@
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -189,7 +189,7 @@ private boolean isIterbale(ExpressionTree expression) {
         return false;
     }
 
-    public static class VariablesVisitor extends TreeScanner<Tree, Trees> {
+    public static class VariablesVisitor extends ErrorAwareTreeScanner<Tree, Trees> {
 
         private Set<Name> innerVariables = new HashSet<Name>();
         private Set<Name> allLocalVariables = new HashSet<Name>();
@@ -234,7 +234,7 @@ private boolean isLocalVariable(IdentifierTree id, Trees trees) {
     /*
      * This class visits the loop to check if there are any failed preconditions.
      */
-    private static class ForLoopTreeVisitor extends TreePathScanner<Tree, Trees> {
+    private static class ForLoopTreeVisitor extends ErrorAwareTreePathScanner<Tree, Trees> {
 
         private Set<Name> inners;
         private CompilationInfo workingCopy;
diff --git a/java.hints/src/org/netbeans/modules/java/hints/perf/ManualArrayCopy.java b/java.hints/src/org/netbeans/modules/java/hints/perf/ManualArrayCopy.java
index 8241a727a..375f7e9ff 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/perf/ManualArrayCopy.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/perf/ManualArrayCopy.java
@@ -21,7 +21,7 @@
 
 import com.sun.source.tree.IdentifierTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
@@ -79,7 +79,7 @@ public static ErrorDescription arrayCopy(final HintContext ctx) {
         
         if (i != null) {
             final boolean[] used = new boolean[1];
-            new TreePathScanner<Void, Void>() {
+            new ErrorAwareTreePathScanner<Void, Void>() {
                 @Override public Void visitIdentifier(IdentifierTree node, Void p) {
                     Element use = ctx.getInfo().getTrees().getElement(getCurrentPath());
                     
diff --git a/java.hints/src/org/netbeans/modules/java/hints/perf/ReplaceBufferByString.java b/java.hints/src/org/netbeans/modules/java/hints/perf/ReplaceBufferByString.java
index 7fe11fe11..9ac0a9370 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/perf/ReplaceBufferByString.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/perf/ReplaceBufferByString.java
@@ -33,7 +33,7 @@
 import com.sun.source.tree.UnaryTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashSet;
@@ -119,7 +119,7 @@ public static ErrorDescription checkReplace(HintContext ctx) {
     /**
      * The scanner determines, if the expression is just a series of new SB().append().append()...
      */
-    private static class NewAppendScanner extends TreePathScanner<Boolean, Void> {
+    private static class NewAppendScanner extends ErrorAwareTreePathScanner<Boolean, Void> {
         private final CompilationInfo ci;
         private boolean hasContents;
         
@@ -386,7 +386,7 @@ private static boolean isPrimitiveType(TypeMirror tm) {
      * Translates rest of references in the method so that .toString() is stripped, as the variable is going
      * to change type to String.
      */
-    private static class ToStringTranslator extends TreePathScanner {
+    private static class ToStringTranslator extends ErrorAwareTreePathScanner {
         private final WorkingCopy wc;
         private final Element varElement;
         private final GeneratorUtilities gu;
@@ -442,7 +442,7 @@ public Object visitMemberSelect(MemberSelectTree node, Object p) {
      * its value must NOT be assigned to another variable, field, passed to another method call or returned from the method.
      * Only String-compatible methods may be called on the variable.
      */
-    private static class StringBufferUsageScanner extends TreePathScanner<Boolean, Void> {
+    private static class StringBufferUsageScanner extends ErrorAwareTreePathScanner<Boolean, Void> {
         private final CompilationInfo ci;
         private final VariableElement var;
         
diff --git a/java.hints/src/org/netbeans/modules/java/hints/perf/StringBuffer2Builder.java b/java.hints/src/org/netbeans/modules/java/hints/perf/StringBuffer2Builder.java
index 2e94dd054..c8594b3a1 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/perf/StringBuffer2Builder.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/perf/StringBuffer2Builder.java
@@ -23,7 +23,7 @@
 import com.sun.source.tree.MethodInvocationTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import javax.lang.model.SourceVersion;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ElementKind;
@@ -53,7 +53,7 @@ public static ErrorDescription hint(final HintContext ctx) {
             return null;
         }
 
-        class EscapeFinder extends TreePathScanner<Boolean, Boolean> {
+        class EscapeFinder extends ErrorAwareTreePathScanner<Boolean, Boolean> {
             @Override
             public Boolean reduce(Boolean r1, Boolean r2) {
                 return r1 == Boolean.TRUE || r2 == Boolean.TRUE;
diff --git a/java.hints/src/org/netbeans/modules/java/hints/suggestions/IfToSwitchSupport.java b/java.hints/src/org/netbeans/modules/java/hints/suggestions/IfToSwitchSupport.java
index f0b493417..93956eee7 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/suggestions/IfToSwitchSupport.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/suggestions/IfToSwitchSupport.java
@@ -32,8 +32,8 @@
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashSet;
@@ -585,7 +585,7 @@ protected void performRewrite(JavaFix.TransformationContext ctx) {
             TreePath topLevelMethod = Utilities.findTopLevelBlock(it);
             final Set<String> seenLabels = new HashSet<String>();
 
-            new TreeScanner<Void, Void>() {
+            new ErrorAwareTreeScanner<Void, Void>() {
                 @Override public Void visitLabeledStatement(LabeledStatementTree node, Void p) {
                     seenLabels.add(node.getLabel().toString());
                     return super.visitLabeledStatement(node, p);
@@ -764,7 +764,7 @@ private boolean addCase(WorkingCopy copy, BranchDescription desc, TreePath path,
                 above.add(t);
             }
 
-            new TreePathScanner<Void, Void>() {
+            new ErrorAwareTreePathScanner<Void, Void>() {
                 @Override public Void visitIdentifier(IdentifierTree node, Void p) {
                     if (declared.contains(info.getTrees().getElement(getCurrentPath())))
                         return null;
diff --git a/java.hints/src/org/netbeans/modules/java/hints/suggestions/Lambda.java b/java.hints/src/org/netbeans/modules/java/hints/suggestions/Lambda.java
index 348deb136..a05c84d08 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/suggestions/Lambda.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/suggestions/Lambda.java
@@ -42,8 +42,8 @@
 import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.EnumSet;
@@ -438,7 +438,7 @@ protected void performRewrite(TransformationContext ctx) throws Exception {
             }
             types.put(samTypeElement.getSimpleName(), samTypeElement);
             
-            new TreePathScanner<Void, Boolean>() {
+            new ErrorAwareTreePathScanner<Void, Boolean>() {
                 @Override public Void visitIdentifier(final IdentifierTree node, Boolean p) {
                     boolean rewrite = false;
                     boolean statRef = false;
diff --git a/java.hints/src/org/netbeans/modules/java/hints/suggestions/Tiny.java b/java.hints/src/org/netbeans/modules/java/hints/suggestions/Tiny.java
index 1ffda7db4..9cd0bf660 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/suggestions/Tiny.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/suggestions/Tiny.java
@@ -35,7 +35,7 @@
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.LinkedList;
@@ -374,7 +374,7 @@ protected void performRewrite(final TransformationContext ctx) {
                 Scope s = ctx.getWorkingCopy().getTrees().getScope(tp);
                 ctx.getWorkingCopy().getTreeUtilities().attributeTree(stmt, s);
                 st = GeneratorUtilities.get(ctx.getWorkingCopy()).importFQNs(make.addSwitchCase(st, make.Case(null, Collections.singletonList(stmt))));
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override public Void visitIdentifier(IdentifierTree node, Void p) {
                         if (node.getName().contentEquals("$expression")) {
                             ExpressionTree expression = ((SwitchTree) tp.getLeaf()).getExpression();
diff --git a/java.hints/src/org/netbeans/modules/java/hints/threading/Tiny.java b/java.hints/src/org/netbeans/modules/java/hints/threading/Tiny.java
index 845927bed..477dcd0d4 100644
--- a/java.hints/src/org/netbeans/modules/java/hints/threading/Tiny.java
+++ b/java.hints/src/org/netbeans/modules/java/hints/threading/Tiny.java
@@ -32,7 +32,7 @@
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.util.EnumSet;
 import java.util.List;
 import java.util.Set;
@@ -195,7 +195,7 @@ public static ErrorDescription nestedSynchronized(HintContext ctx) {
 
         if (!report) {
             try {
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitClass(ClassTree node, Void p) {
                         return null;
diff --git a/java.hints/test/unit/src/org/netbeans/modules/java/hints/ConvertAnonymousToInnerTest.java b/java.hints/test/unit/src/org/netbeans/modules/java/hints/ConvertAnonymousToInnerTest.java
index 3aa2fac3e..2036bc620 100644
--- a/java.hints/test/unit/src/org/netbeans/modules/java/hints/ConvertAnonymousToInnerTest.java
+++ b/java.hints/test/unit/src/org/netbeans/modules/java/hints/ConvertAnonymousToInnerTest.java
@@ -20,7 +20,7 @@
 
 import com.sun.source.tree.NewClassTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.util.regex.Pattern;
 import org.netbeans.api.java.source.JavaSource;
@@ -50,7 +50,7 @@ protected void setUp() throws Exception {
         SourceUtilsTestUtil.prepareTest(new String[0], new Object[0]);
     }
 
-    private static final class FindNewClassTree extends TreePathScanner<TreePath, Void> {
+    private static final class FindNewClassTree extends ErrorAwareTreePathScanner<TreePath, Void> {
         @Override
         public TreePath visitNewClass(NewClassTree node, Void p) {
             return getCurrentPath();
diff --git a/java.hints/test/unit/src/org/netbeans/modules/java/hints/SuspiciousNamesCombinationTest.java b/java.hints/test/unit/src/org/netbeans/modules/java/hints/SuspiciousNamesCombinationTest.java
index fcae8d032..6f599f720 100644
--- a/java.hints/test/unit/src/org/netbeans/modules/java/hints/SuspiciousNamesCombinationTest.java
+++ b/java.hints/test/unit/src/org/netbeans/modules/java/hints/SuspiciousNamesCombinationTest.java
@@ -20,7 +20,7 @@
 
 import com.sun.source.tree.Tree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.beans.PropertyVetoException;
 import java.io.File;
 import java.io.IOException;
@@ -146,7 +146,7 @@ protected void performTestAnalysisTest(String code, List<String> golden) throws
         final SuspiciousNamesCombination snc = new SuspiciousNamesCombination();
         final List<ErrorDescription> errors = new ArrayList<ErrorDescription>();
         
-        class ScannerImpl extends TreePathScanner {
+        class ScannerImpl extends ErrorAwareTreePathScanner {
             @Override
             public Object scan(Tree tree, Object p) {
                 if (tree != null && snc.getTreeKinds().contains(tree.getKind())) {
diff --git a/java.hints/test/unit/src/org/netbeans/modules/java/hints/infrastructure/TreeRuleTestBase.java b/java.hints/test/unit/src/org/netbeans/modules/java/hints/infrastructure/TreeRuleTestBase.java
index 8da2a6de2..ede2a586e 100644
--- a/java.hints/test/unit/src/org/netbeans/modules/java/hints/infrastructure/TreeRuleTestBase.java
+++ b/java.hints/test/unit/src/org/netbeans/modules/java/hints/infrastructure/TreeRuleTestBase.java
@@ -39,13 +39,13 @@
 import org.netbeans.api.java.source.JavaSource.Phase;
 import org.netbeans.api.java.source.SourceUtils;
 import org.netbeans.api.java.source.SourceUtilsTestUtil;
+import org.netbeans.api.java.source.SourceUtilsTestUtil2;
 import org.netbeans.api.java.source.TestUtilities;
 import org.netbeans.api.lexer.Language;
 import org.netbeans.junit.NbTestCase;
 import org.netbeans.junit.RandomlyFails;
 import org.netbeans.modules.java.hints.legacy.spi.RulesManager;
 import org.netbeans.modules.java.hints.legacy.spi.RulesManager.LegacyHintConfiguration;
-import org.netbeans.modules.java.source.TreeLoader;
 import org.netbeans.spi.editor.hints.ErrorDescription;
 import org.netbeans.spi.editor.hints.Fix;
 import org.openide.LifecycleManager;
@@ -74,7 +74,7 @@ protected Level logLevel() {
     protected void setUp() throws Exception {
         super.setUp();
         SourceUtilsTestUtil.prepareTest(new String[] {"org/netbeans/modules/java/editor/resources/layer.xml"}, new Object[0]);
-        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
+        SourceUtilsTestUtil2.disableConfinementTest();
     }
 
     private void prepareTest(String fileName, String code) throws Exception {
diff --git a/java.hints/test/unit/src/org/netbeans/modules/java/hints/introduce/RefFinderTest.java b/java.hints/test/unit/src/org/netbeans/modules/java/hints/introduce/RefFinderTest.java
index 884e66d6d..be9100828 100644
--- a/java.hints/test/unit/src/org/netbeans/modules/java/hints/introduce/RefFinderTest.java
+++ b/java.hints/test/unit/src/org/netbeans/modules/java/hints/introduce/RefFinderTest.java
@@ -18,15 +18,11 @@
  */
 package org.netbeans.modules.java.hints.introduce;
 
-import com.sun.source.tree.BlockTree;
 import com.sun.source.tree.MethodTree;
 import com.sun.source.tree.ReturnTree;
 import com.sun.source.tree.StatementTree;
 import com.sun.source.tree.Tree;
-import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import javax.lang.model.element.ExecutableElement;
diff --git a/java.j2semodule/nbproject/project.properties b/java.j2semodule/nbproject/project.properties
index 4aa612138..be95b9855 100644
--- a/java.j2semodule/nbproject/project.properties
+++ b/java.j2semodule/nbproject/project.properties
@@ -18,3 +18,4 @@
 javac.source=1.8
 javac.compilerargs=-Xlint -Xlint:-serial
 javadoc.arch=${basedir}/arch.xml
+requires.nb.javac=true
diff --git a/java.j2seprofiles/nbproject/project.properties b/java.j2seprofiles/nbproject/project.properties
index ab06b416c..bd782ba4c 100644
--- a/java.j2seprofiles/nbproject/project.properties
+++ b/java.j2seprofiles/nbproject/project.properties
@@ -16,3 +16,4 @@
 # under the License.
 javac.source=1.7
 javac.compilerargs=-Xlint -Xlint:-serial
+requires.nb.javac=true
diff --git a/java.j2seprofiles/src/org/netbeans/modules/java/j2seprofiles/ProfilesAnalyzer.java b/java.j2seprofiles/src/org/netbeans/modules/java/j2seprofiles/ProfilesAnalyzer.java
index 25c65f042..42b1199de 100644
--- a/java.j2seprofiles/src/org/netbeans/modules/java/j2seprofiles/ProfilesAnalyzer.java
+++ b/java.j2seprofiles/src/org/netbeans/modules/java/j2seprofiles/ProfilesAnalyzer.java
@@ -22,7 +22,7 @@
 import com.sun.source.tree.MemberSelectTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.io.IOException;
 import java.net.MalformedURLException;
@@ -634,7 +634,7 @@ public void finished() {
     }
 
     //@NonThreadSafe
-    private static final class FindPosScanner extends TreePathScanner<Void, Void> {
+    private static final class FindPosScanner extends ErrorAwareTreePathScanner<Void, Void> {
 
         private final FileObject target;
         private final Elements elements;
diff --git a/java.j2seproject/nbproject/project.properties b/java.j2seproject/nbproject/project.properties
index e242fda7b..ca9f13c32 100644
--- a/java.j2seproject/nbproject/project.properties
+++ b/java.j2seproject/nbproject/project.properties
@@ -37,3 +37,4 @@ test.config.stableBTD.excludes=\
     **/BuildImplTest.class,\
     **/J2SEConfigurationProviderTest.class,\
     **/J2SEProjectGeneratorTest.class
+requires.nb.javac=true
diff --git a/java.metrics/src/org/netbeans/modules/java/metrics/hints/ClassMetrics.java b/java.metrics/src/org/netbeans/modules/java/metrics/hints/ClassMetrics.java
index 4583d2f76..89eca3c0e 100644
--- a/java.metrics/src/org/netbeans/modules/java/metrics/hints/ClassMetrics.java
+++ b/java.metrics/src/org/netbeans/modules/java/metrics/hints/ClassMetrics.java
@@ -34,7 +34,7 @@
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.beans.Expression;
 import java.util.Collection;
 import java.util.EnumSet;
diff --git a/java.metrics/src/org/netbeans/modules/java/metrics/hints/CyclomaticComplexityVisitor.java b/java.metrics/src/org/netbeans/modules/java/metrics/hints/CyclomaticComplexityVisitor.java
index eeae9e417..5832bc167 100644
--- a/java.metrics/src/org/netbeans/modules/java/metrics/hints/CyclomaticComplexityVisitor.java
+++ b/java.metrics/src/org/netbeans/modules/java/metrics/hints/CyclomaticComplexityVisitor.java
@@ -30,7 +30,7 @@
 import com.sun.source.tree.IfTree;
 import com.sun.source.tree.ThrowTree;
 import com.sun.source.tree.WhileLoopTree;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 
 /**
  * This Visitor counts a Cyclomatic complexity on the visited tree. 
@@ -40,7 +40,7 @@
  * 
  * @author sdedic
  */
-public final class CyclomaticComplexityVisitor extends TreePathScanner<Object, Object> {
+public final class CyclomaticComplexityVisitor extends ErrorAwareTreePathScanner<Object, Object> {
     private int complexity;
     
     private boolean inClass;
diff --git a/java.metrics/src/org/netbeans/modules/java/metrics/hints/DependencyCollector.java b/java.metrics/src/org/netbeans/modules/java/metrics/hints/DependencyCollector.java
index ae5f64d57..285db99db 100644
--- a/java.metrics/src/org/netbeans/modules/java/metrics/hints/DependencyCollector.java
+++ b/java.metrics/src/org/netbeans/modules/java/metrics/hints/DependencyCollector.java
@@ -34,7 +34,7 @@
 import com.sun.source.tree.UnionTypeTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
@@ -51,7 +51,7 @@
  * Collect dependencies on external classes.
  * Depending on 'ignoreJavaLibraries' it ignores classes whose QN begins with 'java.' or 'javax.'.
  */
-class DependencyCollector extends TreePathScanner<Object, Object> {
+class DependencyCollector extends ErrorAwareTreePathScanner<Object, Object> {
     private boolean ignoreJavaLibraries;
     private final CompilationInfo info;
     private TypeElement outermostClass;
diff --git a/java.metrics/src/org/netbeans/modules/java/metrics/hints/DepthVisitor.java b/java.metrics/src/org/netbeans/modules/java/metrics/hints/DepthVisitor.java
index 75fbdacae..6cbdfeac7 100644
--- a/java.metrics/src/org/netbeans/modules/java/metrics/hints/DepthVisitor.java
+++ b/java.metrics/src/org/netbeans/modules/java/metrics/hints/DepthVisitor.java
@@ -29,14 +29,14 @@
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.TryTree;
 import com.sun.source.tree.WhileLoopTree;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 
 /**
  * Counts the maximum depth of the Tree
  * 
  * @author sdedic
  */
-public final class DepthVisitor extends TreePathScanner {
+public final class DepthVisitor extends ErrorAwareTreePathScanner {
     private int depth;
     private int maxDepth;
     
diff --git a/java.metrics/src/org/netbeans/modules/java/metrics/hints/ExpressionVisitor.java b/java.metrics/src/org/netbeans/modules/java/metrics/hints/ExpressionVisitor.java
index 4908159df..4808ad7ec 100644
--- a/java.metrics/src/org/netbeans/modules/java/metrics/hints/ExpressionVisitor.java
+++ b/java.metrics/src/org/netbeans/modules/java/metrics/hints/ExpressionVisitor.java
@@ -24,7 +24,7 @@
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.UnaryTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.EnumSet;
@@ -48,7 +48,7 @@
  * 
  * @author sdedic
  */
-class ExpressionVisitor extends TreePathScanner<Object, Object> {
+class ExpressionVisitor extends ErrorAwareTreePathScanner<Object, Object> {
     private static final EnumSet<Tree.Kind> NUMERIC_OPERATORS = EnumSet.of(
             Tree.Kind.BITWISE_COMPLEMENT, Tree.Kind.LEFT_SHIFT, Tree.Kind.RIGHT_SHIFT, Tree.Kind.UNSIGNED_RIGHT_SHIFT, 
             Tree.Kind.DIVIDE, Tree.Kind.MINUS, Tree.Kind.MULTIPLY, Tree.Kind.PLUS, Tree.Kind.REMAINDER, 
diff --git a/java.metrics/src/org/netbeans/modules/java/metrics/hints/MethodMetrics.java b/java.metrics/src/org/netbeans/modules/java/metrics/hints/MethodMetrics.java
index cc4ccfac4..d77c98c68 100644
--- a/java.metrics/src/org/netbeans/modules/java/metrics/hints/MethodMetrics.java
+++ b/java.metrics/src/org/netbeans/modules/java/metrics/hints/MethodMetrics.java
@@ -33,7 +33,7 @@
 import com.sun.source.tree.UnaryTree;
 import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.Collection;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ElementKind;
@@ -484,7 +484,7 @@ public static ErrorDescription multipleReturnPoints(HintContext ctx) {
      * The visitor will ignore returns, which are the *sole* statement in a if-branch.
      * Such branches are considered to be guards, which abort further processing.
      */
-    private static class ReturnCountVisitor extends TreePathScanner {
+    private static class ReturnCountVisitor extends ErrorAwareTreePathScanner {
         /**
          * Suppressed in local classes
          */
@@ -585,7 +585,7 @@ public static ErrorDescription multipleNegations(HintContext ctx) {
      * Counts number of 'negations' in a Tree. A negation is either unary ! or binary != inequality
      * operator.
      */
-    private static class NegationsVisitor extends TreePathScanner {
+    private static class NegationsVisitor extends ErrorAwareTreePathScanner {
         private int negationsCount;
         private final boolean ignoreAsserts;
 
@@ -627,7 +627,7 @@ public Object visitAssert(AssertTree node, Object p) {
     /**
      * Utility scanner class, which counts all kinds of loops in the scanned subtree 
      */
-    private static class LoopFinder extends TreePathScanner {
+    private static class LoopFinder extends ErrorAwareTreePathScanner {
         private int loopCount;
 
         public int getLoopCount() {
diff --git a/java.metrics/src/org/netbeans/modules/java/metrics/hints/NCLOCVisitor.java b/java.metrics/src/org/netbeans/modules/java/metrics/hints/NCLOCVisitor.java
index 15539eccb..4acc3cbd3 100644
--- a/java.metrics/src/org/netbeans/modules/java/metrics/hints/NCLOCVisitor.java
+++ b/java.metrics/src/org/netbeans/modules/java/metrics/hints/NCLOCVisitor.java
@@ -40,7 +40,7 @@
 import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 
 /**
  * Non-comment line visitor. Counts the number of non-comment
@@ -50,7 +50,7 @@
  * 
  * @author sdedic
  */
-public final class NCLOCVisitor extends TreePathScanner<Object, Object> {
+public final class NCLOCVisitor extends ErrorAwareTreePathScanner<Object, Object> {
     /**
      * The source text 
      */
diff --git a/java.module.graph/nbproject/project.properties b/java.module.graph/nbproject/project.properties
index 513775291..b3de9cde3 100644
--- a/java.module.graph/nbproject/project.properties
+++ b/java.module.graph/nbproject/project.properties
@@ -17,3 +17,4 @@
 
 javac.source=1.8
 javac.compilerargs=-Xlint -Xlint:-serial
+requires.nb.javac=true
diff --git a/java.module.graph/nbproject/project.xml b/java.module.graph/nbproject/project.xml
index cec3af8c1..cb3fbed72 100644
--- a/java.module.graph/nbproject/project.xml
+++ b/java.module.graph/nbproject/project.xml
@@ -77,15 +77,6 @@
                         <specification-version>8.19</specification-version>
                     </run-dependency>
                 </dependency>
-                <dependency>
-                    <code-name-base>org.netbeans.libs.javacimpl</code-name-base>
-                    <build-prerequisite/>
-                    <compile-dependency/>
-                    <run-dependency>
-                        <release-version>1</release-version>
-                        <specification-version>0.42</specification-version>
-                    </run-dependency>
-                </dependency>
                 <dependency>
                     <code-name-base>org.netbeans.modules.java.graph</code-name-base>
                     <build-prerequisite/>
diff --git a/java.navigation/src/org/netbeans/modules/java/navigation/BreadCrumbsNodeImpl.java b/java.navigation/src/org/netbeans/modules/java/navigation/BreadCrumbsNodeImpl.java
index 053a5cd66..7800ff962 100644
--- a/java.navigation/src/org/netbeans/modules/java/navigation/BreadCrumbsNodeImpl.java
+++ b/java.navigation/src/org/netbeans/modules/java/navigation/BreadCrumbsNodeImpl.java
@@ -49,7 +49,7 @@
 import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import java.awt.Image;
 import java.io.CharConversionException;
@@ -511,7 +511,7 @@ private static String simpleName(Tree t) {
                         return;
                     }
 
-                    tp.getLeaf().accept(new TreeScanner<Void, TreePath>() {
+                    tp.getLeaf().accept(new ErrorAwareTreeScanner<Void, TreePath>() {
                         @Override public Void scan(Tree node, TreePath p) {
                             if (node == null) return null;
                             if (node.getKind() == Kind.IF) {
diff --git a/java.navigation/src/org/netbeans/modules/java/navigation/ElementScanningTask.java b/java.navigation/src/org/netbeans/modules/java/navigation/ElementScanningTask.java
index 205cdf55b..d01d90dd6 100644
--- a/java.navigation/src/org/netbeans/modules/java/navigation/ElementScanningTask.java
+++ b/java.navigation/src/org/netbeans/modules/java/navigation/ElementScanningTask.java
@@ -27,7 +27,7 @@
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.util.Collections;
 import java.util.EnumSet;
@@ -211,7 +211,7 @@ DirectiveTree getDirectiveTree(@NonNull final ModuleElement.Directive directive)
         }
     }
 
-    private static class PositionVisitor extends TreePathScanner<Context, Void> {
+    private static class PositionVisitor extends ErrorAwareTreePathScanner<Context, Void> {
 
         private final Trees trees;
         private final SourcePositions sourcePositions;
diff --git a/java.navigation/src/org/netbeans/modules/java/navigation/actions/OpenAction.java b/java.navigation/src/org/netbeans/modules/java/navigation/actions/OpenAction.java
index 40559af64..d307db424 100644
--- a/java.navigation/src/org/netbeans/modules/java/navigation/actions/OpenAction.java
+++ b/java.navigation/src/org/netbeans/modules/java/navigation/actions/OpenAction.java
@@ -31,7 +31,7 @@
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.UsesTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.awt.Toolkit;
 import org.netbeans.api.java.source.ElementHandle;
 import org.netbeans.api.java.source.ui.ElementOpen;
@@ -237,7 +237,7 @@ private static TreePathHandle resolveDirectiveHandle(
                 @Override
                 public void run(final CompilationController cc) throws Exception {
                     cc.toPhase(JavaSource.Phase.ELEMENTS_RESOLVED);
-                    new TreePathScanner<Void, Void>() {
+                    new ErrorAwareTreePathScanner<Void, Void>() {
                         @Override
                         public Void visitExports(ExportsTree node, Void p) {
                             if (matches(handle, ModuleElement.DirectiveKind.EXPORTS, node.getPackageName())) {
diff --git a/java.preprocessorbridge/nbproject/project.properties b/java.preprocessorbridge/nbproject/project.properties
index 8aff04978..a6f0b6128 100644
--- a/java.preprocessorbridge/nbproject/project.properties
+++ b/java.preprocessorbridge/nbproject/project.properties
@@ -20,3 +20,4 @@ javac.source=1.8
 spec.version.base=1.49.0
 javadoc.apichanges=${basedir}/apichanges.xml
 
+requires.nb.javac=true
diff --git a/java.source.base/nbproject/project.properties b/java.source.base/nbproject/project.properties
index 1e5933bb0..a97ce2287 100644
--- a/java.source.base/nbproject/project.properties
+++ b/java.source.base/nbproject/project.properties
@@ -122,6 +122,7 @@ test.config.generator.includes=\
 test.config.jet-main.includes=\
     ${test.config.core.includes},\
     ${test.config.generator.includes},\
+    org/netbeans/api/java/source/TreeUtilitiesTest.class,\
     org/netbeans/api/java/source/TypeUtilitiesTest.class,\
     org/netbeans/api/java/source/TreePathHandleTest.class,\
     org/netbeans/api/java/source/TreeMirrorHandleTest.class,\
diff --git a/java.source.base/nbproject/project.xml b/java.source.base/nbproject/project.xml
index e21285ead..d012fd58b 100644
--- a/java.source.base/nbproject/project.xml
+++ b/java.source.base/nbproject/project.xml
@@ -69,6 +69,14 @@
                         <implementation-version/>
                     </run-dependency>
                 </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.libs.asm</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <specification-version>5.4</specification-version>
+                    </run-dependency>
+                </dependency>
                 <dependency>
                     <code-name-base>org.netbeans.libs.javacapi</code-name-base>
                     <build-prerequisite/>
@@ -289,6 +297,9 @@
             <test-dependencies>
                 <test-type>
                     <name>unit</name>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.api.progress.nb</code-name-base>
+                    </test-dependency>
                     <test-dependency>
                         <code-name-base>org.netbeans.core.startup</code-name-base>
                     </test-dependency>
@@ -332,6 +343,10 @@
                         <code-name-base>org.netbeans.modules.java.guards</code-name-base>
                         <compile-dependency/>
                     </test-dependency>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.modules.java.j2seplatform</code-name-base>
+                        <compile-dependency/>
+                    </test-dependency>
                     <test-dependency>
                         <code-name-base>org.netbeans.modules.java.lexer</code-name-base>
                         <compile-dependency/>
@@ -410,18 +425,15 @@
                         <code-name-base>org.openide.text</code-name-base>
                     </test-dependency>
                     <test-dependency>
-                        <code-name-base>org.openide.util.ui</code-name-base>
+                        <code-name-base>org.openide.util.lookup</code-name-base>
                         <compile-dependency/>
                         <test/>
                     </test-dependency>
                     <test-dependency>
-                        <code-name-base>org.openide.util.lookup</code-name-base>
+                        <code-name-base>org.openide.util.ui</code-name-base>
                         <compile-dependency/>
                         <test/>
                     </test-dependency>
-                    <test-dependency>
-                        <code-name-base>org.netbeans.api.progress.nb</code-name-base>
-                    </test-dependency>
                 </test-type>
             </test-dependencies>
             <public-packages>
diff --git a/java.source.base/src/org/netbeans/api/java/source/AssignComments.java b/java.source.base/src/org/netbeans/api/java/source/AssignComments.java
index 16fc78546..b6c70bb4d 100644
--- a/java.source.base/src/org/netbeans/api/java/source/AssignComments.java
+++ b/java.source.base/src/org/netbeans/api/java/source/AssignComments.java
@@ -36,7 +36,7 @@
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.tools.javac.tree.JCTree;
 import java.util.Collections;
 import java.util.EnumSet;
@@ -63,7 +63,7 @@
  *
  * @author Pavel Flaska, Rastislav Komara, Jan Lahoda
  */
-class AssignComments extends TreeScanner<Void, Void> {
+class AssignComments extends ErrorAwareTreeScanner<Void, Void> {
     
     private static final EnumSet<Tree.Kind> JAVADOC_KINDS = EnumSet.of(
             Tree.Kind.CLASS,
diff --git a/java.source.base/src/org/netbeans/api/java/source/CompilationInfo.java b/java.source.base/src/org/netbeans/api/java/source/CompilationInfo.java
index 43797b240..21be70bbe 100644
--- a/java.source.base/src/org/netbeans/api/java/source/CompilationInfo.java
+++ b/java.source.base/src/org/netbeans/api/java/source/CompilationInfo.java
@@ -23,16 +23,19 @@
 import com.sun.source.tree.MethodTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.util.DocTrees;
+import com.sun.source.util.JavacTask;
 import com.sun.source.util.TreePath;
 import com.sun.source.util.Trees;
 import com.sun.tools.javac.api.JavacTrees;
 import com.sun.tools.javac.code.Source;
 import com.sun.tools.javac.model.JavacElements;
+
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Optional;
+
 import javax.lang.model.SourceVersion;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ModuleElement;
@@ -41,6 +44,7 @@
 import javax.lang.model.util.Types;
 import javax.swing.text.Document;
 import javax.tools.Diagnostic;
+
 import org.netbeans.api.annotations.common.CheckForNull;
 import org.netbeans.api.annotations.common.CheckReturnValue;
 import org.netbeans.api.annotations.common.NonNull;
@@ -48,6 +52,8 @@
 import org.netbeans.api.annotations.common.NullUnknown;
 import org.netbeans.api.lexer.TokenHierarchy;
 import org.netbeans.modules.java.preprocessorbridge.spi.WrapperFactory;
+import org.netbeans.modules.java.source.CompilationInfoAccessor;
+import org.netbeans.modules.java.source.ElementUtils;
 import org.netbeans.modules.java.source.parsing.CompilationInfoImpl;
 import org.netbeans.modules.java.source.parsing.DocPositionRegion;
 import org.netbeans.modules.java.source.parsing.FileObjects;
@@ -222,8 +228,8 @@ public CompilationUnitTree getCompilationUnit() {
                             SourceUtils.getModuleName(impl.getRoot().toURL(), true) :
                             null)
                     .map(elements::getModuleElement)
-                    .map((module) -> elements.getTypeElementByBinaryName(module, name))
-                    .orElseGet(() -> elements.getTypeElementByBinaryName(name));
+                    .map((module) -> ElementUtils.getTypeElementByBinaryName(this, module, name))
+                    .orElseGet(() -> ElementUtils.getTypeElementByBinaryName(this, name));
             if (e != null) {                
                 result.add (e);
             }
@@ -257,6 +263,8 @@ public CompilationUnitTree getCompilationUnit() {
     public synchronized @NonNull Trees getTrees() {
         checkConfinement();
         if (trees == null) {
+            //use a working init order:
+            com.sun.tools.javac.main.JavaCompiler.instance(impl.getJavacTask().getContext());
             trees = JavacTrees.instance(impl.getJavacTask().getContext());
             Snapshot snapshot = impl.getSnapshot();
             Document doc = snapshot != null ? snapshot.getSource().getDocument(false) : null;
@@ -284,6 +292,8 @@ public CompilationUnitTree getCompilationUnit() {
      */
     public @NonNull Types getTypes() {
         checkConfinement();
+        //use a working init order:
+        com.sun.tools.javac.main.JavaCompiler.instance(impl.getJavacTask().getContext());
         return impl.getJavacTask().getTypes();
     }
     
@@ -293,6 +303,8 @@ public CompilationUnitTree getCompilationUnit() {
      */
     public @NonNull Elements getElements() {
         checkConfinement();
+        //use a working init order:
+        com.sun.tools.javac.main.JavaCompiler.instance(impl.getJavacTask().getContext());
 	return impl.getJavacTask().getElements();
     }
         
@@ -475,4 +487,13 @@ final void checkConfinement () throws IllegalStateException {
         /** The cached value will be cleared when a method/field/class is added, removed or its signature changes. */
         ON_SIGNATURE_CHANGE;
     }
+
+    static {
+        CompilationInfoAccessor.setInstance(new CompilationInfoAccessor() {
+            @Override
+            public JavacTask getJavacTask(CompilationInfo info) {
+                return info.impl.getJavacTask();
+            }
+        });
+    }
 }
diff --git a/java.source.base/src/org/netbeans/api/java/source/ElementHandle.java b/java.source.base/src/org/netbeans/api/java/source/ElementHandle.java
index fcbc41fe1..a6211c990 100644
--- a/java.source.base/src/org/netbeans/api/java/source/ElementHandle.java
+++ b/java.source.base/src/org/netbeans/api/java/source/ElementHandle.java
@@ -41,9 +41,11 @@
 import javax.lang.model.element.VariableElement;
 import javax.lang.model.type.DeclaredType;
 import javax.lang.model.type.TypeKind;
+
 import org.netbeans.api.annotations.common.CheckForNull;
 import org.netbeans.api.annotations.common.NonNull;
 import org.netbeans.modules.java.source.ElementHandleAccessor;
+import org.netbeans.modules.java.source.ElementUtils;
 import org.netbeans.modules.java.source.usages.ClassFileUtil;
 import org.openide.util.Parameters;
 import org.openide.util.WeakSet;
@@ -633,10 +635,9 @@ else if (isArray(signature)) {
             return Symtab.instance(jt.getContext()).arrayClass;
         }
         else {
-            final JavacElements elements = (JavacElements) jt.getElements();                    
             return (TypeElement) (module != null
-                    ? elements.getTypeElementByBinaryName(module, signature)
-                    : elements.getTypeElementByBinaryName(signature));
+                    ? ElementUtils.getTypeElementByBinaryName(jt, module, signature)
+                    : ElementUtils.getTypeElementByBinaryName(jt, signature));
         }
     }
     
diff --git a/java.source.base/src/org/netbeans/api/java/source/ElementUtilities.java b/java.source.base/src/org/netbeans/api/java/source/ElementUtilities.java
index c61429e67..665c0e7c2 100644
--- a/java.source.base/src/org/netbeans/api/java/source/ElementUtilities.java
+++ b/java.source.base/src/org/netbeans/api/java/source/ElementUtilities.java
@@ -89,6 +89,7 @@
 import org.netbeans.api.annotations.common.NullAllowed;
 import org.netbeans.modules.java.source.builder.ElementsService;
 import org.netbeans.modules.java.source.JavadocEnv;
+import org.netbeans.modules.java.source.base.SourceLevelUtils;
 import org.openide.util.Parameters;
 
 /**
@@ -273,7 +274,7 @@ public Element elementFor(Doc doc) {
                                 members.add(member);
                         }
                     }
-                    if (te.getKind().isClass() || te.getKind().isInterface() && Source.instance(ctx).allowDefaultMethods()) {
+                    if (te.getKind().isClass() || te.getKind().isInterface() && SourceLevelUtils.allowDefaultMethods(Source.instance(ctx))) {
                         VarSymbol thisPseudoMember = new VarSymbol(Flags.FINAL | Flags.HASINIT, Names.instance(ctx)._this, (ClassType)te.asType(), (ClassSymbol)te);
                         if (acceptor == null || acceptor.accept(thisPseudoMember, type))
                             members.add(thisPseudoMember);
diff --git a/java.source.base/src/org/netbeans/api/java/source/GeneratorUtilities.java b/java.source.base/src/org/netbeans/api/java/source/GeneratorUtilities.java
index 44cfd4c56..9af27006a 100644
--- a/java.source.base/src/org/netbeans/api/java/source/GeneratorUtilities.java
+++ b/java.source.base/src/org/netbeans/api/java/source/GeneratorUtilities.java
@@ -53,8 +53,8 @@
 import com.sun.source.tree.WildcardTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import com.sun.tools.javac.api.JavacTaskImpl;
 import com.sun.tools.javac.code.Flags;
@@ -89,6 +89,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+
 import javax.lang.model.SourceVersion;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ElementKind;
@@ -114,6 +115,8 @@
 import javax.script.ScriptException;
 import javax.swing.text.Document;
 import javax.tools.JavaFileObject;
+
+import com.sun.tools.javac.parser.ParserFactory;
 import org.netbeans.api.editor.document.LineDocumentUtils;
 import org.netbeans.api.editor.guards.DocumentGuards;
 import org.netbeans.api.java.lexer.JavaTokenId;
@@ -124,6 +127,7 @@
 import org.netbeans.modules.java.source.builder.CommentSetImpl;
 import org.netbeans.modules.java.source.parsing.AbstractSourceFileObject;
 import org.netbeans.modules.java.source.parsing.FileObjects;
+import org.netbeans.modules.java.source.parsing.ParsingUtils;
 import org.netbeans.modules.java.source.query.CommentSet.RelativePosition;
 import org.netbeans.modules.java.source.save.DiffContext;
 import org.openide.filesystems.FileObject;
@@ -171,7 +175,7 @@ public CompilationUnitTree createFromTemplate(FileObject sourceRoot, String path
         JavaFileObject sourceFile = FileObjects.templateFileObject(sourceRoot, nameComponent[0], nameComponent[1]);
         FileObject template = FileUtil.getConfigFile(copy.template(kind));
         FileObject targetFile = copy.doCreateFromTemplate(template, sourceFile);
-        CompilationUnitTree templateCUT = copy.impl.getJavacTask().parse(FileObjects.sourceFileObject(targetFile, targetFile.getParent())).iterator().next();
+        CompilationUnitTree templateCUT = ParsingUtils.parseArbitrarySource(copy.impl.getJavacTask(), FileObjects.sourceFileObject(targetFile, targetFile.getParent()));
         CompilationUnitTree importComments = GeneratorUtilities.get(copy).importComments(templateCUT, templateCUT);
         CompilationUnitTree result = copy.getTreeMaker().CompilationUnit(importComments.getPackageAnnotations(),
                 sourceRoot,
@@ -498,7 +502,7 @@ private static void moveCommentsBeforeOffset(WorkingCopy wc, Tree from, Tree to,
      * the revDependencies and dependencies can be used to determine partial order
      * between existing members and the newly inserted one.
      */
-    private class FieldRefVisitor extends TreePathScanner {
+    private class FieldRefVisitor extends ErrorAwareTreePathScanner {
         private final ClassTree clazz;
         // collects field names; serves to identify unqualified indentifiers
         // which might refer to field names.
@@ -1781,7 +1785,7 @@ private Tree resolveWildcard(TypeMirror type) {
         }
 
         final Map<Tree, Tree> translate = new IdentityHashMap<Tree, Tree>();
-        new TreeScanner<Void, Void>() {
+        new ErrorAwareTreeScanner<Void, Void>() {
             @Override public Void visitWildcard(WildcardTree node, Void p) {
                 Tree bound = node.getBound();
 
@@ -1853,7 +1857,7 @@ private Element getElementByFQN(CompilationUnitTree cut, String fqn) {
     private Map<Name, TypeElement> getUsedTypes(final CompilationUnitTree cut) {
         final Trees trees = copy.getTrees();
         final Map<Name, TypeElement> map = new HashMap<Name, TypeElement>();
-        new TreePathScanner<Void, Void>() {
+        new ErrorAwareTreePathScanner<Void, Void>() {
 
             @Override
             public Void visitIdentifier(IdentifierTree node, Void p) {
@@ -2218,7 +2222,7 @@ private static ScriptEngine engine(FileObject fo) {
     }
     
     private static boolean containsErrors(Tree tree) {
-        Boolean b = new TreeScanner<Boolean, Boolean>() {
+        Boolean b = new ErrorAwareTreeScanner<Boolean, Boolean>() {
             @Override
             public Boolean visitErroneous(ErroneousTree node, Boolean p) {
                 return true;
diff --git a/java.source.base/src/org/netbeans/api/java/source/JavaSource.java b/java.source.base/src/org/netbeans/api/java/source/JavaSource.java
index 2b66dfbb1..89acf16bd 100644
--- a/java.source.base/src/org/netbeans/api/java/source/JavaSource.java
+++ b/java.source.base/src/org/netbeans/api/java/source/JavaSource.java
@@ -48,6 +48,7 @@
 import org.netbeans.api.java.classpath.JavaClassPathConstants;
 import org.netbeans.api.java.platform.JavaPlatformManager;
 import org.netbeans.modules.java.source.JavaSourceAccessor;
+import org.netbeans.modules.java.source.NoJavacHelper;
 import org.netbeans.modules.java.source.parsing.CachingArchiveProvider;
 import org.netbeans.modules.java.source.parsing.ClassParser;
 import org.netbeans.modules.java.source.parsing.ClasspathInfoTask;
@@ -185,6 +186,8 @@ public FileObject getFile () {
         if (files == null) {
             throw new IllegalArgumentException ();
         }
+        if (!NoJavacHelper.hasWorkingJavac())
+            return null;
         try {
             return new JavaSource(cpInfo, files);
 // TODO: Split
diff --git a/java.source.base/src/org/netbeans/api/java/source/SourceUtils.java b/java.source.base/src/org/netbeans/api/java/source/SourceUtils.java
index 3f42433fa..9ff0e2cab 100644
--- a/java.source.base/src/org/netbeans/api/java/source/SourceUtils.java
+++ b/java.source.base/src/org/netbeans/api/java/source/SourceUtils.java
@@ -86,6 +86,7 @@
 import org.netbeans.api.lexer.TokenSequence;
 import org.netbeans.modules.java.preprocessorbridge.spi.ImportProcessor;
 import org.netbeans.modules.java.source.ElementHandleAccessor;
+import org.netbeans.modules.java.source.ElementUtils;
 import org.netbeans.modules.java.source.JavadocHelper;
 import org.netbeans.modules.java.source.ModuleNames;
 import org.netbeans.modules.java.source.indexing.FQN2Files;
@@ -200,7 +201,8 @@ public static TypeMirror getBound(WildcardType wildcardType) {
         List<Completion> completions = new LinkedList<>();
         if (info.getPhase().compareTo(Phase.ELEMENTS_RESOLVED) >= 0) {
             String fqn = ((TypeElement) annotation.getAnnotationType().asElement()).getQualifiedName().toString();
-            Iterable<? extends Processor> processors = info.impl.getJavacTask().getProcessors();
+            Iterable<? extends Processor> processors =
+                    JavacParser.ProcessorHolder.instance(info.impl.getJavacTask().getContext()).getProcessors();
             if (processors != null) {
                 for (Processor processor : processors) {
                     boolean match = false;
@@ -923,7 +925,7 @@ public static boolean isMainClass (final String qualifiedName, ClasspathInfo cpI
                     public void run(CompilationController control) throws Exception {
                         control.toPhase(Phase.ELEMENTS_RESOLVED);
                         final JavacElements elms = (JavacElements)control.getElements();
-                        TypeElement type = elms.getTypeElementByBinaryName(qualifiedName);
+                        TypeElement type = ElementUtils.getTypeElementByBinaryName(control, qualifiedName);
                         if (type == null) {
                             return;
                         }
diff --git a/java.source.base/src/org/netbeans/api/java/source/TranslateIdentifier.java b/java.source.base/src/org/netbeans/api/java/source/TranslateIdentifier.java
index c3ae8e739..c9247e312 100644
--- a/java.source.base/src/org/netbeans/api/java/source/TranslateIdentifier.java
+++ b/java.source.base/src/org/netbeans/api/java/source/TranslateIdentifier.java
@@ -27,7 +27,7 @@
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.tools.javac.code.Symbol;
 import java.util.HashMap;
 import java.util.Map;
@@ -47,7 +47,7 @@
  *
  * @author Pavel Flaska
  */
-class TranslateIdentifier extends TreePathScanner<Void, Void>{
+class TranslateIdentifier extends ErrorAwareTreePathScanner<Void, Void>{
     
     public static <T extends Tree> T importFQNs(WorkingCopy copy, T tree) {
         if (tree == null) return null;
diff --git a/java.source.base/src/org/netbeans/api/java/source/TreeMaker.java b/java.source.base/src/org/netbeans/api/java/source/TreeMaker.java
index a8cec9092..6d52e93f0 100644
--- a/java.source.base/src/org/netbeans/api/java/source/TreeMaker.java
+++ b/java.source.base/src/org/netbeans/api/java/source/TreeMaker.java
@@ -52,7 +52,7 @@
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
 
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.tools.javac.code.Flags;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.JCModifiers;
@@ -1096,7 +1096,7 @@ public TryTree Try(List<? extends Tree> resources,
         Tree typeTree = copy.getTreeUtilities().parseType(type);
         final Map<Tree, Tree> translate = new HashMap<Tree, Tree>();
 
-        new TreeScanner<Void, Void>() {
+        new ErrorAwareTreeScanner<Void, Void>() {
             @Override
             public Void visitMemberSelect(MemberSelectTree node, Void p) {
                 translate.put(node, QualIdent(node.toString()));
@@ -3344,7 +3344,7 @@ private void mapComments(BlockTree block, String inputText, WorkingCopy copy, Co
         }*/
     }
 
-    private static class TreePosCleaner extends TreeScanner<Void, Void> {
+    private static class TreePosCleaner extends ErrorAwareTreeScanner<Void, Void> {
 
         @Override
         public Void scan(Tree tree, Void p) {
diff --git a/java.source.base/src/org/netbeans/api/java/source/TreePathHandle.java b/java.source.base/src/org/netbeans/api/java/source/TreePathHandle.java
index 0f1483e70..cb012c8e9 100644
--- a/java.source.base/src/org/netbeans/api/java/source/TreePathHandle.java
+++ b/java.source.base/src/org/netbeans/api/java/source/TreePathHandle.java
@@ -24,7 +24,7 @@
 import com.sun.source.tree.Tree;                                                                                                                                                                                               
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;                                                                                                                                                                                           
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.tools.javac.code.Symbol;
 import com.sun.tools.javac.tree.JCTree;                                                                                                                                                                                        
 
@@ -864,7 +864,7 @@ public ElementHandle getElementHandle() {
     private static List<Tree> listChildren(@NonNull Tree t) {
         final List<Tree> result = new LinkedList<Tree>();
 
-        t.accept(new TreeScanner<Void, Void>() {
+        t.accept(new ErrorAwareTreeScanner<Void, Void>() {
             @Override
             public Void scan(Tree node, Void p) {
                 result.add(node);
diff --git a/java.source.base/src/org/netbeans/api/java/source/TreeUtilities.java b/java.source.base/src/org/netbeans/api/java/source/TreeUtilities.java
index cfeac94db..d616476d0 100644
--- a/java.source.base/src/org/netbeans/api/java/source/TreeUtilities.java
+++ b/java.source.base/src/org/netbeans/api/java/source/TreeUtilities.java
@@ -18,6 +18,12 @@
  */
 package org.netbeans.api.java.source;
 
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URI;
+import java.nio.CharBuffer;
+
 import com.sun.source.doctree.DocCommentTree;
 import com.sun.source.doctree.DocTree;
 import com.sun.source.doctree.ReferenceTree;
@@ -28,8 +34,8 @@
 import com.sun.source.util.DocTreePathScanner;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import com.sun.tools.javac.api.JavacScope;
 import com.sun.tools.javac.api.JavacTrees;
@@ -45,9 +51,12 @@
 import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
 import com.sun.tools.javac.tree.TreeInfo;
 import com.sun.tools.javac.util.Context;
+
 import java.util.*;
+import java.util.function.Function;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+
 import javax.lang.model.SourceVersion;
 import javax.lang.model.element.*;
 import javax.lang.model.type.DeclaredType;
@@ -57,6 +66,24 @@
 import javax.lang.model.util.ElementFilter;
 import javax.lang.model.util.Elements;
 import javax.lang.model.util.Types;
+import javax.tools.Diagnostic;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+
+import com.sun.source.util.DocTrees;
+import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.comp.ArgumentAttr;
+import com.sun.tools.javac.comp.Attr;
+import com.sun.tools.javac.main.JavaCompiler;
+import com.sun.tools.javac.parser.JavacParser;
+import com.sun.tools.javac.parser.Parser;
+import com.sun.tools.javac.parser.ParserFactory;
+import com.sun.tools.javac.parser.ScannerFactory;
+import com.sun.tools.javac.tree.JCTree.JCClassDecl;
+import com.sun.tools.javac.tree.JCTree.JCExpression;
+import com.sun.tools.javac.util.JCDiagnostic;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.Names;
 import org.netbeans.api.annotations.common.CheckForNull;
 import org.netbeans.api.annotations.common.NonNull;
 import org.netbeans.api.annotations.common.NullAllowed;
@@ -64,13 +91,17 @@
 import org.netbeans.api.java.lexer.JavadocTokenId;
 import org.netbeans.api.java.source.JavaSource.Phase;
 import org.netbeans.api.lexer.TokenSequence;
+import org.netbeans.lib.nbjavac.services.CancelService;
+import org.netbeans.lib.nbjavac.services.NBParserFactory;
 import org.netbeans.lib.nbjavac.services.NBResolve;
 import org.netbeans.lib.nbjavac.services.NBTreeMaker.IndexedClassDecl;
+import org.netbeans.modules.java.source.TreeUtilitiesAccessor;
 import org.netbeans.modules.java.source.builder.CommentHandlerService;
 import org.netbeans.modules.java.source.builder.CommentSetImpl;
 import org.netbeans.modules.java.source.pretty.ImportAnalysis2;
 import org.netbeans.modules.java.source.transform.ImmutableDocTreeTranslator;
 import org.netbeans.modules.java.source.transform.ImmutableTreeTranslator;
+import org.openide.util.Exceptions;
 
 /**
  *
@@ -301,7 +332,7 @@ public TreePath pathFor(TreePath path, int pos, SourcePositions sourcePositions)
             }
         }
         
-        class PathFinder extends TreePathScanner<Void,Void> {
+        class PathFinder extends ErrorAwareTreePathScanner<Void,Void> {
             private int pos;
             private SourcePositions sourcePositions;
             
@@ -345,6 +376,7 @@ public Void visitMethod(MethodTree node, Void p) {
                 
                 return super.visitMethod(node, p);
             }
+
         }
         
         try {
@@ -534,13 +566,7 @@ public TypeMirror parseType(String expr, TypeElement scope) {
      * @return parsed {@link TypeMirror} or null if the given specification cannot be parsed
      */
     Tree parseType(String expr) {
-        com.sun.tools.javac.tree.TreeMaker jcMaker = com.sun.tools.javac.tree.TreeMaker.instance(info.impl.getJavacTask().getContext());
-        int oldPos = jcMaker.pos;
-        try {
-            return info.impl.getJavacTask().parseType(expr);
-        } finally {
-            jcMaker.pos = oldPos;
-        }
+        return doParse(expr, null, 0, Parser::parseType);
     }
     
     /**Parses given statement.
@@ -550,16 +576,13 @@ Tree parseType(String expr) {
      * @return parsed {@link StatementTree} or null?
      */
     public StatementTree parseStatement(String stmt, SourcePositions[] sourcePositions) {
-        com.sun.tools.javac.tree.TreeMaker jcMaker = com.sun.tools.javac.tree.TreeMaker.instance(info.impl.getJavacTask().getContext());
-        int oldPos = jcMaker.pos;
-        
-        try {
-            return (StatementTree)info.impl.getJavacTask().parseStatement(stmt, sourcePositions);
-        } finally {
-            jcMaker.pos = oldPos;
-        }
+        return parseStatementImpl(info.impl.getJavacTask(), stmt, sourcePositions);
     }
-    
+
+    private static StatementTree parseStatementImpl(JavacTaskImpl task, String stmt, SourcePositions[] sourcePositions) {
+        return doParse(task, stmt, sourcePositions, 0, Parser::parseStatement);
+    }
+
     /**Parses given expression.
      * 
      * @param expr expression code
@@ -567,14 +590,7 @@ public StatementTree parseStatement(String stmt, SourcePositions[] sourcePositio
      * @return parsed {@link ExpressionTree} or null?
      */
     public ExpressionTree parseExpression(String expr, SourcePositions[] sourcePositions) {
-        com.sun.tools.javac.tree.TreeMaker jcMaker = com.sun.tools.javac.tree.TreeMaker.instance(info.impl.getJavacTask().getContext());
-        int oldPos = jcMaker.pos;
-        
-        try {
-            return (ExpressionTree) info.impl.getJavacTask().parseExpression(expr, sourcePositions);
-        } finally {
-            jcMaker.pos = oldPos;
-        }
+        return doParse(expr, sourcePositions, 0, Parser::parseExpression);
     }
     
     /**Parses given variable initializer.
@@ -584,14 +600,7 @@ public ExpressionTree parseExpression(String expr, SourcePositions[] sourcePosit
      * @return parsed {@link ExpressionTree} or null?
      */
     public ExpressionTree parseVariableInitializer(String init, SourcePositions[] sourcePositions) {
-        com.sun.tools.javac.tree.TreeMaker jcMaker = com.sun.tools.javac.tree.TreeMaker.instance(info.impl.getJavacTask().getContext());
-        int oldPos = jcMaker.pos;
-        
-        try {
-            return (ExpressionTree)info.impl.getJavacTask().parseVariableInitializer(init, sourcePositions);
-        } finally {
-            jcMaker.pos = oldPos;
-        }
+        return doParse(init, sourcePositions, 0, p -> ((JavacParser) p).variableInitializer());
     }
 
     /**Parses given static block.
@@ -601,15 +610,90 @@ public ExpressionTree parseVariableInitializer(String init, SourcePositions[] so
      * @return parsed {@link BlockTree} or null?
      */
     public BlockTree parseStaticBlock(String block, SourcePositions[] sourcePositions) {
-        com.sun.tools.javac.tree.TreeMaker jcMaker = com.sun.tools.javac.tree.TreeMaker.instance(info.impl.getJavacTask().getContext());
+        return doParse("{ class C { " + block + " }", sourcePositions, "{ class C { ".length(), p -> {
+            JCClassDecl decl = (JCClassDecl) ((BlockTree) p.parseStatement()).getStatements().get(0);
+            return decl.defs.head.getKind() == Kind.BLOCK ? (BlockTree) decl.defs.head : null; //check result
+        });
+    }
+
+    /**Parses given statement.
+     * 
+     * @param text code
+     * @param sourcePositions return value - new SourcePositions for the new tree
+     * @return parsed {@link T} or null?
+     */
+    private <T extends Tree> T doParse(String text, SourcePositions[] sourcePositions, int offset, Function<Parser, T> actualParse) {
+        return doParse(info.impl.getJavacTask(), text, sourcePositions, offset, actualParse);
+    }
+
+    private static <T extends Tree> T doParse(JavacTaskImpl task, String text, SourcePositions[] sourcePositions, int offset, Function<Parser, T> actualParse) {
+        if (text == null || (sourcePositions != null && sourcePositions.length != 1))
+            throw new IllegalArgumentException();
+        //use a working init order:
+        com.sun.tools.javac.main.JavaCompiler.instance(task.getContext());
+        com.sun.tools.javac.tree.TreeMaker jcMaker = com.sun.tools.javac.tree.TreeMaker.instance(task.getContext());
         int oldPos = jcMaker.pos;
         
         try {
-            return (BlockTree)info.impl.getJavacTask().parseStaticBlock(block, sourcePositions);
+            //from org/netbeans/modules/java/hints/spiimpl/Utilities.java:
+            Context context = task.getContext();
+            JavaCompiler compiler = JavaCompiler.instance(context);
+            JavaFileObject prev = compiler.log.useSource(new DummyJFO());
+            Log.DiagnosticHandler discardHandler = new Log.DiscardDiagnosticHandler(compiler.log) {
+                @Override
+                public void report(JCDiagnostic diag) {
+                    //ignore:
+                }            
+            };
+            try {
+                CharBuffer buf = CharBuffer.wrap((text+"\u0000").toCharArray(), 0, text.length());
+                ParserFactory factory = ParserFactory.instance(context);
+                Parser parser = factory.newParser(buf, false, true, false, false);
+                if (parser instanceof JavacParser) {
+                    if (sourcePositions != null)
+                        sourcePositions[0] = new ParserSourcePositions((JavacParser)parser, offset);
+                    return actualParse.apply(parser);
+                }
+                return null;
+            } finally {
+                compiler.log.useSource(prev);
+                compiler.log.popDiagnosticHandler(discardHandler);
+            }
         } finally {
             jcMaker.pos = oldPos;
         }
     }
+    
+    //from org/netbeans/modules/java/hints/spiimpl/Utilities.java:
+    private static final class DummyJFO extends SimpleJavaFileObject {
+        private DummyJFO() {
+            super(URI.create("dummy.java"), JavaFileObject.Kind.SOURCE);
+        }
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
+            return "";
+        }
+    }
+
+    //from org/netbeans/modules/java/hints/spiimpl/Utilities.java:
+    private static class ParserSourcePositions implements SourcePositions {
+
+        private final JavacParser parser;
+        private final int offset;
+
+        private ParserSourcePositions(JavacParser parser, int offset) {
+            this.parser = parser;
+            this.offset = offset;
+        }
+
+        public long getStartPosition(CompilationUnitTree file, Tree tree) {
+            return parser.getStartPos((JCTree)tree) - offset;
+        }
+
+        public long getEndPosition(CompilationUnitTree file, Tree tree) {
+            return parser.getEndPos((JCTree)tree) - offset;
+        }
+    }
 
     //XXX: parseAnnotationValue
     
@@ -679,6 +763,14 @@ public Scope scopeFor(int pos) {
     public Scope toScopeWithDisabledAccessibilityChecks(Scope scope) {
         return new NBScope((JavacScope)scope);
     }
+
+    private static Env<AttrContext> getEnv(Scope scope) {
+        if (scope instanceof NBScope) {
+            scope = ((NBScope) scope).delegate;
+        }
+        
+        return ((JavacScope) scope).getEnv();
+    }
     
     /**Attribute the given tree in the given context.
      */
@@ -687,7 +779,7 @@ public TypeMirror attributeTree(Tree tree, Scope scope) {
             NBResolve.instance(info.impl.getJavacTask().getContext()).disableAccessibilityChecks();
         }
         try {
-            return info.impl.getJavacTask().attributeTree((JCTree) tree, ((JavacScope) scope).getEnv());
+            return attributeTree(info.impl.getJavacTask(), (JCTree) tree, scope, new ArrayList<>());
         } finally {
             NBResolve.instance(info.impl.getJavacTask().getContext()).restoreAccessbilityChecks();
         }
@@ -701,38 +793,106 @@ public Scope attributeTreeTo(Tree tree, Scope scope, Tree to) {
             NBResolve.instance(info.impl.getJavacTask().getContext()).disableAccessibilityChecks();
         }
         try {
-            return info.impl.getJavacTask().attributeTreeTo((JCTree)tree, ((JavacScope)scope).getEnv(), (JCTree)to);
+            return attributeTreeTo(info.impl.getJavacTask(), (JCTree)tree, scope, (JCTree)to, new ArrayList<>());
         } finally {
             NBResolve.instance(info.impl.getJavacTask().getContext()).restoreAccessbilityChecks();
         }
     }
     
     public TypeMirror reattributeTree(Tree tree, Scope scope) {
-        Env<AttrContext> env = ((JavacScope)scope).getEnv();
+        Env<AttrContext> env = getEnv(scope);
         copyInnerClassIndexes(env.tree, tree);
         if (scope instanceof NBScope && ((NBScope)scope).areAccessibilityChecksDisabled()) {
             NBResolve.instance(info.impl.getJavacTask().getContext()).disableAccessibilityChecks();
         }
         try {
-            return info.impl.getJavacTask().attributeTree((JCTree)tree, env);
+            return attributeTree(info.impl.getJavacTask(), (JCTree)tree, scope, new ArrayList<>());
         } finally {
             NBResolve.instance(info.impl.getJavacTask().getContext()).restoreAccessbilityChecks();
         }
     }
     
     public Scope reattributeTreeTo(Tree tree, Scope scope, Tree to) {
-        Env<AttrContext> env = ((JavacScope)scope).getEnv();
+        Env<AttrContext> env = getEnv(scope);
         copyInnerClassIndexes(env.tree, tree);
         if (scope instanceof NBScope && ((NBScope)scope).areAccessibilityChecksDisabled()) {
             NBResolve.instance(info.impl.getJavacTask().getContext()).disableAccessibilityChecks();
         }
         try {
-            return info.impl.getJavacTask().attributeTreeTo((JCTree)tree, env, (JCTree)to);
+            return attributeTreeTo(info.impl.getJavacTask(), (JCTree)tree, scope, (JCTree)to, new ArrayList<>());
         } finally {
             NBResolve.instance(info.impl.getJavacTask().getContext()).restoreAccessbilityChecks();
         }
     }
     
+    //from org/netbeans/modules/java/hints/spiimpl/Utilities.java:
+    private static TypeMirror attributeTree(JavacTaskImpl jti, Tree tree, Scope scope, final List<Diagnostic<? extends JavaFileObject>> errors) {
+        Log log = Log.instance(jti.getContext());
+        JavaFileObject prev = log.useSource(new DummyJFO());
+        Log.DiagnosticHandler discardHandler = new Log.DiscardDiagnosticHandler(log) {
+            @Override
+            public void report(JCDiagnostic diag) {
+                errors.add(diag);
+            }            
+        };
+        NBResolve resolve = NBResolve.instance(jti.getContext());
+        resolve.disableAccessibilityChecks();
+//        Enter enter = Enter.instance(jti.getContext());
+//        enter.shadowTypeEnvs(true);
+//        ArgumentAttr argumentAttr = ArgumentAttr.instance(jti.getContext());
+//        ArgumentAttr.LocalCacheContext cacheContext = argumentAttr.withLocalCacheContext();
+        try {
+            Attr attr = Attr.instance(jti.getContext());
+            Env<AttrContext> env = getEnv(scope);
+            if (tree instanceof JCExpression)
+                return attr.attribExpr((JCTree) tree,env, Type.noType);
+            return attr.attribStat((JCTree) tree,env);
+        } finally {
+//            cacheContext.leave();
+            log.useSource(prev);
+            log.popDiagnosticHandler(discardHandler);
+            resolve.restoreAccessbilityChecks();
+//            enter.shadowTypeEnvs(false);
+        }
+    }
+
+    private static Scope attributeTreeTo(JavacTaskImpl jti, Tree tree, Scope scope, Tree to, final List<Diagnostic<? extends JavaFileObject>> errors) {
+        Log log = Log.instance(jti.getContext());
+        JavaFileObject prev = log.useSource(new DummyJFO());
+        Log.DiagnosticHandler discardHandler = new Log.DiscardDiagnosticHandler(log) {
+            @Override
+            public void report(JCDiagnostic diag) {
+                errors.add(diag);
+            }            
+        };
+        NBResolve resolve = NBResolve.instance(jti.getContext());
+        resolve.disableAccessibilityChecks();
+//        Enter enter = Enter.instance(jti.getContext());
+//        enter.shadowTypeEnvs(true);
+//        ArgumentAttr argumentAttr = ArgumentAttr.instance(jti.getContext());
+//        ArgumentAttr.LocalCacheContext cacheContext = argumentAttr.withLocalCacheContext();
+        try {
+            Attr attr = Attr.instance(jti.getContext());
+            Env<AttrContext> env = getEnv(scope);
+            Env<AttrContext> result = tree instanceof JCExpression ?
+                attr.attribExprToTree((JCExpression) tree, env, (JCTree) to) :
+                attr.attribStatToTree((JCTree) tree, env, (JCTree) to);
+            try {
+                Constructor<JavacScope> c = JavacScope.class.getDeclaredConstructor(Env.class);
+                c.setAccessible(true);
+                return c.newInstance(result);
+            } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
+                throw new IllegalStateException(ex);
+            }
+        } finally {
+//            cacheContext.leave();
+            log.useSource(prev);
+            log.popDiagnosticHandler(discardHandler);
+            resolve.restoreAccessbilityChecks();
+//            enter.shadowTypeEnvs(false);
+        }
+    }
+
     /**Returns tokens for a given tree.
      */
     public TokenSequence<JavaTokenId> tokensFor(Tree tree) {
@@ -764,7 +924,7 @@ public boolean isAccessible(Scope scope, Element member, TypeMirror type) {
     /**Checks whether the given scope is in "static" context.
      */
     public boolean isStaticContext(Scope scope) {
-        return Resolve.instance(info.impl.getJavacTask().getContext()).isStatic(((JavacScope)scope).getEnv());
+        return NBResolve.isStatic(getEnv(scope));
     }
     
     /**Returns uncaught exceptions inside the given tree path.
@@ -797,7 +957,7 @@ public boolean isStaticContext(Scope scope) {
                 fields.add(ve);
             }
         }
-        new TreePathScanner<Void, Boolean>() {
+        new ErrorAwareTreePathScanner<Void, Boolean>() {
             @Override
             public Void visitAssignment(AssignmentTree node, Boolean p) {
                 Element el = trees.getElement(new TreePath(getCurrentPath(), node.getVariable()));
@@ -1454,7 +1614,7 @@ public void setPackage(ExpressionTree packageNameTree) {}
     
     private void copyInnerClassIndexes(Tree from, Tree to) {
         final int[] fromIdx = {-3};
-        TreeScanner<Void, Void> scanner = new TreeScanner<Void, Void>() {
+        ErrorAwareTreeScanner<Void, Void> scanner = new ErrorAwareTreeScanner<Void, Void>() {
             @Override
             public Void scan(Tree node, Void p) {
                 return fromIdx[0] < -1 ? super.scan(node, p) : null;
@@ -1486,7 +1646,7 @@ public Void visitBlock(BlockTree node, Void p) {
         scanner.scan(from, null);
         if (fromIdx[0] < -1)
             return;
-        scanner = new TreeScanner<Void, Void>() {
+        scanner = new ErrorAwareTreeScanner<Void, Void>() {
             @Override
             public Void visitClass(ClassTree node, Void p) {
                 ((IndexedClassDecl)node).index = fromIdx[0]++;
@@ -1496,7 +1656,7 @@ public Void visitClass(ClassTree node, Void p) {
         scanner.scan(to, null);
     }
 
-    private static class UncaughtExceptionsVisitor extends TreePathScanner<Void, Set<TypeMirror>> {
+    private static class UncaughtExceptionsVisitor extends ErrorAwareTreePathScanner<Void, Set<TypeMirror>> {
         
         private final CompilationInfo info;
         
@@ -1657,7 +1817,9 @@ public boolean isCompileTimeConstantExpression(TreePath expression) {
         TreePath tp = path.getTreePath();
         DCReference ref = (DCReference) path.getLeaf();
         
-        ((JavacTrees) this.info.getTrees()).ensureDocReferenceAttributed(tp, ref);
+        ((DocTrees) this.info.getTrees()).getElement(path);
+//        was:
+//        ((JavacTrees) this.info.getTrees()).ensureDocReferenceAttributed(tp, ref);
         
         return (ExpressionTree) ref.qualifierExpression;
     }
@@ -1682,19 +1844,53 @@ public boolean isCompileTimeConstantExpression(TreePath expression) {
         TreePath tp = path.getTreePath();
         DCReference ref = (DCReference) path.getLeaf();
         
-        ((JavacTrees) this.info.getTrees()).ensureDocReferenceAttributed(tp, ref);
+        ((DocTrees) this.info.getTrees()).getElement(path);
+//        was:
+//        ((JavacTrees) this.info.getTrees()).ensureDocReferenceAttributed(tp, ref);
         
         return ref.paramTypes;
     }
     
-    private static final class NBScope extends JavacScope {
+    private static final class NBScope implements Scope {
 
-        private NBScope(JavacScope scope) {
-            super(scope.getEnv());
+        private final JavacScope delegate;
+
+        private NBScope(JavacScope delegate) {
+            this.delegate = delegate;
         }
         
         private boolean areAccessibilityChecksDisabled() {
             return true;
         }
+
+        @Override
+        public Scope getEnclosingScope() {
+            //TODO: wrap?
+            return delegate.getEnclosingScope();
+        }
+
+        @Override
+        public TypeElement getEnclosingClass() {
+            return delegate.getEnclosingClass();
+        }
+
+        @Override
+        public ExecutableElement getEnclosingMethod() {
+            return delegate.getEnclosingMethod();
+        }
+
+        @Override
+        public Iterable<? extends Element> getLocalElements() {
+            return delegate.getLocalElements();
+        }
+    }
+
+    static {
+        TreeUtilitiesAccessor.setInstance(new TreeUtilitiesAccessor() {
+            @Override
+            public StatementTree parseStatement(JavacTaskImpl task, String stmt, SourcePositions[] sourcePositions) {
+                return parseStatementImpl(task, stmt, sourcePositions);
+            }
+        });
     }
 }
diff --git a/java.source.base/src/org/netbeans/api/java/source/TypeUtilities.java b/java.source.base/src/org/netbeans/api/java/source/TypeUtilities.java
index d145fd48d..7093b9345 100644
--- a/java.source.base/src/org/netbeans/api/java/source/TypeUtilities.java
+++ b/java.source.base/src/org/netbeans/api/java/source/TypeUtilities.java
@@ -29,6 +29,7 @@
 import java.util.Arrays;
 import java.util.EnumSet;
 import java.util.Iterator;
+import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
 import javax.lang.model.element.Element;
@@ -169,7 +170,7 @@ public TypeMirror getDenotableType(TypeMirror type) {
         } else if (tk == TypeKind.NONE || tk == TypeKind.OTHER) {
             return types.createErrorType(inType);
         }
-        Type t = types.upward(inType, types.captures(inType));
+        Type t = (Type) resolveCapturedType(info, type);
         if (t == null) {
             return types.createErrorType(inType);
         }
@@ -240,6 +241,108 @@ public Boolean visitWildcardType(Type.WildcardType t, Void s) {
         }
     };
 
+    //from java.hints/src/org/netbeans/modules/java/hints/errors/Utilities.java:
+    private static TypeMirror resolveCapturedType(CompilationInfo info, TypeMirror tm) {
+        if (tm == null) {
+            return tm;
+        }
+        if (tm.getKind() == TypeKind.ERROR) {
+            tm = info.getTrees().getOriginalType((ErrorType) tm);
+        }
+        TypeMirror type = resolveCapturedTypeInt(info, tm);
+        if (type == null) {
+            return tm;
+        }
+        if (type.getKind() == TypeKind.WILDCARD) {
+            TypeMirror tmirr = ((WildcardType) type).getExtendsBound();
+            if (tmirr != null)
+                return tmirr;
+            else { //no extends, just '?'
+                TypeElement te = info.getElements().getTypeElement("java.lang.Object"); // NOI18N
+                return te == null ? null : te.asType();
+            }
+                
+        }
+        
+        return type;
+    }
+    
+    /**
+     * Note: may return {@code null}, if an intersection type is encountered, to indicate a 
+     * real type cannot be created.
+     */
+    private static TypeMirror resolveCapturedTypeInt(CompilationInfo info, TypeMirror tm) {
+        if (tm == null) return tm;
+        
+        TypeMirror orig = SourceUtils.resolveCapturedType(tm);
+
+        if (orig != null) {
+            tm = orig;
+        }
+        
+        if (tm.getKind() == TypeKind.WILDCARD) {
+            TypeMirror extendsBound = ((WildcardType) tm).getExtendsBound();
+            TypeMirror superBound = ((WildcardType) tm).getSuperBound();
+            if (extendsBound != null || superBound != null) {
+                TypeMirror rct = resolveCapturedTypeInt(info, extendsBound != null ? extendsBound : superBound);
+                if (rct != null) {
+                    switch (rct.getKind()) {
+                        case WILDCARD:
+                            return rct;
+                        case ARRAY:
+                        case DECLARED:
+                        case ERROR:
+                        case TYPEVAR:
+                        case OTHER:
+                            return info.getTypes().getWildcardType(
+                                    extendsBound != null ? rct : null, superBound != null ? rct : null);
+                    }
+                } else {
+                    // propagate failure out of all wildcards
+                    return null;
+                }
+            }
+        } else if (tm.getKind() == TypeKind.INTERSECTION) {
+            return null;
+        }
+        
+        if (tm.getKind() == TypeKind.DECLARED) {
+            DeclaredType dt = (DeclaredType) tm;
+            List<TypeMirror> typeArguments = new LinkedList<TypeMirror>();
+            
+            for (TypeMirror t : dt.getTypeArguments()) {
+                TypeMirror targ = resolveCapturedTypeInt(info, t);
+                if (targ == null) {
+                    // bail out, if the type parameter is a wildcard, it's probably not possible
+                    // to create a proper parametrized type from it
+                    if (t.getKind() == TypeKind.WILDCARD || t.getKind() == TypeKind.INTERSECTION) {
+                        return null;
+                    }
+                    // use rawtype
+                    typeArguments.clear();
+                    break;
+                }
+                typeArguments.add(targ);
+            }
+            
+            final TypeMirror enclosingType = dt.getEnclosingType();
+            if (enclosingType.getKind() == TypeKind.DECLARED) {
+                return info.getTypes().getDeclaredType((DeclaredType) enclosingType, (TypeElement) dt.asElement(), typeArguments.toArray(new TypeMirror[0]));
+            } else {
+                if (dt.asElement() == null) return dt;
+                return info.getTypes().getDeclaredType((TypeElement) dt.asElement(), typeArguments.toArray(new TypeMirror[0]));
+            }
+        }
+
+        if (tm.getKind() == TypeKind.ARRAY) {
+            ArrayType at = (ArrayType) tm;
+            TypeMirror tm2 = resolveCapturedTypeInt(info, at.getComponentType());
+            return info.getTypes().getArrayType(tm2 != null ? tm2 : tm);
+        }
+        
+        return tm;
+    }
+
     /**Options for the {@link #getTypeName(javax.lang.model.type.TypeMirror, org.netbeans.api.java.source.TypeUtilities.TypeNameOptions[]) } method.
      * @since 0.62
      */
diff --git a/java.source.base/src/org/netbeans/api/java/source/WorkingCopy.java b/java.source.base/src/org/netbeans/api/java/source/WorkingCopy.java
index 841c14e2c..ff8bc89c2 100644
--- a/java.source.base/src/org/netbeans/api/java/source/WorkingCopy.java
+++ b/java.source.base/src/org/netbeans/api/java/source/WorkingCopy.java
@@ -32,8 +32,8 @@
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.util.Context;
 
@@ -66,9 +66,11 @@
 import com.sun.source.tree.TryTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.DocTrees;
+
 import java.util.Collection;
 import java.util.Comparator;
 
+import com.sun.tools.javac.parser.ParserFactory;
 import org.netbeans.api.annotations.common.NonNull;
 import org.netbeans.api.annotations.common.NullAllowed;
 import org.netbeans.api.annotations.common.NullUnknown;
@@ -85,6 +87,7 @@
 import org.netbeans.modules.java.source.builder.TreeFactory;
 import org.netbeans.modules.java.source.parsing.CompilationInfoImpl;
 import org.netbeans.modules.java.source.parsing.FileObjects;
+import org.netbeans.modules.java.source.parsing.ParsingUtils;
 import org.netbeans.modules.java.source.pretty.ImportAnalysis2;
 import org.netbeans.modules.java.source.query.CommentSet.RelativePosition;
 import org.netbeans.modules.java.source.save.CasualDiff;
@@ -275,7 +278,7 @@ boolean validateIsReplacement(Tree t) {
         return ok || introducedTrees.containsKey(t);
     }
     
-    private static class TreeCollector extends TreeScanner {
+    private static class TreeCollector extends ErrorAwareTreeScanner {
         private final Map<Tree, Boolean> collectTo;
         private final boolean add;
 
@@ -577,7 +580,7 @@ private void addSyntheticTrees(DiffContext diffContext, Tree node) {
 
         final Map<Tree, Boolean> presentInResult = new IdentityHashMap<Tree, Boolean>();
         if (CasualDiff.OLD_TREES_VERBATIM) {
-            new TreeScanner<Void, Void>() {
+            new ErrorAwareTreeScanner<Void, Void>() {
                 private boolean synthetic = false;
                 @Override
                 public Void scan(Tree node, Void p) {
@@ -624,7 +627,7 @@ public Void visitTry(TryTree node, Void p) {
                 
             }.scan(diffContext.origUnit, null);
         } else {
-            new TreeScanner<Void, Void>() {
+            new ErrorAwareTreeScanner<Void, Void>() {
                 @Override
                 public Void scan(Tree node, Void p) {
                     addSyntheticTrees(diffContext, node);
@@ -635,7 +638,7 @@ public Void scan(Tree node, Void p) {
         }
 
         if (!REWRITE_WHOLE_FILE) {
-            new TreePathScanner<Void, Void>() {
+            new ErrorAwareTreePathScanner<Void, Void>() {
                 private TreePath currentParent;
                 private final Map<Tree, TreePath> tree2Path = new IdentityHashMap<Tree, TreePath>();
                 private final FQNComputer fqn = new FQNComputer();
@@ -1031,7 +1034,7 @@ private void addPresentInResult(Map<Tree, Boolean> present, Tree t, boolean mark
      * <li>copies comments from a tree to an associated tree
      * <li>
      */
-    private class CommentReplicator extends TreePathScanner<Object, Object> {
+    private class CommentReplicator extends ErrorAwareTreePathScanner<Object, Object> {
         private final Set<Tree>   stillPresent;
         
         private boolean collectCommentsFromRemovedNodes;
@@ -1188,7 +1191,7 @@ private Tree resolveRewriteHint(Tree orig) {
         for (CompilationUnitTree t : externalChanges.values()) {
             try {
                 FileObject targetFile = doCreateFromTemplate(t);
-                CompilationUnitTree templateCUT = impl.getJavacTask().parse(FileObjects.sourceFileObject(targetFile, targetFile.getParent())).iterator().next();
+                CompilationUnitTree templateCUT = ParsingUtils.parseArbitrarySource(impl.getJavacTask(), FileObjects.sourceFileObject(targetFile, targetFile.getParent()));
                 CompilationUnitTree importComments = GeneratorUtilities.get(this).importComments(templateCUT, templateCUT);
 
                 rewrite(importComments, getTreeMaker().asRemoved(t));
@@ -1296,7 +1299,7 @@ FileObject doCreateFromTemplate(FileObject template, JavaFileObject sourceFile)
                 fqn.setCompilationUnit(t);
                 overlay.registerPackage(fqn.getFQN());
 
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitClass(ClassTree node, Void p) {
                         String parent = fqn.getFQN();
diff --git a/java.source.base/src/org/netbeans/api/java/source/support/CancellableTreePathScanner.java b/java.source.base/src/org/netbeans/api/java/source/support/CancellableTreePathScanner.java
index 826b4d5ff..9be8c7e65 100644
--- a/java.source.base/src/org/netbeans/api/java/source/support/CancellableTreePathScanner.java
+++ b/java.source.base/src/org/netbeans/api/java/source/support/CancellableTreePathScanner.java
@@ -19,14 +19,14 @@
 package org.netbeans.api.java.source.support;
 
 import com.sun.source.tree.Tree;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 /**
  *
  * @author Jan Lahoda
  */
-public class CancellableTreePathScanner<R,P> extends TreePathScanner<R,P> {
+public class CancellableTreePathScanner<R,P> extends ErrorAwareTreePathScanner<R,P> {
 
     private final AtomicBoolean internalCanceled;
     private final AtomicBoolean canceled;
diff --git a/java.source.base/src/org/netbeans/api/java/source/support/CancellableTreeScanner.java b/java.source.base/src/org/netbeans/api/java/source/support/CancellableTreeScanner.java
index ec7bd9062..6693e63a2 100644
--- a/java.source.base/src/org/netbeans/api/java/source/support/CancellableTreeScanner.java
+++ b/java.source.base/src/org/netbeans/api/java/source/support/CancellableTreeScanner.java
@@ -19,14 +19,14 @@
 package org.netbeans.api.java.source.support;
 
 import com.sun.source.tree.Tree;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 /**
  *
  * @author Jan Lahoda
  */
-public class CancellableTreeScanner<R,P> extends TreeScanner<R,P> {
+public class CancellableTreeScanner<R,P> extends ErrorAwareTreeScanner<R,P> {
 
     private final AtomicBoolean internalCanceled;
     private final AtomicBoolean canceled;
diff --git a/java.source.base/src/org/netbeans/api/java/source/support/ErrorAwareTreePathScanner.java b/java.source.base/src/org/netbeans/api/java/source/support/ErrorAwareTreePathScanner.java
new file mode 100644
index 000000000..a04e544e5
--- /dev/null
+++ b/java.source.base/src/org/netbeans/api/java/source/support/ErrorAwareTreePathScanner.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.api.java.source.support;
+
+import com.sun.source.tree.ErroneousTree;
+import com.sun.source.util.TreePathScanner;
+
+/**
+ *
+ * @author Jan Lahoda
+ */
+public class ErrorAwareTreePathScanner<R,P> extends TreePathScanner<R,P> {
+
+    @Override
+    public R visitErroneous(ErroneousTree et, P p) {
+        return scan(et.getErrorTrees(), p);
+    }
+
+}
diff --git a/java.source.base/src/org/netbeans/api/java/source/support/ErrorAwareTreeScanner.java b/java.source.base/src/org/netbeans/api/java/source/support/ErrorAwareTreeScanner.java
new file mode 100644
index 000000000..eebbcb533
--- /dev/null
+++ b/java.source.base/src/org/netbeans/api/java/source/support/ErrorAwareTreeScanner.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.api.java.source.support;
+
+import com.sun.source.tree.ErroneousTree;
+import com.sun.source.util.TreeScanner;
+
+/**
+ *
+ * @author Jan Lahoda
+ */
+public class ErrorAwareTreeScanner<R,P> extends TreeScanner<R,P> {
+
+    @Override
+    public R visitErroneous(ErroneousTree et, P p) {
+        return scan(et.getErrorTrees(), p);
+    }
+
+}
diff --git a/java.source.base/src/org/netbeans/modules/java/source/CompilationInfoAccessor.java b/java.source.base/src/org/netbeans/modules/java/source/CompilationInfoAccessor.java
new file mode 100644
index 000000000..efe5d7f3c
--- /dev/null
+++ b/java.source.base/src/org/netbeans/modules/java/source/CompilationInfoAccessor.java
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.source;
+
+import com.sun.source.util.JavacTask;
+import org.netbeans.api.java.source.CompilationInfo;
+
+/**
+ *
+ * @author lahvac
+ */
+public abstract class CompilationInfoAccessor {
+    
+    private static volatile CompilationInfoAccessor INSTANCE;
+
+    public static CompilationInfoAccessor getInstance() {
+        CompilationInfoAccessor result = INSTANCE;
+        
+        if (result == null) {
+            synchronized (CompilationInfoAccessor.class) {
+                if (INSTANCE == null) {
+                    Class c = CompilationInfo.class;
+                    try {
+                        Class.forName(c.getName(), true, c.getClassLoader());
+                    } catch (Exception ex) {
+                        ex.printStackTrace();
+                    }
+                    
+                    assert INSTANCE != null;
+                }
+                
+                return INSTANCE;
+            }
+        }
+        
+        return result;
+    }
+    
+    public static void setInstance(CompilationInfoAccessor instance) {
+        assert instance != null;
+        INSTANCE = instance;
+    }
+
+    protected CompilationInfoAccessor() {
+    }
+    
+    public abstract JavacTask getJavacTask(CompilationInfo info);
+
+}
diff --git a/java.source.base/src/org/netbeans/modules/java/source/ElementUtils.java b/java.source.base/src/org/netbeans/modules/java/source/ElementUtils.java
new file mode 100644
index 000000000..757bc5724
--- /dev/null
+++ b/java.source.base/src/org/netbeans/modules/java/source/ElementUtils.java
@@ -0,0 +1,94 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.source;
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.code.Kinds.Kind;
+import com.sun.tools.javac.code.Symbol;
+import com.sun.tools.javac.code.Symbol.ClassSymbol;
+import com.sun.tools.javac.code.Symbol.CompletionFailure;
+import com.sun.tools.javac.code.Symbol.ModuleSymbol;
+import com.sun.tools.javac.code.Symtab;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Name;
+import com.sun.tools.javac.util.Names;
+import java.util.Set;
+import javax.lang.model.element.ModuleElement;
+import javax.lang.model.element.TypeElement;
+import org.netbeans.api.java.source.CompilationInfo;
+
+/** TODO
+ *
+ * @author lahvac
+ */
+public class ElementUtils {
+
+    public static TypeElement getTypeElementByBinaryName(CompilationInfo info, String name) {
+        return getTypeElementByBinaryName(CompilationInfoAccessor.getInstance().getJavacTask(info), name);
+    }
+
+    public static TypeElement getTypeElementByBinaryName(JavacTask task, String name) {
+        Set<? extends ModuleElement> allModules = task.getElements().getAllModuleElements();
+        
+        if (allModules.isEmpty()) {
+            Context ctx = ((JavacTaskImpl) task).getContext();
+            Symtab syms = Symtab.instance(ctx);
+            
+            return getTypeElementByBinaryName(task, syms.noModule, name);
+        }
+        
+        TypeElement result = null;
+        
+        for (ModuleElement me : allModules) {
+            TypeElement found = getTypeElementByBinaryName(task, me, name);
+            
+            if (found != null) {
+                if (result != null) return null;
+                result = found;
+            }
+        }
+        
+        return result;
+    }
+
+    public static TypeElement getTypeElementByBinaryName(CompilationInfo info, ModuleElement mod, String name) {
+        return getTypeElementByBinaryName(CompilationInfoAccessor.getInstance().getJavacTask(info), mod, name);
+    }
+
+    public static TypeElement getTypeElementByBinaryName(JavacTask task, ModuleElement mod, String name) {
+        Context ctx = ((JavacTaskImpl) task).getContext();
+        Names names = Names.instance(ctx);
+        Symtab syms = Symtab.instance(ctx);
+        final Name wrappedName = names.fromString(name);
+        ClassSymbol clazz = syms.enterClass((ModuleSymbol) mod, wrappedName);
+        
+        try {
+            clazz.complete();
+            
+            if (clazz.kind == Kind.TYP &&
+                clazz.flatName() == wrappedName) {
+                return clazz;
+            }
+        } catch (CompletionFailure cf) {
+        }
+
+        return null;
+    }
+}
diff --git a/java.source.base/src/org/netbeans/modules/java/source/JavaSourceUtilImpl.java b/java.source.base/src/org/netbeans/modules/java/source/JavaSourceUtilImpl.java
index 4138bf5dc..6c6b060fc 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/JavaSourceUtilImpl.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/JavaSourceUtilImpl.java
@@ -24,8 +24,7 @@
 import com.sun.source.tree.ModuleTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import com.sun.tools.javac.code.ClassFinder;
 import com.sun.tools.javac.code.Symbol;
@@ -39,6 +38,7 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.URI;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -223,11 +223,11 @@ protected long createTaggedCompilationController(FileObject file, long currenTag
                     r.getProfile(),
                     null,
                     null,
-                    null,
                     aptUtils,
-                    null);
+                    null,
+                    Arrays.asList(toCompile));
             final Iterable<? extends JavaFileObject> generated = jt.generate(
-                    StreamSupport.stream(jt.analyze(jt.enter(jt.parse(toCompile))).spliterator(), false)
+                    StreamSupport.stream(jt.analyze(jt.enter(jt.parse())).spliterator(), false)
                             .filter((e) -> e.getKind().isClass() || e.getKind().isInterface())
                             .map((e) -> (TypeElement)e)
                             .collect(Collectors.toList()));
@@ -286,7 +286,7 @@ public String parseModuleName() throws IOException {
                     @CheckForNull
                     public ModuleTree parseModule() throws IOException {
                         cc.toPhase(JavaSource.Phase.PARSED);
-                        final TreeScanner<ModuleTree, Void> scanner = new TreeScanner<ModuleTree, Void>() {
+                        final ErrorAwareTreeScanner<ModuleTree, Void> scanner = new ErrorAwareTreeScanner<ModuleTree, Void>() {
                             @Override
                             public ModuleTree visitModule(ModuleTree node, Void p) {
                                 return node;
diff --git a/java.source.base/src/org/netbeans/modules/java/source/JavadocEnv.java b/java.source.base/src/org/netbeans/modules/java/source/JavadocEnv.java
index 97434a87c..1de5a759b 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/JavadocEnv.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/JavadocEnv.java
@@ -44,8 +44,12 @@
 import com.sun.tools.javadoc.main.MethodDocImpl;
 import com.sun.tools.javadoc.main.ModifierFilter;
 import com.sun.tools.javadoc.main.PackageDocImpl;
+import com.sun.tools.javadoc.main.ProgramElementDocImpl;
 import java.io.IOException;
+import java.lang.reflect.Method;
 import java.util.StringTokenizer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import javax.lang.model.element.Element;
 import org.netbeans.api.java.source.Task;
 import org.netbeans.api.java.source.ClasspathInfo;
@@ -105,7 +109,7 @@ protected void makeClassDoc(ClassSymbol clazz, TreePath treePath) {
         }
         ClassDocImpl result = classMap.get(clazz);
         if (result != null) {
-            if (treePath != null) result.setTreePath(treePath);
+            if (treePath != null) setTreePath(result, treePath);
             return;
         }
         if (isAnnotationType((JCClassDecl)treePath.getLeaf())) {	// flags of clazz may not yet be set
@@ -129,7 +133,7 @@ public FieldDocImpl getFieldDoc(VarSymbol var) {
     protected void makeFieldDoc(VarSymbol var, TreePath treePath) {
         FieldDocImpl result = fieldMap.get(var);
         if (result != null) {
-            if (treePath != null) result.setTreePath(treePath);
+            if (treePath != null) setTreePath(result, treePath);
         } else {
             result = new JavadocField(this, var, treePath);
             fieldMap.put(var, result);
@@ -152,7 +156,7 @@ public MethodDocImpl getMethodDoc(MethodSymbol meth) {
     protected void makeMethodDoc(MethodSymbol meth, TreePath treePath) {
         MethodDocImpl result = (MethodDocImpl)methodMap.get(meth);
         if (result != null) {
-            if (treePath != null) result.setTreePath(treePath);
+            if (treePath != null) setTreePath(result, treePath);
         } else {
             result = new JavadocMethod(this, meth, treePath);
             methodMap.put(meth, result);
@@ -175,7 +179,7 @@ public ConstructorDocImpl getConstructorDoc(MethodSymbol meth) {
     protected void makeConstructorDoc(MethodSymbol meth, TreePath treePath) {
         ConstructorDocImpl result = (ConstructorDocImpl)methodMap.get(meth);
         if (result != null) {
-            if (treePath != null) result.setTreePath(treePath);
+            if (treePath != null) setTreePath(result, treePath);
         } else {
             result = new JavadocConstructor(this, meth, treePath);
             methodMap.put(meth, result);
@@ -198,12 +202,22 @@ public AnnotationTypeElementDocImpl getAnnotationTypeElementDoc(MethodSymbol met
     protected void makeAnnotationTypeElementDoc(MethodSymbol meth, TreePath treePath) {
         AnnotationTypeElementDocImpl result = (AnnotationTypeElementDocImpl)methodMap.get(meth);
         if (result != null) {
-            if (treePath != null) result.setTreePath(treePath);
+            if (treePath != null) setTreePath(result, treePath);
         } else {
             result = new JavadocAnnotationTypeElement(this, meth, treePath);
             methodMap.put(meth, result);
         }
     }
+    
+    private void setTreePath(ProgramElementDocImpl pe, TreePath treePath) {
+        try {
+            Method setTreePath = ProgramElementDocImpl.class.getDeclaredMethod("setTreePath", TreePath.class);
+            setTreePath.setAccessible(true);
+            setTreePath.invoke(pe, treePath);
+        } catch (Throwable ex) {
+            Logger.getLogger(JavadocEnv.class.getName()).log(Level.FINE, null, ex);
+        }
+    }
 
     /**
      * Return the AnnotationTypeElementDoc for a MethodSymbol.
diff --git a/java.source.base/src/org/netbeans/modules/java/source/ModuleNames.java b/java.source.base/src/org/netbeans/modules/java/source/ModuleNames.java
index 16038fcce..8073c10e6 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/ModuleNames.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/ModuleNames.java
@@ -281,13 +281,12 @@ public static String parseModuleName(
                 null,
                 null,
                 null,
-                null);
-        try {
-            final CompilationUnitTree cu =  jt.parse(FileObjects.fileObjectFileObject(
+                Collections.singletonList(FileObjects.fileObjectFileObject(
                     moduleInfo,
                     moduleInfo.getParent(),
                     null,
-                    FileEncodingQuery.getEncoding(moduleInfo))).iterator().next();
+                    FileEncodingQuery.getEncoding(moduleInfo))));
+            final CompilationUnitTree cu =  jt.parse().iterator().next();
             final List<? extends Tree> typeDecls = cu.getTypeDecls();
             if (!typeDecls.isEmpty()) {
                 final Tree typeDecl = typeDecls.get(0);
@@ -295,9 +294,6 @@ public static String parseModuleName(
                     return ((ModuleTree)typeDecl).getName().toString();
                 }
             }
-        } catch (IOException ioe) {
-            Exceptions.printStackTrace(ioe);
-        }
         return null;
     }
 
diff --git a/java.source.base/src/org/netbeans/modules/java/source/NoJavacHelper.java b/java.source.base/src/org/netbeans/modules/java/source/NoJavacHelper.java
new file mode 100644
index 000000000..d60f6a874
--- /dev/null
+++ b/java.source.base/src/org/netbeans/modules/java/source/NoJavacHelper.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.source;
+
+import java.lang.reflect.Field;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.objectweb.asm.ClassWriter;
+import org.objectweb.asm.Opcodes;
+import org.openide.modules.OnStart;
+import sun.misc.Unsafe;
+
+/**
+ *
+ * @author lahvac
+ */
+public class NoJavacHelper {
+
+    public static boolean hasWorkingJavac() {
+        try {
+            Class.forName("javax.lang.model.element.ModuleElement");
+            return true;
+        } catch (ClassNotFoundException ex) {
+            //OK
+            return false;
+        }
+    }
+
+    public static boolean hasNbJavac() {
+        try {
+            Class.forName("com.sun.tools.javac.comp.Repair");
+            return true;
+        } catch (ClassNotFoundException ex) {
+            //OK
+            return false;
+        }
+    }
+
+    @OnStart
+    public static class FixClasses implements Runnable {
+
+        @Override
+        public void run() {
+            if (!hasWorkingJavac()) {
+                ClassWriter w = new ClassWriter(0);
+                w.visit(Opcodes.V1_8, Opcodes.ACC_ABSTRACT | Opcodes.ACC_PUBLIC, "com/sun/tools/javac/code/Scope$WriteableScope", null, "com/sun/tools/javac/code/Scope", null);
+                byte[] classData = w.toByteArray();
+                try {
+                    Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
+                    theUnsafe.setAccessible(true);
+                    Unsafe unsafe = (Unsafe) theUnsafe.get(null);
+                    Class scopeClass = Class.forName("com.sun.tools.javac.code.Scope");
+                    unsafe.defineClass("com.sun.tools.javac.code.Scope$WriteableScope", classData, 0, classData.length, scopeClass.getClassLoader(), scopeClass.getProtectionDomain());
+                } catch (Throwable t) {
+                    //ignore...
+                    Logger.getLogger(NoJavacHelper.class.getName()).log(Level.FINE, null, t);
+                }
+            }
+        }
+
+    }
+}
diff --git a/java.source.base/src/org/netbeans/modules/java/source/PostFlowAnalysis.java b/java.source.base/src/org/netbeans/modules/java/source/PostFlowAnalysis.java
index fb9be503a..edf0f3137 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/PostFlowAnalysis.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/PostFlowAnalysis.java
@@ -160,7 +160,7 @@ public void visitMethodDef(JCMethodDecl tree) {
     public void visitNewClass(JCNewClass tree) {
         super.visitNewClass(tree);
         Symbol c = tree.constructor != null ? tree.constructor.owner : null;
-        if (c != null && c.hasOuterInstance()) {
+        if (c != null && c != syms.noSymbol && c.hasOuterInstance()) {
             if (tree.encl == null && c.isLocal()) {
                 checkThis(tree.pos(), c.type.getEnclosingType().tsym);
             }
diff --git a/java.source.base/src/org/netbeans/modules/java/source/TreeUtilitiesAccessor.java b/java.source.base/src/org/netbeans/modules/java/source/TreeUtilitiesAccessor.java
new file mode 100644
index 000000000..a6c3350ec
--- /dev/null
+++ b/java.source.base/src/org/netbeans/modules/java/source/TreeUtilitiesAccessor.java
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.source;
+
+import com.sun.source.tree.StatementTree;
+import com.sun.source.util.SourcePositions;
+import com.sun.tools.javac.api.JavacTaskImpl;
+import org.netbeans.api.java.source.TreeUtilities;
+
+/**
+ *
+ * @author lahvac
+ */
+public abstract class TreeUtilitiesAccessor {
+
+    private static volatile TreeUtilitiesAccessor INSTANCE;
+
+    public static TreeUtilitiesAccessor getInstance() {
+        TreeUtilitiesAccessor result = INSTANCE;
+
+        if (result == null) {
+            synchronized (TreeUtilitiesAccessor.class) {
+                if (INSTANCE == null) {
+                    Class c = TreeUtilities.class;
+                    try {
+                        Class.forName(c.getName(), true, c.getClassLoader());
+                    } catch (Exception ex) {
+                        ex.printStackTrace();
+                    }
+                    
+                    assert INSTANCE != null;
+                }
+
+                return INSTANCE;
+            }
+        }
+
+        return result;
+    }
+
+    public static void setInstance(TreeUtilitiesAccessor instance) {
+        assert instance != null;
+        INSTANCE = instance;
+    }
+
+    protected TreeUtilitiesAccessor() {
+    }
+
+    public abstract StatementTree parseStatement(JavacTaskImpl task, String stmt, SourcePositions[] sourcePositions);
+
+}
diff --git a/java.source.base/src/org/netbeans/modules/java/source/base/SourceLevelUtils.java b/java.source.base/src/org/netbeans/modules/java/source/base/SourceLevelUtils.java
new file mode 100644
index 000000000..7365c109d
--- /dev/null
+++ b/java.source.base/src/org/netbeans/modules/java/source/base/SourceLevelUtils.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.netbeans.modules.java.source.base;
+
+import com.sun.tools.javac.code.Source;
+
+/**
+ *
+ * @author lahvac
+ */
+public class SourceLevelUtils {
+    
+    public static final Source JDK1_5 = Source.lookup("5");
+    public static final Source JDK1_6 = Source.lookup("6");
+    public static final Source JDK1_7 = Source.lookup("7");
+    public static final Source JDK1_8 = Source.lookup("8");
+    public static final Source JDK1_9 = Source.lookup("9");
+
+    public static boolean allowDefaultMethods(Source in) {
+        return in.compareTo(JDK1_8) >= 0;
+    }
+}
diff --git a/java.source.base/src/org/netbeans/modules/java/source/base/layer.xml b/java.source.base/src/org/netbeans/modules/java/source/base/layer.xml
index 7716cef4a..dd4d3387a 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/base/layer.xml
+++ b/java.source.base/src/org/netbeans/modules/java/source/base/layer.xml
@@ -23,9 +23,6 @@
 <filesystem>
 
     <folder name="Editors">
-        <file name="JavaBinaryIndexer.instance">
-            <attr name="instanceClass" stringvalue="org.netbeans.modules.java.source.indexing.JavaBinaryIndexer$Factory"/>
-        </file>
         <file name="COSSynchronizingIndexer.instance">
             <attr name="instanceClass" stringvalue="org.netbeans.modules.java.source.indexing.COSSynchronizingIndexer$Factory"/>
         </file>
@@ -37,10 +34,6 @@
                 <file name="Reindenter.instance">
                     <attr name="instanceClass" stringvalue="org.netbeans.modules.java.source.save.Reindenter$Factory"/>
                 </file>
-                <file name="JavaIndexer.instance">
-                    <attr name="instanceClass" stringvalue="org.netbeans.modules.java.source.indexing.JavaCustomIndexer$Factory"/>
-                    <!--attr name="position" intvalue="1000"/-->
-                </file>
                 <file name="SourcePathCheck.instance">
                     <attr name="instanceClass" stringvalue="org.netbeans.modules.java.source.classpath.SourcePathCheck$Factory"/>
                 </file>
diff --git a/java.source.base/src/org/netbeans/modules/java/source/builder/ElementsService.java b/java.source.base/src/org/netbeans/modules/java/source/builder/ElementsService.java
index 40c0cad83..7a4842165 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/builder/ElementsService.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/builder/ElementsService.java
@@ -38,6 +38,7 @@
 import static javax.lang.model.element.ElementKind.*;
 import javax.lang.model.type.*;
 import javax.lang.model.util.Types;
+import org.netbeans.modules.java.source.base.SourceLevelUtils;
 
 /**
  * Utility methods for working with Element instances.
@@ -63,7 +64,7 @@ protected ElementsService(Context context) {
         jctypes = com.sun.tools.javac.code.Types.instance(context);
         names = Names.instance(context);
         types = JavacTypes.instance(context);
-        allowDefaultMethods = Source.instance(context).allowDefaultMethods();
+        allowDefaultMethods = SourceLevelUtils.allowDefaultMethods(Source.instance(context));
     }
 
     /** 
diff --git a/java.source.base/src/org/netbeans/modules/java/source/indexing/CompileWorker.java b/java.source.base/src/org/netbeans/modules/java/source/indexing/CompileWorker.java
index c87ef4916..84469a586 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/indexing/CompileWorker.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/indexing/CompileWorker.java
@@ -40,9 +40,9 @@
  *
  * @author Jan Lahoda, Dusan Balek
  */
-abstract class CompileWorker {
+public abstract class CompileWorker {
 
-    abstract ParsingOutput compile(ParsingOutput previous, Context context, JavaParsingContext javaContext, Collection<? extends CompileTuple> files);
+    protected abstract ParsingOutput compile(ParsingOutput previous, Context context, JavaParsingContext javaContext, Collection<? extends CompileTuple> files);
 
     protected void computeFQNs(final Map<JavaFileObject, List<String>> file2FQNs, CompilationUnitTree cut, CompileTuple tuple) {
         String pack;
@@ -89,26 +89,26 @@ protected final void freeMemory(final boolean freeCaches) {
         lm.free(freeCaches);
     }
     
-    static class ModuleName {
-        String name;
-        boolean assigned;
+    protected static class ModuleName {
+        public String name;
+        public boolean assigned;
         
-        ModuleName(final String name) {
+        public ModuleName(final String name) {
             this.name = name;
         }
     }
 
-    static class ParsingOutput {
-        final boolean success;
-        final boolean lowMemory;
-        final String moduleName;
-        final Map<JavaFileObject, List<String>> file2FQNs;
-        final Set<ElementHandle<TypeElement>> addedTypes;
-        final Set<ElementHandle<ModuleElement>> addedModules;
-        final Set<File> createdFiles;
-        final Set<Indexable> finishedFiles;
-        final Set<ElementHandle<TypeElement>> modifiedTypes;
-        final Set<javax.tools.FileObject> aptGenerated;
+    public static class ParsingOutput {
+        public final boolean success;
+        public final boolean lowMemory;
+        public final String moduleName;
+        public final Map<JavaFileObject, List<String>> file2FQNs;
+        public final Set<ElementHandle<TypeElement>> addedTypes;
+        public final Set<ElementHandle<ModuleElement>> addedModules;
+        public final Set<File> createdFiles;
+        public final Set<Indexable> finishedFiles;
+        public final Set<ElementHandle<TypeElement>> modifiedTypes;
+        public final Set<javax.tools.FileObject> aptGenerated;
 
         private ParsingOutput(
                 final boolean success,
@@ -134,7 +134,7 @@ private ParsingOutput(
             this.aptGenerated = aptGenerated;
         }
 
-        static ParsingOutput success (
+        public static ParsingOutput success (
                 @NullAllowed final String moduleName,
                 final Map<JavaFileObject, List<String>> file2FQNs,
                 final Set<ElementHandle<TypeElement>> addedTypes,
@@ -148,7 +148,7 @@ static ParsingOutput success (
                     modifiedTypes, aptGenerated);
         }
 
-        static ParsingOutput failure(
+        public static ParsingOutput failure(
                 @NullAllowed final String moduleName,
                 final Map<JavaFileObject, List<String>> file2FQNs,
                 final Set<ElementHandle<TypeElement>> addedTypes,
@@ -162,7 +162,7 @@ static ParsingOutput failure(
                     modifiedTypes, aptGenerated);
         }
 
-        static ParsingOutput lowMemory(
+        public static ParsingOutput lowMemory(
                 @NullAllowed final String moduleName,
                 final Map<JavaFileObject, List<String>> file2FQNs,
                 final Set<ElementHandle<TypeElement>> addedTypes,
diff --git a/java.source.base/src/org/netbeans/modules/java/source/indexing/DiagnosticListenerImpl.java b/java.source.base/src/org/netbeans/modules/java/source/indexing/DiagnosticListenerImpl.java
index f7e7b787a..817f56baa 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/indexing/DiagnosticListenerImpl.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/indexing/DiagnosticListenerImpl.java
@@ -31,7 +31,7 @@
 import javax.tools.DiagnosticListener;
 import javax.tools.JavaFileObject;
 
-class DiagnosticListenerImpl implements DiagnosticListener<JavaFileObject> {
+public class DiagnosticListenerImpl implements DiagnosticListener<JavaFileObject> {
 
     private static final Logger ERROR_LOG = Logger.getLogger(DiagnosticListenerImpl.class.getName() + "-errors");
     private final Map<URI, List<Diagnostic<? extends JavaFileObject>>> diagnostics = new HashMap<URI, List<Diagnostic<? extends JavaFileObject>>>();
@@ -62,6 +62,10 @@ public void report(Diagnostic<? extends JavaFileObject> d) {
         return result;
     }
 
+    public List<Diagnostic<? extends JavaFileObject>> peekDiagnostics(JavaFileObject file) {
+        return diagnostics.getOrDefault(file.toUri(), Collections.emptyList());
+    }
+
     public void cleanDiagnostics() {
         diagnostics.clear();
     }
diff --git a/java.source.base/src/org/netbeans/modules/java/source/indexing/FQN2Files.java b/java.source.base/src/org/netbeans/modules/java/source/indexing/FQN2Files.java
index 86953c37c..75e29e0fe 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/indexing/FQN2Files.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/indexing/FQN2Files.java
@@ -18,7 +18,6 @@
  */
 package org.netbeans.modules.java.source.indexing;
 
-import com.sun.tools.javac.api.DuplicateClassChecker;
 import com.sun.tools.javac.code.Symbol;
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
@@ -48,7 +47,7 @@
  *
  * @author Dusan Balek
  */
-public final class FQN2Files implements DuplicateClassChecker {
+public final class FQN2Files {
 
     private static final Logger LOG = Logger.getLogger(FQN2Files.class.getName());
     private static final String FQN2FILES_FILE = "fqn2files.properties"; //NOI18N
@@ -134,7 +133,6 @@ private void load() throws IOException {
         }
     }
 
-    @Override
     public boolean check(final Name fqn, final JavaFileObject jfo) {
         String value = props.getProperty(fqn.toString());
         try {
diff --git a/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaBinaryIndexer.java b/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaBinaryIndexer.java
index b84b37180..7875bda22 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaBinaryIndexer.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaBinaryIndexer.java
@@ -27,6 +27,7 @@
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -43,11 +44,13 @@
 import javax.tools.JavaFileObject;
 
 import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.api.editor.mimelookup.MimeRegistration;
 import org.netbeans.api.java.classpath.ClassPath;
 import org.netbeans.api.java.platform.JavaPlatform;
 import org.netbeans.api.java.source.ClasspathInfo;
 import org.netbeans.api.java.source.ElementHandle;
-import org.netbeans.modules.java.source.TreeLoader;
+import org.netbeans.modules.java.source.ElementUtils;
+import org.netbeans.modules.java.source.NoJavacHelper;
 import org.netbeans.modules.java.source.base.Module;
 import org.netbeans.modules.java.source.parsing.FileManagerTransaction;
 import org.netbeans.modules.java.source.parsing.FileObjects;
@@ -192,11 +195,10 @@ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
             false,
             false,
             null);
-        final JavacTaskImpl jt = JavacParser.createJavacTask(cpInfo, new DevNullDiagnosticListener(), null, null, null, null, null, null, null);
-        TreeLoader.preRegister(jt.getContext(), cpInfo, true);
+        final JavacTaskImpl jt = JavacParser.createJavacTask(cpInfo, new DevNullDiagnosticListener(), null, null, null, null, null, null, Collections.emptyList());
         //Force JTImpl.prepareCompiler to get JTImpl into Context
         jt.enter();
-        TypeElement jc = (TypeElement) ((JavacElements)jt.getElements()).getTypeElementByBinaryName(fqn);
+        TypeElement jc = ElementUtils.getTypeElementByBinaryName(jt, fqn);
         if (jc != null) {
             List<ExecutableElement> methods = ElementFilter.methodsIn(jt.getElements().getAllMembers(jc));
             for (ExecutableElement method : methods) {
@@ -289,5 +291,10 @@ public void scanFinished(Context context) {
                 Exceptions.printStackTrace(ex);
             }
         }
+
+        @MimeRegistration(mimeType="", service=BinaryIndexerFactory.class)
+        public static Factory register() {
+            return NoJavacHelper.hasWorkingJavac() ? new Factory() : null;
+        }
     }
 }
diff --git a/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaCustomIndexer.java b/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaCustomIndexer.java
index 13272c9d1..8e5a3b0b5 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaCustomIndexer.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaCustomIndexer.java
@@ -66,6 +66,7 @@
 
 import org.netbeans.api.annotations.common.NonNull;
 import org.netbeans.api.annotations.common.NullAllowed;
+import org.netbeans.api.editor.mimelookup.MimeRegistration;
 //import org.netbeans.api.annotations.common.StaticResource;
 import org.netbeans.api.java.classpath.ClassPath;
 import org.netbeans.api.java.classpath.JavaClassPathConstants;
@@ -79,6 +80,7 @@
 import org.netbeans.modules.java.source.ElementHandleAccessor;
 import org.netbeans.modules.java.source.JavaSourceTaskFactoryManager;
 import org.netbeans.modules.java.source.ModuleNames;
+import org.netbeans.modules.java.source.NoJavacHelper;
 import org.netbeans.modules.java.source.base.Module;
 import org.netbeans.modules.java.source.parsing.FileManagerTransaction;
 import org.netbeans.modules.java.source.parsing.FileObjects;
@@ -114,6 +116,7 @@
 import org.openide.util.TopologicalSortException;
 import org.openide.util.BaseUtilities;
 import org.openide.util.Lookup;
+import org.openide.util.lookup.ServiceProvider;
 
 /**
  *
@@ -121,13 +124,12 @@
  */
 public class JavaCustomIndexer extends CustomIndexer {
 
-            static       boolean NO_ONE_PASS_COMPILE_WORKER = Boolean.getBoolean(JavaCustomIndexer.class.getName() + ".no.one.pass.compile.worker");
+    public  static       boolean NO_ONE_PASS_COMPILE_WORKER = Boolean.getBoolean(JavaCustomIndexer.class.getName() + ".no.one.pass.compile.worker");
     private static final String DUMP_ON_LOW_MEM = System.getProperty(JavaCustomIndexer.class.getName() + ".dump.on.low.mem");    //NOI18N
     private static final String SOURCE_PATH = "sourcePath"; //NOI18N
     private static final String APT_SOURCE_OUTPUT = "apSrcOut"; //NOI18N
     private static final Pattern ANONYMOUS = Pattern.compile("\\$[0-9]"); //NOI18N
     private static final ClassPath EMPTY = ClassPathSupport.createClassPath(new URL[0]);
-    private static final int TRESHOLD = 500;
 
     @Override
     protected void index(final Iterable<? extends Indexable> files, final Context context) {
@@ -266,10 +268,7 @@ protected void index(final Iterable<? extends Indexable> files, final Context co
                     int round = 0;
                     String moduleName = null;
                     while (round++ < 2) {
-                        CompileWorker[] WORKERS = {
-                            toCompileRound.size() < TRESHOLD ? new SuperOnePassCompileWorker() : new OnePassCompileWorker(),
-                            new MultiPassCompileWorker()
-                        };
+                        CompileWorker[] WORKERS = Lookup.getDefault().lookup(CompileWorkerProvider.class).getWorkers(toCompileRound);
                         for (CompileWorker w : WORKERS) {
                             compileResult = w.compile(compileResult, context, javaContext, toCompileRound);
                             if (compileResult == null || context.isCancelled()) {
@@ -705,7 +704,7 @@ public boolean accept(File dir, String name) {
         return result;
     }
 
-    static void addAptGenerated(
+    public static void addAptGenerated(
             @NonNull final Context context,
             @NonNull JavaParsingContext javaContext,
             @NonNull final CompileTuple source,
@@ -716,14 +715,14 @@ static void addAptGenerated(
         }
     }
 
-    static void setErrors(Context context, CompileTuple active, DiagnosticListenerImpl errors) {
+    public static void setErrors(Context context, CompileTuple active, DiagnosticListenerImpl errors) {
         if (!active.virtual) {
             Iterable<Diagnostic<? extends JavaFileObject>> filteredErrorsList = Iterators.filter(errors.getDiagnostics(active.jfo), new FilterOutJDK7AndLaterWarnings());
             ErrorsCache.setErrors(context.getRootURI(), active.indexable, filteredErrorsList, active.aptGenerated ? ERROR_CONVERTOR_NO_BADGE : ERROR_CONVERTOR);
         }
     }
 
-    static void brokenPlatform(
+    public static void brokenPlatform(
             @NonNull final Context ctx,
             @NonNull final Iterable<? extends CompileTuple> files,
             @NullAllowed final Diagnostic<JavaFileObject> diagnostic) {
@@ -1178,7 +1177,12 @@ public boolean equals(final Object obj) {
         @Override
         public int hashCode() {
             return getIndexerName().hashCode();
-        }        
+        }
+
+        @MimeRegistration(mimeType="text/x-java", service=CustomIndexerFactory.class)
+        public static Factory register() {
+            return NoJavacHelper.hasWorkingJavac() ? new Factory() : null;
+        }
     }
 
     public static final class CompileTuple {
@@ -1421,4 +1425,20 @@ public Boolean call() throws Exception {
             return vote;
         }
     }
+    
+    public static interface CompileWorkerProvider {
+        public CompileWorker[] getWorkers(List<CompileTuple> toCompile);
+    }
+
+    @ServiceProvider(service=CompileWorkerProvider.class, position=1000)
+    public static class DefaultCompileWorkerProvider implements CompileWorkerProvider {
+
+        @Override
+        public CompileWorker[] getWorkers(List<CompileTuple> toCompile) {
+            return new CompileWorker[] {
+                new VanillaCompileWorker()
+            };
+        }
+        
+    }
 }
diff --git a/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaIndex.java b/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaIndex.java
index 45c2f3bf5..62a253740 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaIndex.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaIndex.java
@@ -60,7 +60,7 @@
     public static final String NAME = "java"; //NOI18N
     public static final int VERSION = 15;
     public static final String ATTR_MODULE_NAME = "moduleName"; //NOI18N
-    static final Logger LOG = Logger.getLogger(JavaIndex.class.getName());
+    public static final Logger LOG = Logger.getLogger(JavaIndex.class.getName());
     private static final String CLASSES = "classes"; //NOI18N
     private static final String APT_SOURCES = "sources";    //NOI18N
     private static final String ATTR_FILE_NAME = "attributes.properties"; //NOI18N
diff --git a/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaParsingContext.java b/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaParsingContext.java
index d5cf76003..9708ad750 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaParsingContext.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/indexing/JavaParsingContext.java
@@ -65,7 +65,7 @@
 import org.openide.util.lookup.Lookups;
 
 //@NotThreadSafe
-final class JavaParsingContext {
+public final class JavaParsingContext {
 
     private final Context ctx;
     private final boolean rootNotNeeded;    
@@ -160,7 +160,7 @@ public JavaParsingContext(final Context context, final ClassPath bootPath, final
     }
     
     @CheckForNull
-    ClasspathInfo getClasspathInfo() {
+    public ClasspathInfo getClasspathInfo() {
         return cpInfo;
     }
     
@@ -170,13 +170,13 @@ ClassIndexImpl getClassIndexImpl() throws IOException {
     }
     
     @CheckForNull
-    String getSourceLevel() {
+    public String getSourceLevel() {
         final SourceLevelQuery.Result sl = initSourceLevel();
         return sl == null ? null : sl.getSourceLevel();
     }
 
     @CheckForNull
-    SourceLevelQuery.Profile getProfile() {
+    public SourceLevelQuery.Profile getProfile() {
         final SourceLevelQuery.Result sl = initSourceLevel();
         return sl == null ? null : sl.getProfile();
     }
@@ -208,7 +208,7 @@ Charset getEncoding() {
     }
     
     @NonNull
-    CheckSums getCheckSums() throws IOException {
+    public CheckSums getCheckSums() throws IOException {
         if (checkSums == null) {
             try {
                 checkSums = CheckSums.forContext(ctx);
@@ -220,7 +220,7 @@ CheckSums getCheckSums() throws IOException {
     }
     
     @NonNull
-    FQN2Files getFQNs() throws IOException {
+    public FQN2Files getFQNs() throws IOException {
         if (fqn2Files == null) {
             fqn2Files = FQN2Files.forRoot(ctx.getRootURI());
         }
@@ -236,7 +236,7 @@ ProcessorGenerated getProcessorGeneratedFiles() {
     }
 
     @CheckForNull
-    String getModuleName() {
+    public String getModuleName() {
         try {
             return JavaIndex.getAttribute(ctx.getRootURI(), JavaIndex.ATTR_MODULE_NAME, null);
         } catch (IOException ioe) {
@@ -244,7 +244,7 @@ String getModuleName() {
         }
     }
 
-    void analyze(
+    public void analyze(
             @NonNull final Iterable<? extends CompilationUnitTree> trees,
             @NonNull final JavacTaskImpl jt,
             @NonNull final CompileTuple active,
diff --git a/java.source.base/src/org/netbeans/modules/java/source/indexing/SourcePrefetcher.java b/java.source.base/src/org/netbeans/modules/java/source/indexing/SourcePrefetcher.java
index 47a893ffb..3e654a810 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/indexing/SourcePrefetcher.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/indexing/SourcePrefetcher.java
@@ -31,7 +31,7 @@
  *
  * @author Tomas Zezula
  */
-class SourcePrefetcher implements Iterator<CompileTuple>, /*Auto*/Closeable {
+public class SourcePrefetcher implements Iterator<CompileTuple>, /*Auto*/Closeable {
        
     private final Iterator<? extends CompileTuple> iterator;
     //@NotThreadSafe
@@ -79,7 +79,7 @@ public void close() throws IOException {
     }
     
     
-    static SourcePrefetcher create(
+    public static SourcePrefetcher create(
             @NonNull final Collection<? extends CompileTuple> files,
             @NonNull final SuspendStatus suspendStatus) {
         return new SourcePrefetcher(JavaIndexerWorker.getCompileTupleIterator(files, suspendStatus));
diff --git a/java.source.base/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorker.java b/java.source.base/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorker.java
new file mode 100644
index 000000000..c1b44f009
--- /dev/null
+++ b/java.source.base/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorker.java
@@ -0,0 +1,515 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.netbeans.modules.java.source.indexing;
+
+import com.sun.source.tree.ClassTree;
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.MethodTree;
+import com.sun.source.tree.PackageTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.tree.VariableTree;
+import com.sun.source.util.TreePath;
+import com.sun.source.util.TreePathScanner;
+import com.sun.source.util.Trees;
+import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.code.Attribute;
+import com.sun.tools.javac.code.Flags;
+import com.sun.tools.javac.code.Symbol;
+import com.sun.tools.javac.code.Symbol.TypeSymbol;
+import com.sun.tools.javac.code.SymbolMetadata;
+import com.sun.tools.javac.code.Symtab;
+import com.sun.tools.javac.code.Type;
+import com.sun.tools.javac.code.Type.ClassType;
+import com.sun.tools.javac.code.Type.ForAll;
+import com.sun.tools.javac.code.Type.TypeVar;
+import com.sun.tools.javac.code.TypeTag;
+import com.sun.tools.javac.comp.AttrContext;
+import com.sun.tools.javac.comp.CompileStates.CompileState;
+import com.sun.tools.javac.comp.Enter;
+import com.sun.tools.javac.comp.Env;
+import com.sun.tools.javac.comp.Modules;
+import com.sun.tools.javac.main.JavaCompiler;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.JCClassDecl;
+import com.sun.tools.javac.tree.JCTree.JCModuleDecl;
+import com.sun.tools.javac.tree.JCTree.JCPackageDecl;
+import com.sun.tools.javac.tree.TreeMaker;
+import org.netbeans.lib.nbjavac.services.CancelAbort;
+import org.netbeans.lib.nbjavac.services.CancelService;
+import com.sun.tools.javac.util.FatalError;
+import com.sun.tools.javac.util.ListBuffer;
+import com.sun.tools.javac.util.Log;
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+import java.util.Map.Entry;
+import java.util.concurrent.Future;
+import java.util.logging.Level;
+import java.util.stream.Collectors;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.ModuleElement;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.TypeKind;
+import javax.lang.model.type.TypeMirror;
+import javax.tools.JavaFileManager;
+import javax.tools.JavaFileObject;
+import org.netbeans.api.java.classpath.ClassPath;
+import org.netbeans.api.java.queries.CompilerOptionsQuery;
+import org.netbeans.api.java.source.ClasspathInfo;
+import org.netbeans.api.java.source.ElementHandle;
+import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.CompileTuple;
+import org.netbeans.modules.java.source.parsing.FileManagerTransaction;
+import org.netbeans.modules.java.source.parsing.FileObjects;
+import org.netbeans.modules.java.source.parsing.JavacParser;
+import org.netbeans.modules.java.source.parsing.OutputFileManager;
+import org.netbeans.modules.java.source.usages.ExecutableFilesIndex;
+import org.netbeans.modules.parsing.spi.indexing.Context;
+import org.netbeans.modules.parsing.spi.indexing.Indexable;
+import org.netbeans.modules.parsing.spi.indexing.SuspendStatus;
+import org.openide.filesystems.FileSystem;
+import org.openide.filesystems.FileUtil;
+import org.openide.util.Exceptions;
+
+/**
+ *
+ * @author Dusan Balek
+ */
+final class VanillaCompileWorker extends CompileWorker {
+
+    @Override
+    protected ParsingOutput compile(
+            final ParsingOutput previous,
+            final Context context,
+            final JavaParsingContext javaContext,
+            final Collection<? extends CompileTuple> files) {
+        final Map<JavaFileObject, List<String>> file2FQNs = previous != null ? previous.file2FQNs : new HashMap<>();
+        final Set<ElementHandle<TypeElement>> addedTypes = previous != null ? previous.addedTypes : new HashSet<>();
+        final Set<ElementHandle<ModuleElement>> addedModules = previous != null ? previous.addedModules : new HashSet<>();
+        final Set<File> createdFiles = previous != null ? previous.createdFiles : new HashSet<>();
+        final Set<Indexable> finished = previous != null ? previous.finishedFiles : new HashSet<>();
+        final Set<ElementHandle<TypeElement>> modifiedTypes = previous != null ? previous.modifiedTypes : new HashSet<>();
+        final Set<javax.tools.FileObject> aptGenerated = previous != null ? previous.aptGenerated : new HashSet<>();
+
+        final DiagnosticListenerImpl dc = new DiagnosticListenerImpl();
+        final LinkedList<CompilationUnitTree> trees = new LinkedList<CompilationUnitTree>();
+        Map<CompilationUnitTree, CompileTuple> units = new IdentityHashMap<CompilationUnitTree, CompileTuple>();
+        JavacTaskImpl jt = null;
+
+        boolean nop = true;
+        final SuspendStatus suspendStatus = context.getSuspendStatus();
+        final SourcePrefetcher sourcePrefetcher = SourcePrefetcher.create(files, suspendStatus);
+        Map<JavaFileObject, CompileTuple> fileObjects = new IdentityHashMap<>();
+        try {
+            final boolean flm[] = {true};
+            while (sourcePrefetcher.hasNext())  {
+                final CompileTuple tuple = sourcePrefetcher.next();
+                try {
+                    if (tuple != null) {
+                        nop = false;
+                        if (context.isCancelled()) {
+                            return null;
+                        }
+                        fileObjects.put(tuple.jfo, tuple);
+                    }
+                }  finally {
+                    sourcePrefetcher.remove();
+                }
+            }
+        } finally {
+            try {
+                sourcePrefetcher.close();
+            } catch (IOException ex) {
+                Exceptions.printStackTrace(ex);
+            }
+        }
+        ModuleName moduleName = new ModuleName(javaContext.getModuleName());
+        if (nop) {
+            return ParsingOutput.success(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+        }
+        try {
+            jt = JavacParser.createJavacTask(
+                javaContext.getClasspathInfo(),
+                dc,
+                javaContext.getSourceLevel(),
+                javaContext.getProfile(),
+                javaContext.getFQNs(),
+                new CancelService() {
+                    public @Override boolean isCanceled() {
+                        return context.isCancelled() || isLowMemory(null);
+                    }
+                },
+                fileObjects.values().iterator().next().aptGenerated ? null : APTUtils.get(context.getRoot()),
+                CompilerOptionsQuery.getOptions(context.getRoot()),
+                fileObjects.keySet());
+            for (CompilationUnitTree cut : jt.parse()) {
+                trees.add(cut);
+                CompileTuple tuple = fileObjects.get(cut.getSourceFile());
+                units.put(cut, tuple);
+                computeFQNs(file2FQNs, cut, tuple);
+            }
+            Log.instance(jt.getContext()).nerrors = 0;
+        } catch (CancelAbort ca) {
+            if (context.isCancelled() && JavaIndex.LOG.isLoggable(Level.FINEST)) {
+                JavaIndex.LOG.log(Level.FINEST, "VanillaCompileWorker was canceled in root: " + FileUtil.getFileDisplayName(context.getRoot()), ca);  //NOI18N
+            }
+        } catch (Throwable t) {
+            if (JavaIndex.LOG.isLoggable(Level.WARNING)) {
+                final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
+                final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
+                final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
+                final String message = String.format("VanillaCompileWorker caused an exception\nFile: %s\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
+                            fileObjects.values().iterator().next().indexable.getURL().toString(),
+                            FileUtil.getFileDisplayName(context.getRoot()),
+                            bootPath == null   ? null : bootPath.toString(),
+                            classPath == null  ? null : classPath.toString(),
+                            sourcePath == null ? null : sourcePath.toString()
+                            );
+                JavaIndex.LOG.log(Level.WARNING, message, t);  //NOI18N
+            }
+            if (t instanceof ThreadDeath) {
+                throw (ThreadDeath) t;
+            } else {
+                jt = null;
+                units = null;
+                dc.cleanDiagnostics();
+                freeMemory(false);
+            }
+        }
+        if (jt == null || units == null || JavaCustomIndexer.NO_ONE_PASS_COMPILE_WORKER) {
+            return ParsingOutput.failure(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+        }
+        if (context.isCancelled()) {
+            return null;
+        }
+        if (isLowMemory(null)) {
+            return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+        }
+        boolean aptEnabled = true;
+        Log log = Log.instance(jt.getContext());
+        JavaCompiler compiler = JavaCompiler.instance(jt.getContext());
+        try {
+            final Iterable<? extends Element> types = jt.enter(trees);
+            if (context.isCancelled()) {
+                return null;
+            }
+            if (isLowMemory(null)) {
+                return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+            }
+            final Map<Element, CompileTuple> clazz2Tuple = new IdentityHashMap<Element, CompileTuple>();
+            Enter enter = Enter.instance(jt.getContext());
+            for (Element type : types) {
+                if (type.getKind().isClass() || type.getKind().isInterface() || type.getKind() == ElementKind.MODULE) {
+                    Env<AttrContext> typeEnv = enter.getEnv((TypeSymbol) type);
+                    if (typeEnv == null) {
+                        JavaIndex.LOG.log(Level.FINE, "No Env for: {0}", ((TypeSymbol) type).getQualifiedName());
+                        continue;
+                    }
+                    clazz2Tuple.put(type, units.get(typeEnv.toplevel));
+                }
+            }
+            jt.analyze(types);
+            if (context.isCancelled()) {
+                return null;
+            }
+            if (isLowMemory(null)) {
+                return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+            }
+            for (Entry<CompilationUnitTree, CompileTuple> unit : units.entrySet()) {
+                CompileTuple active = unit.getValue();
+                if (aptEnabled) {
+                    JavaCustomIndexer.addAptGenerated(context, javaContext, active, aptGenerated);
+                }
+                List<Element> activeTypes = new ArrayList<>();
+                if (unit.getValue().jfo.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE)) {
+                    final PackageTree pt = unit.getKey().getPackage();
+                    if (pt instanceof JCPackageDecl) {                        
+                        final Element sym = ((JCPackageDecl)pt).packge;
+                        if (sym != null)
+                            activeTypes.add(sym);
+                    }
+                } else {
+                    for (Tree tree : unit.getKey().getTypeDecls()) {
+                        if (tree instanceof JCTree) {
+                            final JCTree jct = (JCTree)tree;
+                            if (jct.getTag() == JCTree.Tag.CLASSDEF) {
+                                final Element sym = ((JCClassDecl)tree).sym;
+                                if (sym != null)
+                                    activeTypes.add(sym);
+                            } else if (jct.getTag() == JCTree.Tag.MODULEDEF) {
+                                final Element sym = ((JCModuleDecl)tree).sym;
+                                if (sym != null)
+                                    activeTypes.add(sym);
+                            }
+                        }
+                    }
+                }
+                javaContext.getFQNs().set(activeTypes, active.indexable.getURL());
+                boolean[] main = new boolean[1];
+                if (javaContext.getCheckSums().checkAndSet(
+                        active.indexable.getURL(),
+                        activeTypes.stream()                                                
+                                .filter((e) -> e.getKind().isClass() || e.getKind().isInterface())
+                                .map ((e) -> (TypeElement)e)
+                                .collect(Collectors.toList()),
+                        jt.getElements()) || context.isSupplementaryFilesIndexing()) {
+                    javaContext.analyze(Collections.singleton(unit.getKey()), jt, active, addedTypes, addedModules, main);
+                } else {
+                    final Set<ElementHandle<TypeElement>> aTypes = new HashSet<>();
+                    javaContext.analyze(Collections.singleton(unit.getKey()), jt, active, aTypes, addedModules, main);
+                    addedTypes.addAll(aTypes);
+                    modifiedTypes.addAll(aTypes);
+                }
+                ExecutableFilesIndex.DEFAULT.setMainClass(context.getRoot().toURL(), active.indexable.getURL(), main[0]);
+                dropMethodsAndErrors(jt.getContext(), unit.getKey());
+                JavaCustomIndexer.setErrors(context, active, dc);
+            }
+            if (context.isCancelled()) {
+                return null;
+            }
+            if (isLowMemory(null)) {
+                return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+            }
+            final JavacTaskImpl jtFin = jt;
+            final Future<Void> done = FileManagerTransaction.runConcurrent(new FileSystem.AtomicAction() {
+                @Override
+                public void run() throws IOException {
+                    Modules modules = Modules.instance(jtFin.getContext());
+                    compiler.shouldStopPolicyIfError = CompileState.FLOW; 
+                    for (Element type : types) {
+                        TreePath tp = Trees.instance(jtFin).getPath(type);
+                        assert tp != null;
+                        log.nerrors = 0;
+                        Iterable<? extends JavaFileObject> generatedFiles = jtFin.generate(Collections.singletonList(type));
+                        CompileTuple unit = clazz2Tuple.get(type);
+                        if (unit == null || !unit.virtual) {
+                            for (JavaFileObject generated : generatedFiles) {
+                                if (generated instanceof FileObjects.FileBase) {
+                                    createdFiles.add(((FileObjects.FileBase) generated).getFile());
+                                } else {
+                                    // presumably should not happen
+                                }
+                            }
+                        }
+                    }
+                    if (!moduleName.assigned) {
+                        ModuleElement module = !trees.isEmpty() ?
+                            ((JCTree.JCCompilationUnit)trees.getFirst()).modle :
+                            null;
+                        if (module == null) {
+                            module = modules.getDefaultModule();
+                        }
+                        moduleName.name = module == null || module.isUnnamed() ?
+                            null :
+                            module.getQualifiedName().toString();
+                        moduleName.assigned = true;
+                    }
+                }
+            });
+            for (Entry<CompilationUnitTree, CompileTuple> unit : units.entrySet()) {
+                finished.add(unit.getValue().indexable);
+            }
+            done.get();
+            return ParsingOutput.success(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+        } catch (OutputFileManager.InvalidSourcePath isp) {
+            //Deleted project - log & ignore
+            if (JavaIndex.LOG.isLoggable(Level.FINEST)) {
+                final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
+                final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
+                final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
+                final String message = String.format("VanillaCompileWorker caused an exception\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
+                            FileUtil.getFileDisplayName(context.getRoot()),
+                            bootPath == null   ? null : bootPath.toString(),
+                            classPath == null  ? null : classPath.toString(),
+                            sourcePath == null ? null : sourcePath.toString()
+                            );
+                JavaIndex.LOG.log(Level.FINEST, message, isp);
+            }
+        } catch (CancelAbort ca) {
+            if (isLowMemory(null)) {
+                return ParsingOutput.lowMemory(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+            } else if (JavaIndex.LOG.isLoggable(Level.FINEST)) {
+                JavaIndex.LOG.log(Level.FINEST, "VanillaCompileWorker was canceled in root: " + FileUtil.getFileDisplayName(context.getRoot()), ca);  //NOI18N
+            }
+        } catch (Throwable t) {
+            if (t instanceof ThreadDeath) {
+                throw (ThreadDeath) t;
+            } else {
+                Level level = t instanceof FatalError ? Level.FINEST : Level.WARNING;
+                if (JavaIndex.LOG.isLoggable(level)) {
+                    final ClassPath bootPath   = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.BOOT);
+                    final ClassPath classPath  = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.COMPILE);
+                    final ClassPath sourcePath = javaContext.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE);
+                    final String message = String.format("VanillaCompileWorker caused an exception\nRoot: %s\nBootpath: %s\nClasspath: %s\nSourcepath: %s", //NOI18N
+                                FileUtil.getFileDisplayName(context.getRoot()),
+                                bootPath == null   ? null : bootPath.toString(),
+                                classPath == null  ? null : classPath.toString(),
+                                sourcePath == null ? null : sourcePath.toString()
+                                );
+                    JavaIndex.LOG.log(level, message, t);  //NOI18N
+                }
+            }
+        }
+        return ParsingOutput.failure(moduleName.name, file2FQNs, addedTypes, addedModules, createdFiles, finished, modifiedTypes, aptGenerated);
+    }
+
+    private void dropMethodsAndErrors(com.sun.tools.javac.util.Context ctx, CompilationUnitTree cut) {
+        Symtab syms = Symtab.instance(ctx);
+        TreeMaker make = TreeMaker.instance(ctx);
+        //TODO: should preserve error types!!!
+        new TreePathScanner<Void, Void>() {
+            @Override
+            public Void visitVariable(VariableTree node, Void p) {
+                JCTree.JCVariableDecl decl = (JCTree.JCVariableDecl) node;
+                if ((decl.mods.flags & Flags.ENUM) == 0) {
+                    decl.init = null;
+                }
+                if (decl.type.getKind() == TypeKind.ERROR) {
+                    decl.sym.type = decl.type = syms.objectType;
+                }
+                clearAnnotations(decl.sym.getMetadata());
+                return super.visitVariable(node, p);
+            }
+
+            @Override
+            public Void visitMethod(MethodTree node, Void p) {
+                JCTree.JCMethodDecl decl = (JCTree.JCMethodDecl) node;
+                Symbol.MethodSymbol msym = decl.sym;
+                if (Collections.disjoint(msym.getModifiers(), EnumSet.of(Modifier.NATIVE, Modifier.ABSTRACT))) {
+                    JCTree.JCNewClass nct =
+                            make.NewClass(null,
+                                          com.sun.tools.javac.util.List.nil(),
+                                          make.QualIdent(syms.runtimeExceptionType.tsym),
+                                          com.sun.tools.javac.util.List.of(make.Literal("")),
+                                          null);
+                    nct.type = syms.runtimeExceptionType;
+                    nct.constructor = syms.runtimeExceptionType.tsym.members().getSymbols(
+                            s -> s.getKind() == ElementKind.CONSTRUCTOR && s.type.getParameterTypes().size() == 1 && s.type.getParameterTypes().head.tsym == syms.stringType.tsym
+                    ).iterator().next();
+                    decl.body = make.Block(0, com.sun.tools.javac.util.List.of(make.Throw(nct)));
+                }
+                Type.MethodType mt;
+                if (msym.type.hasTag(TypeTag.FORALL)) {
+                    ForAll fa = (ForAll) msym.type;
+                    fa.tvars = error2Object(fa.tvars);
+                    mt = fa.asMethodType();
+                } else {
+                    mt = (Type.MethodType) msym.type;
+                }
+                mt.restype = error2Object(mt.restype);
+                mt.argtypes = error2Object(mt.argtypes);
+                mt.thrown = error2Object(mt.thrown);
+                clearAnnotations(decl.sym.getMetadata());
+                return super.visitMethod(node, p);
+            }
+
+            @Override
+            public Void visitClass(ClassTree node, Void p) {
+                Symbol.ClassSymbol csym = ((JCTree.JCClassDecl) node).sym;
+                Type.ClassType ct = (Type.ClassType) csym.type;
+                ct.all_interfaces_field = error2Object(ct.all_interfaces_field);
+                ct.allparams_field = error2Object(ct.allparams_field);
+                ct.interfaces_field = error2Object(ct.interfaces_field);
+                ct.typarams_field = error2Object(ct.typarams_field);
+                ct.supertype_field = error2Object(ct.supertype_field);
+                return super.visitClass(node, p);
+            }
+
+            private void clearAnnotations(SymbolMetadata metadata) {
+                if (metadata == null)
+                    return;
+
+                //TODO: type annotations, etc.
+                com.sun.tools.javac.util.List<Attribute.Compound> annotations = metadata.getDeclarationAttributes();
+                com.sun.tools.javac.util.List<Attribute.Compound> prev = null;
+                while (annotations.nonEmpty()) {
+                    if (isErroneous(annotations.head.type)) {
+                        if (prev == null) {
+                            metadata.reset();
+                            metadata.setDeclarationAttributes(annotations.tail);
+                        } else {
+                            prev.tail = annotations.tail;
+                        }
+                    }
+                    prev = annotations;
+                    annotations = annotations.tail;
+                }
+            }
+
+            private boolean isErroneous(TypeMirror type) {
+                return type == null || type.getKind() == TypeKind.ERROR || type.getKind() == TypeKind.NONE || type.getKind() == TypeKind.OTHER;
+            }
+
+            private Set<Type> seen = Collections.newSetFromMap(new IdentityHashMap<>());
+
+            private Type error2Object(Type t) {
+                if (t == null)
+                    return null;
+
+                if (isErroneous(t)) {
+                    return syms.objectType;
+                }
+
+                if (!seen.add(t))
+                    return t;
+
+                switch (t.getKind()) {
+                    case DECLARED: {
+                        resolveErrors((ClassType) t);
+                        break;
+                    }
+                    case WILDCARD: {
+                        Type.WildcardType wt = ((Type.WildcardType) t);
+                        wt.type = error2Object(wt.type);
+                        TypeVar tv = wt.bound;
+                        tv.bound = error2Object(tv.bound);
+                        tv.lower = error2Object(tv.lower);
+                        break;
+                    }
+                }
+                return t;
+            }
+
+            private com.sun.tools.javac.util.List<Type> error2Object(com.sun.tools.javac.util.List<Type> types) {
+                if (types == null)
+                    return null;
+
+                ListBuffer<Type> lb = new ListBuffer<>();
+                boolean changed = false;
+                for (Type t : types) {
+                    Type nue = error2Object(t);
+                    changed |= nue != t;
+                    lb.append(nue);
+                }
+                return changed ? lb.toList() : types;
+            }
+
+            private void resolveErrors(ClassType ct) {
+                if (ct.tsym == syms.objectType.tsym) return ;
+                ct.all_interfaces_field = error2Object(ct.all_interfaces_field);
+                ct.allparams_field = error2Object(ct.allparams_field); //TODO: should replace with bounds
+                ct.interfaces_field = error2Object(ct.interfaces_field);
+                ct.typarams_field = error2Object(ct.typarams_field);
+                ct.supertype_field = error2Object(ct.supertype_field);
+            }
+        }.scan(cut, null);
+    }
+}
diff --git a/java.source.base/src/org/netbeans/modules/java/source/matching/CopyFinder.java b/java.source.base/src/org/netbeans/modules/java/source/matching/CopyFinder.java
index 9d7dc9f38..0f5b7fa08 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/matching/CopyFinder.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/matching/CopyFinder.java
@@ -71,7 +71,7 @@
 import com.sun.source.tree.WildcardTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -105,7 +105,7 @@
  *
  * @author Jan Lahoda
  */
-public class CopyFinder extends TreeScanner<Boolean, TreePath> {
+public class CopyFinder extends ErrorAwareTreeScanner<Boolean, TreePath> {
 
     private final TreePath searchingFor;
     private final CompilationInfo info;
diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/AbstractSourceFileObject.java b/java.source.base/src/org/netbeans/modules/java/source/parsing/AbstractSourceFileObject.java
index 8ff2af58d..f1227bef9 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/parsing/AbstractSourceFileObject.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/parsing/AbstractSourceFileObject.java
@@ -76,12 +76,13 @@
 
     protected AbstractSourceFileObject (
             @NonNull final Handle handle,
-            @NullAllowed final JavaFileFilterImplementation filter) {
+            @NullAllowed final JavaFileFilterImplementation filter,
+            boolean hasContent) { //TODO: if has a content, then Kind.SOURCE, right??
         Parameters.notNull("handle", handle);   //NOI18N
         this.handle = handle;
         this.filter = filter;
         final String ext = this.handle.getExt();
-        this.kind = filter == null ?
+        this.kind = filter == null && !hasContent ?
             FileObjects.getKind(ext) :
             Kind.SOURCE; //#141411
     }
diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/BasicSourceFileObject.java b/java.source.base/src/org/netbeans/modules/java/source/parsing/BasicSourceFileObject.java
index ba70280b1..1194a6603 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/parsing/BasicSourceFileObject.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/parsing/BasicSourceFileObject.java
@@ -74,7 +74,7 @@ public BasicSourceFileObject (
         @NullAllowed final JavaFileFilterImplementation filter,
         @NullAllowed final CharSequence content,
         final boolean renderNow) throws IOException {
-        super(handle, filter);
+        super(handle, filter, content != null);
         this.hasFilter = filter != null;
         if (content != null || renderNow) {
             update(content);
diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/CachingFileManager.java b/java.source.base/src/org/netbeans/modules/java/source/parsing/CachingFileManager.java
index 24108e81a..294be6161 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/parsing/CachingFileManager.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/parsing/CachingFileManager.java
@@ -42,6 +42,7 @@
 import org.netbeans.api.annotations.common.NullAllowed;
 import org.netbeans.api.java.classpath.ClassPath;
 import org.netbeans.modules.java.preprocessorbridge.spi.JavaFileFilterImplementation;
+import org.netbeans.modules.java.source.base.SourceLevelUtils;
 import org.netbeans.modules.java.source.classpath.CacheClassPath;
 import org.netbeans.modules.java.source.util.Iterators;
 import org.openide.util.Exceptions;
@@ -240,7 +241,7 @@ protected final ClassPath getClassPath() {
         String folderName = FileObjects.convertPackage2Folder( packageName );
         List<Iterable<JavaFileObject>> idxs = new LinkedList<>();
         List<? extends String> prefixes = null;
-        final boolean supportsMultiRelease = sourceLevel != null && sourceLevel.compareTo(Source.JDK1_9)>= 0;
+        final boolean supportsMultiRelease = sourceLevel != null && sourceLevel.compareTo(SourceLevelUtils.JDK1_9) >= 0;
         for(ClassPath.Entry entry : roots) {
             try {
                 Archive archive = provider.getArchive( entry.getURL(), cacheFile );
@@ -297,7 +298,7 @@ protected final JavaFileObject getJavaFileForInputImpl(
             final String className,
             final JavaFileObject.Kind kind) {
         final String[] namePair = FileObjects.getParentRelativePathAndName(className);
-        final boolean supportsMultiRelease = sourceLevel != null && sourceLevel.compareTo(Source.JDK1_9)>= 0;
+        final boolean supportsMultiRelease = sourceLevel != null && sourceLevel.compareTo(SourceLevelUtils.JDK1_9)>= 0;
         List<? extends String> reloc = null;
         for( ClassPath.Entry root : roots) {
             try {
@@ -345,7 +346,7 @@ protected final JavaFileObject getJavaFileForInputImpl(
         assert pkgName != null;
         assert relativeName != null;
         final String resourceName = FileObjects.resolveRelativePath(pkgName,relativeName);
-        final boolean supportsMultiRelease = sourceLevel != null && sourceLevel.compareTo(Source.JDK1_9)>= 0;
+        final boolean supportsMultiRelease = sourceLevel != null && sourceLevel.compareTo(SourceLevelUtils.JDK1_9) >= 0;
         List<? extends String> reloc = null;
         for( ClassPath.Entry root : roots) {
             try {
@@ -383,7 +384,7 @@ protected final JavaFileObject getJavaFileForInputImpl(
         prefixes.add("");   //NOI18N
         final Source[] sources = Source.values();
         for (int i=0; i< sources.length; i++) {
-            if (sources[i].compareTo(Source.JDK1_9) >=0 && sources[i].compareTo(sourceLevel) <=0) {
+            if (sources[i].compareTo(SourceLevelUtils.JDK1_9) >=0 && sources[i].compareTo(sourceLevel) <=0) {
                 prefixes.add(String.format(
                         "META-INF/versions/%s",    //NOI18N
                         normalizeSourceLevel(sources[i].name)));
diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/CompilationInfoImpl.java b/java.source.base/src/org/netbeans/modules/java/source/parsing/CompilationInfoImpl.java
index ffb6ee631..0ce761228 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/parsing/CompilationInfoImpl.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/parsing/CompilationInfoImpl.java
@@ -163,7 +163,7 @@
         this.isDetached = false;
     }
 
-    void update (final Snapshot snapshot) throws IOException {
+    public void update (final Snapshot snapshot) throws IOException {
         assert snapshot != null;
         this.jfo.update(snapshot.getText());
         this.snapshot = snapshot;
@@ -354,7 +354,7 @@ public Document getDocument() {
             if (currentPhase.compareTo(phase)<0) {
                 setPhase(phase);
                 if (currentPhase == JavaSource.Phase.MODIFIED)
-                    getJavacTask().analyze(); // Ensure proper javac initialization
+                    getJavacTask().getElements().getTypeElement("java.lang.Object"); // Ensure proper javac initialization
             }
             return phase;
         } else {
@@ -372,7 +372,7 @@ public synchronized JavacTaskImpl getJavacTask() {
         if (javacTask == null) {
             diagnosticListener = new DiagnosticListenerImpl(this.root, this.jfo, this.cpInfo);
             javacTask = JavacParser.createJavacTask(this.file, this.root, this.cpInfo,
-                    this.parser, diagnosticListener, null, isDetached);
+                    this.parser, diagnosticListener, isDetached);
         }
 	return javacTask;
     }
@@ -413,7 +413,7 @@ public void dispose() {
      * Returns current {@link DiagnosticListener}
      * @return listener
      */
-    DiagnosticListener<JavaFileObject> getDiagnosticListener() {
+    public DiagnosticListener<JavaFileObject> getDiagnosticListener() {
         return diagnosticListener;
     }
     
@@ -452,7 +452,7 @@ private boolean hasSource () {
     
     // Innerclasses ------------------------------------------------------------
     @Trusted
-    static class DiagnosticListenerImpl implements DiagnosticListener<JavaFileObject> {
+    public static class DiagnosticListenerImpl implements DiagnosticListener<JavaFileObject> {
         
         private final Map<JavaFileObject, Diagnostics> source2Errors;
         private final FileObject root;
@@ -517,12 +517,12 @@ private Diagnostics getErrors(JavaFileObject file) {
             return errors;
         }
 
-        final boolean hasPartialReparseErrors () {
+        public final boolean hasPartialReparseErrors () {
             // #236654: warnings should not stop processing of the reparsed method
             return this.partialReparseErrors != null && partialReparseRealErrors;
         }
         
-        final void startPartialReparse (int from, int to) {
+        public final void startPartialReparse (int from, int to) {
             if (partialReparseErrors == null) {
                 partialReparseErrors = new ArrayList<>();
                 Diagnostics errors = getErrors(jfo);
@@ -562,7 +562,7 @@ final void startPartialReparse (int from, int to) {
             partialReparseRealErrors = false;
         }
         
-        final void endPartialReparse (final int delta) {
+        public final void endPartialReparse (final int delta) {
             this.currentDelta+=delta;
         }
         
@@ -602,27 +602,18 @@ public Object getSource() {
             @Override
             public long getPosition() {
                 long ret = this.delegate.getPosition();
-                if (delegate.hasFixedPositions()) {
-                    ret+=currentDelta;
-                }
                 return ret;
             }
 
             @Override
             public long getStartPosition() {
                 long ret = this.delegate.getStartPosition();
-                if (delegate.hasFixedPositions()) {
-                    ret+=currentDelta;
-                }
                 return ret;
             }
 
             @Override
             public long getEndPosition() {
                 long ret = this.delegate.getEndPosition();
-                if (delegate.hasFixedPositions()) {
-                    ret+=currentDelta;
-                }
                 return ret;
             }
 
diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/FileManagerTransaction.java b/java.source.base/src/org/netbeans/modules/java/source/parsing/FileManagerTransaction.java
index 202cc7452..5c52fdce9 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/parsing/FileManagerTransaction.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/parsing/FileManagerTransaction.java
@@ -18,7 +18,6 @@
  */
 package org.netbeans.modules.java.source.parsing;
 
-import com.sun.tools.javac.model.LazyTreeLoader;
 import java.io.*;
 import java.net.URL;
 import java.nio.channels.CompletionHandler;
@@ -37,7 +36,6 @@
 import org.netbeans.api.annotations.common.NonNull;
 import org.netbeans.api.annotations.common.NullAllowed;
 import org.netbeans.modules.java.preprocessorbridge.spi.JavaFileFilterImplementation;
-import org.netbeans.modules.java.source.TreeLoader;
 import org.netbeans.modules.java.source.indexing.JavaIndexerWorker;
 import org.netbeans.modules.java.source.indexing.TransactionContext;
 import org.openide.filesystems.FileSystem;
@@ -375,9 +373,7 @@ protected void rollBack() throws IOException {
 
         @NonNull
         private FileManagerTransaction getDelegate() {
-            return TreeLoader.isTreeLoading() ?
-                writeThrough :
-                nullWrite;
+            return nullWrite;
         }
     }
 
diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/FileObjects.java b/java.source.base/src/org/netbeans/modules/java/source/parsing/FileObjects.java
index e8acfdb21..5644dcf6e 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/parsing/FileObjects.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/parsing/FileObjects.java
@@ -139,6 +139,7 @@ public int compare( JavaFileObject o1, JavaFileObject o2 ) {
     private static final Set<String> javaFlavorExt = new HashSet<String>();
     static {
         javaFlavorExt.add("btrace");    //NOI18N
+        javaFlavorExt.add("jsh");       //NOI18N
     }
 
     /** Creates a new instance of FileObjects */
diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacFlowListener.java b/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacFlowListener.java
index 26aac1c50..2080d67ea 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacFlowListener.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacFlowListener.java
@@ -36,7 +36,7 @@
  *
  * @author Tomas Zezula
  */
-class JavacFlowListener {
+public class JavacFlowListener {
         
     protected static final Context.Key<JavacFlowListener> flowListenerKey =
         new Context.Key<JavacFlowListener>();
@@ -58,7 +58,7 @@ private JavacFlowListener(Context context, JavacTaskImpl jti) {
         jti.setTaskListener(new TaskListenerImpl());
     }
 
-    final boolean hasFlowCompleted (final FileObject fo) {
+    public final boolean hasFlowCompleted (final FileObject fo) {
         if (fo == null) {
             return false;
         }
diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacParser.java b/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacParser.java
index 2c36972f5..83d1cb36d 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacParser.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacParser.java
@@ -19,34 +19,18 @@
 
 package org.netbeans.modules.java.source.parsing;
 
-import com.sun.source.tree.ClassTree;
 import com.sun.source.tree.CompilationUnitTree;
 import com.sun.source.tree.MethodTree;
-import com.sun.source.tree.Tree;
-import com.sun.source.util.TreePath;
+import com.sun.source.util.JavacTask;
 import com.sun.source.util.Trees;
-import com.sun.tools.javac.api.ClassNamesForFileOraculum;
-import com.sun.tools.javac.api.DuplicateClassChecker;
 import com.sun.tools.javac.api.JavacTaskImpl;
 import com.sun.tools.javac.api.JavacTool;
-import com.sun.tools.javac.api.JavacTrees;
-import com.sun.tools.javac.parser.LazyDocCommentTable;
-import com.sun.tools.javac.tree.EndPosTable;
-import com.sun.tools.javac.tree.JCTree;
-import com.sun.tools.javac.tree.JCTree.JCBlock;
-import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
-import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
 import com.sun.tools.javac.util.Abort;
 
 import org.netbeans.lib.nbjavac.services.CancelAbort;
 import org.netbeans.lib.nbjavac.services.CancelService;
 
 import com.sun.tools.javac.util.Context;
-import com.sun.tools.javac.util.CouplingAbort;
-import com.sun.tools.javac.util.Log;
-import com.sun.tools.javac.util.Options;
-import com.sun.tools.javac.util.Position.LineMapImpl;
-import com.sun.tools.javadoc.main.JavadocClassFinder;
 
 import java.io.File;
 import java.io.FileOutputStream;
@@ -63,7 +47,6 @@
 import java.util.Collections;
 import java.util.EnumMap;
 import java.util.EnumSet;
-import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.LinkedList;
@@ -81,7 +64,6 @@
 import javax.swing.event.ChangeEvent;
 import  javax.swing.event.ChangeListener;
 import javax.swing.text.Document;
-import javax.tools.Diagnostic;
 import javax.tools.DiagnosticListener;
 import javax.tools.JavaFileObject;
 
@@ -103,22 +85,24 @@
 import org.netbeans.modules.java.source.JavaSourceAccessor;
 import org.netbeans.modules.java.source.JavadocEnv;
 import org.netbeans.modules.java.source.PostFlowAnalysis;
-import org.netbeans.modules.java.source.TreeLoader;
 import org.netbeans.modules.java.source.indexing.APTUtils;
 import org.netbeans.modules.java.source.indexing.FQN2Files;
 import org.netbeans.lib.nbjavac.services.NBAttr;
+import org.netbeans.lib.nbjavac.services.NBClassFinder;
 import org.netbeans.lib.nbjavac.services.NBClassReader;
 import org.netbeans.lib.nbjavac.services.NBEnter;
+import org.netbeans.lib.nbjavac.services.NBJavaCompiler;
 import org.netbeans.lib.nbjavac.services.NBJavadocEnter;
 import org.netbeans.lib.nbjavac.services.NBJavadocMemberEnter;
 import org.netbeans.lib.nbjavac.services.NBMemberEnter;
 import org.netbeans.lib.nbjavac.services.NBParserFactory;
 import org.netbeans.lib.nbjavac.services.NBClassWriter;
 import org.netbeans.lib.nbjavac.services.NBJavacTrees;
+import org.netbeans.lib.nbjavac.services.NBJavadocClassFinder;
 import org.netbeans.lib.nbjavac.services.NBMessager;
 import org.netbeans.lib.nbjavac.services.NBResolve;
 import org.netbeans.lib.nbjavac.services.NBTreeMaker;
-import org.netbeans.lib.nbjavac.services.PartialReparser;
+import org.netbeans.modules.java.source.base.SourceLevelUtils;
 import org.netbeans.modules.java.source.indexing.JavaIndex;
 import org.netbeans.modules.java.source.tasklist.CompilerSettings;
 import org.netbeans.modules.java.source.usages.ClassIndexImpl;
@@ -137,8 +121,10 @@
 import org.openide.modules.SpecificationVersion;
 import org.openide.util.ChangeSupport;
 import org.openide.util.Exceptions;
+import org.openide.util.Lookup;
 import org.openide.util.Pair;
 import org.openide.util.WeakListeners;
+import org.openide.util.lookup.ServiceProvider;
 
 /**
  * Provides Parsing API parser built atop Javac (using JSR 199).
@@ -159,7 +145,7 @@
     private static final int MAX_DUMPS = Integer.getInteger("org.netbeans.modules.java.source.parsing.JavacParser.maxDumps", 255);  //NOI18N
     //Command line switch disabling partial reparse
     private static final boolean DISABLE_PARTIAL_REPARSE = Boolean.getBoolean("org.netbeans.modules.java.source.parsing.JavacParser.no_reparse");   //NOI18N
-    private static final String LOMBOK_DETECTED = "lombokDetected";
+    public static final String LOMBOK_DETECTED = "lombokDetected";
 
     /**
      * Helper map mapping the {@link Phase} to message for performance logger
@@ -200,6 +186,7 @@
     private final FilterListener filterListener;
     //ClasspathInfo Listener
     private final ChangeListener cpInfoListener;
+    private final SequentialParsing sequentialParsing;
     //Cached javac impl
     private CompilationInfoImpl ciImpl;
     //State of the parser, used only for single source parser, otherwise don't care.
@@ -240,6 +227,7 @@ public void run() {
                     }
                 }
             });
+        this.sequentialParsing = Lookup.getDefault().lookup(SequentialParsing.class);
     }
 
     private void init (final Snapshot snapshot, final Task task, final boolean singleSource) {
@@ -404,7 +392,8 @@ private void parseImpl(
                         final Pair<DocPositionRegion,MethodTree> _changedMethod = changedMethod.getAndSet(null);
                         if (_changedMethod != null && ciImpl != null) {
                             LOGGER.log(Level.FINE, "\t:trying partial reparse:\n{0}", _changedMethod.first().getText());                           //NOI18N
-                            needsFullReparse = !reparseMethod(ciImpl, snapshot, _changedMethod.second(), _changedMethod.first().getText());
+                            PartialReparser reparser = Lookup.getDefault().lookup(PartialReparser.class);
+                            needsFullReparse = !reparser.reparseMethod(ciImpl, snapshot, _changedMethod.second(), _changedMethod.first().getText());
                             if (!needsFullReparse) {
                                 ciImpl.setChangedMethod(_changedMethod);
                             }
@@ -419,8 +408,8 @@ private void parseImpl(
                 default:
                     init (snapshot, task, false);
                     ciImpl = createCurrentInfo(this, file, root, snapshot,
-                        ciImpl == null ? null : ciImpl.getJavacTask(),
-                        ciImpl == null ? null : ciImpl.getDiagnosticListener());
+                        sequentialParsing == null || ciImpl == null ? null : ciImpl.getJavacTask(),
+                        sequentialParsing == null || ciImpl == null ? null : ciImpl.getDiagnosticListener());
             }
             success = true;
         } finally {
@@ -585,7 +574,12 @@ Phase moveToPhase (final Phase phase, final CompilationInfoImpl currentInfo,
                 }
                 long start = System.currentTimeMillis();
                 // XXX - this might be with wrong encoding
-                Iterable<? extends CompilationUnitTree> trees = currentInfo.getJavacTask().parse(new JavaFileObject[] {currentInfo.jfo});
+                Iterable<? extends CompilationUnitTree> trees;
+                if (sequentialParsing != null) {
+                    trees = sequentialParsing.parse(currentInfo.getJavacTask(), currentInfo.jfo);
+                } else {
+                    trees = currentInfo.getJavacTask().parse();
+                }
                 if (trees == null) {
                     LOGGER.log( Level.INFO, "Did not parse anything for: {0}", currentInfo.jfo.toUri()); //NOI18N
                     return Phase.MODIFIED;
@@ -641,18 +635,11 @@ Phase moveToPhase (final Phase phase, final CompilationInfoImpl currentInfo,
             if (currentPhase == Phase.RESOLVED && phase.compareTo(Phase.UP_TO_DATE)>=0) {
                 currentPhase = Phase.UP_TO_DATE;
             }
-        } catch (CouplingAbort a) {
-            TreeLoader.dumpCouplingAbort(a, null);
-            return currentPhase;
         } catch (CancelAbort ca) {
             currentPhase = Phase.MODIFIED;
             invalidate(false);
         } catch (Abort abort) {
             parserError = currentPhase;
-        } catch (IOException ex) {
-            currentInfo.parserCrashed = currentPhase;
-            dumpSource(currentInfo, ex);
-            throw ex;
         } catch (RuntimeException | Error ex) {
             parserError = currentPhase;
             dumpSource(currentInfo, ex);
@@ -684,17 +671,16 @@ static JavacTaskImpl createJavacTask(
             final ClasspathInfo cpInfo,
             final JavacParser parser,
             final DiagnosticListener<? super JavaFileObject> diagnosticListener,
-            final ClassNamesForFileOraculum oraculum,
             final boolean detached) {
         if (file != null) {
             if (LOGGER.isLoggable(Level.FINER)) {
                 LOGGER.log(Level.FINER, "Created new JavacTask for: {0}", FileUtil.getFileDisplayName(file));
             }
         }
-        FQN2Files dcc = null;
+        FQN2Files fqn2Files = null;
         if (root != null) {
             try {
-                dcc = FQN2Files.forRoot(root.toURL());
+                fqn2Files = FQN2Files.forRoot(root.toURL());
             } catch (IOException ex) {
                 LOGGER.log(Level.FINE, null, ex);
             }
@@ -744,14 +730,16 @@ static JavacTaskImpl createJavacTask(
                     sourceLevel != null ? sourceLevel.getSourceLevel() : null,
                     sourceLevel != null ? sourceLevel.getProfile() : null,
                     flags,
-                    oraculum,
-                    dcc,
+                    fqn2Files,
                     parser == null ? null : new DefaultCancelService(parser),
                     APTUtils.get(root),
                     compilerOptions,
-                    additionalModules);
-            Context context = javacTask.getContext();
-            TreeLoader.preRegister(context, cpInfo, detached);
+                    additionalModules,
+                    file != null ? Arrays.asList(FileObjects.sourceFileObject(file, root)) : Collections.emptyList());
+            Lookup.getDefault()
+                  .lookupAll(TreeLoaderRegistry.class)
+                  .stream()
+                  .forEach(r -> r.enhance(javacTask.getContext(), cpInfo, detached));
             return javacTask;
         }
     }
@@ -761,23 +749,23 @@ public static JavacTaskImpl createJavacTask (
             @NullAllowed final DiagnosticListener<? super JavaFileObject> diagnosticListener,
             @NullAllowed final String sourceLevel,
             @NullAllowed final SourceLevelQuery.Profile sourceProfile,
-            @NullAllowed final ClassNamesForFileOraculum cnih,
-            @NullAllowed final DuplicateClassChecker dcc,
+            @NullAllowed FQN2Files fqn2Files,
             @NullAllowed final CancelService cancelService,
             @NullAllowed final APTUtils aptUtils,
-            @NullAllowed final CompilerOptionsQuery.Result compilerOptions) {
+            @NullAllowed final CompilerOptionsQuery.Result compilerOptions,
+            @NonNull Iterable<? extends JavaFileObject> files) {
         return createJavacTask(
                 cpInfo,
                 diagnosticListener,
                 sourceLevel,
                 sourceProfile,
                 EnumSet.of(ConfigFlags.BACKGROUND_COMPILATION, ConfigFlags.MULTI_SOURCE),
-                cnih,
-                dcc,
+                fqn2Files,
                 cancelService,
                 aptUtils,
                 compilerOptions,
-                Collections.emptySet());
+                Collections.emptySet(),
+                files);
     }
 
     private static enum ConfigFlags {
@@ -792,12 +780,12 @@ private static JavacTaskImpl createJavacTask(
             @NullAllowed final String sourceLevel,
             @NullAllowed SourceLevelQuery.Profile sourceProfile,
             @NonNull final Set<? extends ConfigFlags> flags,
-            @NullAllowed final ClassNamesForFileOraculum cnih,
-            @NullAllowed final DuplicateClassChecker dcc,
+            @NullAllowed FQN2Files fqn2Files,
             @NullAllowed final CancelService cancelService,
             @NullAllowed final APTUtils aptUtils,
             @NullAllowed final CompilerOptionsQuery.Result compilerOptions,
-            @NonNull final Collection<? extends String> additionalModules) {
+            @NonNull final Collection<? extends String> additionalModules,
+            @NonNull Iterable<? extends JavaFileObject> files) {
         final boolean backgroundCompilation = flags.contains(ConfigFlags.BACKGROUND_COMPILATION);
         final boolean multiSource = flags.contains(ConfigFlags.MULTI_SOURCE);
         final List<String> options = new ArrayList<>();
@@ -883,19 +871,21 @@ private static JavacTaskImpl createJavacTask(
         NBMessager.preRegister(context, null, DEV_NULL, DEV_NULL, DEV_NULL);
         JavacTaskImpl task = (JavacTaskImpl)JavacTool.create().getTask(null,
                 ClasspathInfoAccessor.getINSTANCE().createFileManager(cpInfo, validatedSourceLevel.name),
-                diagnosticListener, options, null, Collections.<JavaFileObject>emptySet(),
+                diagnosticListener, options, files.iterator().hasNext() ? null : Arrays.asList("java.lang.Object"), files,
                 context);
         if (aptEnabled) {
             task.setProcessors(processors);
+            ProcessorHolder.instance(context).setProcessors(processors);
         }
         NBClassReader.preRegister(context);
-        JavadocClassFinder.preRegister(context, !backgroundCompilation);
-        if (cnih != null) {
-            context.put(ClassNamesForFileOraculum.class, cnih);
-        }
-        if (dcc != null) {
-            context.put(DuplicateClassChecker.class, dcc);
-        }
+        Lookup.getDefault()
+              .lookupAll(ContextEnhancer.class)
+              .stream()
+              .forEach(r -> r.enhance(context, backgroundCompilation));
+        Lookup.getDefault()
+              .lookupAll(DuplicateClassRegistry.class)
+              .stream()
+              .forEach(r -> r.enhance(context, fqn2Files));
         if (cancelService != null) {
             DefaultCancelService.preRegister(context, cancelService);
         }
@@ -954,7 +944,7 @@ private static JavacTaskImpl createJavacTask(
         } else {
             if (isModuleInfo) {
                 //Module info requires at least 9 otherwise module.compete fails with ISE.
-                final com.sun.tools.javac.code.Source java9 = com.sun.tools.javac.code.Source.JDK1_9;
+                final com.sun.tools.javac.code.Source java9 = SourceLevelUtils.JDK1_9;
                 final com.sun.tools.javac.code.Source required = com.sun.tools.javac.code.Source.lookup(sourceLevel);
                 if (required == null || required.compareTo(java9) < 0) {
                     sourceLevel = java9.name;
@@ -979,7 +969,7 @@ private static JavacTaskImpl createJavacTask(
                         }
                     }
                 }
-                if (source.compareTo(com.sun.tools.javac.code.Source.JDK1_5) >= 0 &&
+                if (source.compareTo(SourceLevelUtils.JDK1_5) >= 0 &&
                     !hasResource("java/lang/StringBuilder", new ClassPath[] {bootClassPath}, new ClassPath[] {classPath}, new ClassPath[] {srcClassPath})) { //NOI18N
                     LOGGER.log(warnLevel,
                                "Even though the source level of {0} is set to: {1}, java.lang.StringBuilder cannot be found on the bootclasspath: {2}\n" +
@@ -987,28 +977,28 @@ private static JavacTaskImpl createJavacTask(
                                new Object[]{srcClassPath, sourceLevel, bootClassPath}); //NOI18N
                     return com.sun.tools.javac.code.Source.JDK1_4;
                 }
-                if (source.compareTo(com.sun.tools.javac.code.Source.JDK1_7) >= 0 &&
+                if (source.compareTo(SourceLevelUtils.JDK1_7) >= 0 &&
                     !hasResource("java/lang/AutoCloseable", new ClassPath[] {bootClassPath}, new ClassPath[] {classPath}, new ClassPath[] {srcClassPath})) { //NOI18N
                     LOGGER.log(warnLevel,
                                "Even though the source level of {0} is set to: {1}, java.lang.AutoCloseable cannot be found on the bootclasspath: {2}\n" +   //NOI18N
                                "Try with resources is unsupported.",  //NOI18N
                                new Object[]{srcClassPath, sourceLevel, bootClassPath}); //NOI18N
                 }
-                if (source.compareTo(com.sun.tools.javac.code.Source.JDK1_8) >= 0 &&
+                if (source.compareTo(SourceLevelUtils.JDK1_8) >= 0 &&
                     !hasResource("java/util/stream/Streams", new ClassPath[] {bootClassPath}, new ClassPath[] {classPath}, new ClassPath[] {srcClassPath})) { //NOI18N
                     LOGGER.log(warnLevel,
                                "Even though the source level of {0} is set to: {1}, java.util.stream.Streams cannot be found on the bootclasspath: {2}\n" +   //NOI18N
                                "Changing source level to 1.7",  //NOI18N
                                new Object[]{srcClassPath, sourceLevel, bootClassPath}); //NOI18N
-                    return com.sun.tools.javac.code.Source.JDK1_7;
+                    return SourceLevelUtils.JDK1_7;
                 }
-                if (source.compareTo(com.sun.tools.javac.code.Source.JDK1_9) >= 0 &&
+                if (source.compareTo(SourceLevelUtils.JDK1_9) >= 0 &&
                     !hasResource("java/util/zip/CRC32C", new ClassPath[] {moduleBoot}, new ClassPath[] {moduleCompile, moduleAllUnnamed}, new ClassPath[] {srcClassPath})) { //NOI18N
                     LOGGER.log(warnLevel,
                                "Even though the source level of {0} is set to: {1}, java.util.zip.CRC32C cannot be found on the system module path: {2}\n" +   //NOI18N
                                "Changing source level to 1.8",  //NOI18N
                                new Object[]{srcClassPath, sourceLevel, bootClassPath}); //NOI18N
-                    return com.sun.tools.javac.code.Source.JDK1_8;
+                    return SourceLevelUtils.JDK1_8;
                 }
                 return source;
             }
@@ -1106,7 +1096,7 @@ private static boolean hasResource(
          return false;
      }
 
-    private static void logTime (FileObject source, Phase phase, long time) {
+    public static void logTime (FileObject source, Phase phase, long time) {
         assert source != null && phase != null;
         String message = phase2Message.get(phase);
         assert message != null;
@@ -1120,7 +1110,7 @@ private static void logTime (FileObject source, Phase phase, long time) {
      * @param  info  CompilationInfo for which the error occurred.
      * @param  exc  exception to write to the end of dump file
      */
-    private static void dumpSource(CompilationInfoImpl info, Throwable exc) {
+    public static void dumpSource(CompilationInfoImpl info, Throwable exc) {
         String userDir = System.getProperty("netbeans.user");
         if (userDir == null) {
             return;
@@ -1183,168 +1173,6 @@ private static void dumpSource(CompilationInfoImpl info, Throwable exc) {
         }
     }
 
-    private static boolean reparseMethod (final CompilationInfoImpl ci,
-            final Snapshot snapshot,
-            final MethodTree orig,
-            final String newBody) throws IOException {
-        assert ci != null;
-        final FileObject fo = ci.getFileObject();
-        if (LOGGER.isLoggable(Level.FINER)) {
-            LOGGER.log(Level.FINER, "Reparse method in: {0}", fo);          //NOI18N
-        }
-        if (((JCMethodDecl)orig).localEnv == null) {
-            //We are seeing interface method or abstract or native method with body.
-            //Don't do any optimalization of this broken code - has no attr env.
-            return false;
-        }
-        final Phase currentPhase = ci.getPhase();
-        if (Phase.PARSED.compareTo(currentPhase) > 0) {
-            return false;
-        }
-        try {
-            final CompilationUnitTree cu = ci.getCompilationUnit();
-            if (cu == null || newBody == null) {
-                return false;
-            }
-            final JavacTaskImpl task = ci.getJavacTask();
-            if (Options.instance(task.getContext()).isSet(LOMBOK_DETECTED)) {
-                return false;
-            }
-            PartialReparser pr = PartialReparser.instance(task.getContext());
-            final JavacTrees jt = JavacTrees.instance(task);
-            final int origStartPos = (int) jt.getSourcePositions().getStartPosition(cu, orig.getBody());
-            final int origEndPos = (int) jt.getSourcePositions().getEndPosition(cu, orig.getBody());
-            if (origStartPos < 0) {
-                LOGGER.log(Level.WARNING, "Javac returned startpos: {0} < 0", new Object[]{origStartPos});  //NOI18N
-                return false;
-            }
-            if (origStartPos > origEndPos) {
-                LOGGER.log(Level.WARNING, "Javac returned startpos: {0} > endpos: {1}", new Object[]{origStartPos, origEndPos});  //NOI18N
-                return false;
-            }
-            final FindAnonymousVisitor fav = new FindAnonymousVisitor();
-            fav.scan(orig.getBody(), null);
-            if (fav.hasLocalClass) {
-                if (LOGGER.isLoggable(Level.FINER)) {
-                    LOGGER.log(Level.FINER, "Skeep reparse method (old local classes): {0}", fo);   //NOI18N
-                }
-                return false;
-            }
-            final int firstInner = fav.firstInner;
-            final int noInner = fav.noInner;
-            final Context ctx = task.getContext();
-            final TreeLoader treeLoader = TreeLoader.instance(ctx);
-            if (treeLoader != null) {
-                treeLoader.startPartialReparse();
-            }
-            try {
-                final Log l = Log.instance(ctx);
-                l.startPartialReparse();
-                final JavaFileObject prevLogged = l.useSource(cu.getSourceFile());
-                JCBlock block;
-                try {
-                    DiagnosticListener dl = ci.getDiagnosticListener();
-                    assert dl instanceof CompilationInfoImpl.DiagnosticListenerImpl;
-                    ((CompilationInfoImpl.DiagnosticListenerImpl)dl).startPartialReparse(origStartPos, origEndPos);
-                    long start = System.currentTimeMillis();
-                    Map<JCTree,LazyDocCommentTable.Entry> docComments = new HashMap<>();
-                    block = pr.reparseMethodBody(cu, orig, newBody + " ", firstInner, docComments);
-                    LOGGER.log(Level.FINER, "Reparsed method in: {0}", fo);     //NOI18N
-                    if (block == null) {
-                        LOGGER.log(
-                            Level.FINER,
-                            "Skeep reparse method, invalid position, newBody: ",       //NOI18N
-                            newBody);
-                        return false;
-                    }
-                    final int newEndPos = (int) jt.getSourcePositions().getEndPosition(cu, block);
-                    if (newEndPos != origStartPos + newBody.length()) {
-                        return false;
-                    }
-                    fav.reset();
-                    fav.scan(block, null);
-                    final int newNoInner = fav.noInner;
-                    if (fav.hasLocalClass || noInner != newNoInner) {
-                        if (LOGGER.isLoggable(Level.FINER)) {
-                            LOGGER.log(Level.FINER, "Skeep reparse method (new local classes): {0}", fo);   //NOI18N
-                        }
-                        return false;
-                    }
-                    ((LazyDocCommentTable) ((JCTree.JCCompilationUnit)cu).docComments).table.keySet().removeAll(fav.docOwners);
-                    ((LazyDocCommentTable) ((JCTree.JCCompilationUnit)cu).docComments).table.putAll(docComments);
-                    long end = System.currentTimeMillis();
-                    if (fo != null) {
-                        logTime (fo,Phase.PARSED,(end-start));
-                    }
-                    final int delta = newEndPos - origEndPos;
-                    final EndPosTable endPos = ((JCCompilationUnit)cu).endPositions;
-                    final TranslatePositionsVisitor tpv = new TranslatePositionsVisitor(orig, endPos, delta);
-                    tpv.scan(cu, null);
-                    ((JCMethodDecl)orig).body = block;
-                    if (Phase.RESOLVED.compareTo(currentPhase)<=0) {
-                        start = System.currentTimeMillis();
-                        pr.reattrMethodBody(orig, block);
-                        if (LOGGER.isLoggable(Level.FINER)) {
-                            LOGGER.log(Level.FINER, "Resolved method in: {0}", fo);     //NOI18N
-                        }
-                        if (!((CompilationInfoImpl.DiagnosticListenerImpl)dl).hasPartialReparseErrors()) {
-                            final JavacFlowListener fl = JavacFlowListener.instance(ctx);
-                            if (fl != null && fl.hasFlowCompleted(fo)) {
-                                if (LOGGER.isLoggable(Level.FINER)) {
-                                    final List<? extends Diagnostic> diag = ci.getDiagnostics();
-                                    if (!diag.isEmpty()) {
-                                        LOGGER.log(Level.FINER, "Reflow with errors: {0} {1}", new Object[]{fo, diag});     //NOI18N
-                                    }
-                                }
-                                TreePath tp = TreePath.getPath(cu, orig);       //todo: store treepath in changed method => improve speed
-                                Tree t = tp.getParentPath().getLeaf();
-                                pr.reflowMethodBody(cu, (ClassTree) t, orig);
-                                if (LOGGER.isLoggable(Level.FINER)) {
-                                    LOGGER.log(Level.FINER, "Reflowed method in: {0}", fo); //NOI18N
-                                }
-                            }
-                        }
-                        end = System.currentTimeMillis();
-                        if (fo != null) {
-                            logTime (fo, Phase.ELEMENTS_RESOLVED,0L);
-                            logTime (fo,Phase.RESOLVED,(end-start));
-                        }
-                    }
-
-                    //fix CompilationUnitTree.getLineMap:
-                    long startM = System.currentTimeMillis();
-                    char[] chars = snapshot.getText().toString().toCharArray();
-                    ((LineMapImpl) cu.getLineMap()).build(chars, chars.length);
-                    LOGGER.log(Level.FINER, "Rebuilding LineMap took: {0}", System.currentTimeMillis() - startM);
-
-                    ((CompilationInfoImpl.DiagnosticListenerImpl)dl).endPartialReparse (delta);
-                } finally {
-                    l.endPartialReparse();
-                    l.useSource(prevLogged);
-                }
-                ci.update(snapshot);
-            } finally {
-              if (treeLoader != null) {
-                  treeLoader.endPartialReparse();
-              }
-            }
-        } catch (CouplingAbort ca) {
-            //Needs full reparse
-            return false;
-        } catch (Throwable t) {
-            if (t instanceof ThreadDeath) {
-                throw (ThreadDeath) t;
-            }
-            boolean a = false;
-            assert a = true;
-            if (a) {
-                dumpSource(ci, t);
-            }
-            return false;
-        }
-        return true;
-    }
-
     //Helper classes
     private static class DefaultCancelService extends CancelService {
 
@@ -1428,4 +1256,71 @@ public void stateChanged(ChangeEvent event) {
             listeners.fireChange();
         }
     }
+    
+    public static interface PartialReparser {
+        public boolean reparseMethod (final CompilationInfoImpl ci,
+                final Snapshot snapshot,
+                final MethodTree orig,
+                final String newBody) throws IOException;
+    }
+    
+    @ServiceProvider(service = PartialReparser.class, position = 1000)
+    public static class DefaultPartialReparser implements PartialReparser {
+
+        @Override
+        public boolean reparseMethod(CompilationInfoImpl ci, Snapshot snapshot, MethodTree orig, String newBody) throws IOException {
+            return false;
+        }
+        
+    }
+    
+    public static class ProcessorHolder {
+        public static ProcessorHolder instance(Context ctx) {
+            ProcessorHolder instance = ctx.get(ProcessorHolder.class);
+
+            if (instance == null) {
+                ctx.put(ProcessorHolder.class, instance = new ProcessorHolder());
+            }
+
+            return instance;
+        }
+
+        private Collection<? extends Processor> processors;
+
+        public void setProcessors(Collection<? extends Processor> processors) {
+            this.processors = processors;
+        }
+
+        public Collection<? extends Processor> getProcessors() {
+            return processors;
+        }
+    }
+
+    public static interface TreeLoaderRegistry {
+        public void enhance(Context context, ClasspathInfo cpInfo, boolean detached);
+    }
+    
+    public static interface DuplicateClassRegistry {
+        public void enhance(Context context, FQN2Files fqn2Files);
+    }
+    
+    public static interface ContextEnhancer {
+        public void enhance(Context context, boolean backgroundCompilation);
+    }
+
+    @ServiceProvider(service=ContextEnhancer.class)
+    public static class VanillaJavacContextEnhancer implements ContextEnhancer {
+        @Override
+        public void enhance(Context context, boolean backgroundCompilation) {
+            if (!backgroundCompilation)
+                NBJavadocClassFinder.preRegister(context);
+            else
+                NBClassFinder.preRegister(context);
+            NBJavaCompiler.preRegister(context);
+        }
+    }
+
+    public static interface SequentialParsing {
+        public Iterable<? extends CompilationUnitTree> parse(JavacTask task, JavaFileObject file) throws IOException;
+    }
 }
diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacParserFactory.java b/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacParserFactory.java
index 85b26db9c..68e21e25a 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacParserFactory.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/parsing/JavacParserFactory.java
@@ -26,6 +26,7 @@
 import java.util.logging.Logger;
 import org.netbeans.api.editor.mimelookup.MimeLookup;
 import org.netbeans.api.editor.mimelookup.MimeRegistration;
+import org.netbeans.modules.java.source.NoJavacHelper;
 import org.netbeans.modules.parsing.api.Snapshot;
 import org.netbeans.modules.parsing.spi.ParserFactory;
 import org.openide.filesystems.FileObject;
@@ -49,6 +50,8 @@ public JavacParserFactory() {
     
     @Override
     public JavacParser createParser(final Collection<Snapshot> snapshots) {
+        if (!NoJavacHelper.hasWorkingJavac())
+            return null;
         assert snapshots != null;
         if (snapshots.size() == 1) {
             final FileObject fo = snapshots.iterator().next().getSource().getFileObject();
diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/ModuleFileManager.java b/java.source.base/src/org/netbeans/modules/java/source/parsing/ModuleFileManager.java
index 4f0770fc4..914facef5 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/parsing/ModuleFileManager.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/parsing/ModuleFileManager.java
@@ -42,6 +42,7 @@
 import org.netbeans.api.annotations.common.NullUnknown;
 import org.netbeans.api.java.classpath.ClassPath;
 import org.netbeans.api.java.source.SourceUtils;
+import org.netbeans.modules.java.source.base.SourceLevelUtils;
 import org.netbeans.modules.java.source.util.Iterators;
 import org.openide.util.Exceptions;
 
@@ -94,7 +95,7 @@ public ModuleFileManager(
         try {
             final List<Iterable<JavaFileObject>> res = new ArrayList<>();
             List<? extends String> prefixes = null;
-            final boolean supportsMultiRelease = sourceLevel != null && sourceLevel.compareTo(Source.JDK1_9) >= 0;
+            final boolean supportsMultiRelease = sourceLevel != null && sourceLevel.compareTo(SourceLevelUtils.JDK1_9) >= 0;
             for (URL root : ml.getModuleRoots()) {
                 final Archive archive = cap.getArchive(root, cacheFile);
                 if (archive != null) {
@@ -164,7 +165,7 @@ public JavaFileObject getJavaFileForInput (
             @NonNull final JavaFileObject.Kind kind) {
         final ModuleLocation ml = ModuleLocation.cast(l);
         final String[] namePair = FileObjects.getParentRelativePathAndName(className);
-        final boolean supportsMultiRelease = sourceLevel != null && sourceLevel.compareTo(Source.JDK1_9)>= 0;
+        final boolean supportsMultiRelease = sourceLevel != null && sourceLevel.compareTo(SourceLevelUtils.JDK1_9) >= 0;
         List<? extends String> reloc = null;
         for (URL root : ml.getModuleRoots()) {
             try {
@@ -329,7 +330,7 @@ private JavaFileObject findFile(
         assert pkgName != null;
         assert relativeName != null;
         final String resourceName = FileObjects.resolveRelativePath(pkgName,relativeName);
-        final boolean supportsMultiRelease = sourceLevel != null && sourceLevel.compareTo(Source.JDK1_9) >= 0;
+        final boolean supportsMultiRelease = sourceLevel != null && sourceLevel.compareTo(SourceLevelUtils.JDK1_9) >= 0;
         List<? extends String> reloc = null;
         for (URL root : ml.getModuleRoots()) {
             try {
@@ -388,7 +389,7 @@ private static void logListedFiles(
         prefixes.add("");   //NOI18N
         final Source[] sources = Source.values();
         for (int i=0; i< sources.length; i++) {
-            if (sources[i].compareTo(Source.JDK1_9) >=0 && sources[i].compareTo(sourceLevel) <=0) {
+            if (sources[i].compareTo(SourceLevelUtils.JDK1_9) >=0 && sources[i].compareTo(sourceLevel) <=0) {
                 prefixes.add(String.format(
                         "META-INF/versions/%s",    //NOI18N
                         normalizeSourceLevel(sources[i].name)));
diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/ModuleOraculum.java b/java.source.base/src/org/netbeans/modules/java/source/parsing/ModuleOraculum.java
index b558db2e3..e89bc5010 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/parsing/ModuleOraculum.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/parsing/ModuleOraculum.java
@@ -182,7 +182,6 @@ private String computeModuleIfAbsent(
     @NonNull
     private static String parsePackage(FileObject file) {
         String pkg = "";    //NOI18N
-        try {
             final JavacTaskImpl jt = JavacParser.createJavacTask(
                     new ClasspathInfo.Builder(ClassPath.EMPTY).build(),
                     null,
@@ -192,22 +191,16 @@ private static String parsePackage(FileObject file) {
                     null,
                     null,
                     null,
-                    null);
-            final CompilationUnitTree cu =  jt.parse(FileObjects.fileObjectFileObject(
+                    Collections.singletonList(FileObjects.fileObjectFileObject(
                     file,
                     file.getParent(),
                     null,
-                    FileEncodingQuery.getEncoding(file))).iterator().next();
+                    FileEncodingQuery.getEncoding(file))));
+            final CompilationUnitTree cu =  jt.parse().iterator().next();
             pkg = Optional.ofNullable(cu.getPackage())
                     .map((pt) -> pt.getPackageName())
                     .map((xt) -> xt.toString())
                     .orElse(pkg);
-        } catch (IOException ioe) {
-            LOG.log(
-                    Level.INFO,
-                    "Cannot parse: {0}",
-                    FileUtil.getFileDisplayName(file));
-        }
         return pkg;
     }
 
diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/OutputFileManager.java b/java.source.base/src/org/netbeans/modules/java/source/parsing/OutputFileManager.java
index cad92d604..65bf36e61 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/parsing/OutputFileManager.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/parsing/OutputFileManager.java
@@ -21,13 +21,14 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.net.MalformedURLException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.HashSet;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -35,7 +36,6 @@
 import java.util.logging.Logger;
 import java.util.stream.Collectors;
 import java.util.stream.StreamSupport;
-import javax.tools.JavaFileManager;
 import javax.tools.JavaFileManager.Location;
 import javax.tools.JavaFileObject;
 import javax.tools.JavaFileObject.Kind;
@@ -172,7 +172,6 @@ public OutputFileManager(
         return tx.createFileObject(l, file, activeRoot,null,null);
     }
 
-
     @Override
     public javax.tools.FileObject getFileForInput(Location l, String pkgName, String relativeName) {
         final String[] names = FileObjects.getFolderAndBaseName(
diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/ParsingUtils.java b/java.source.base/src/org/netbeans/modules/java/source/parsing/ParsingUtils.java
new file mode 100644
index 000000000..e47840596
--- /dev/null
+++ b/java.source.base/src/org/netbeans/modules/java/source/parsing/ParsingUtils.java
@@ -0,0 +1,53 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.source.parsing;
+
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.parser.ParserFactory;
+import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
+import com.sun.tools.javac.util.Log;
+import java.io.IOException;
+import javax.tools.JavaFileObject;
+
+/**
+ *
+ * @author lahvac
+ */
+public class ParsingUtils {
+    
+    public static CompilationUnitTree parseArbitrarySource(JavacTask task, JavaFileObject file) throws IOException {
+        JavacTaskImpl taskImpl = (JavacTaskImpl) task;
+        com.sun.tools.javac.util.Context context = taskImpl.getContext();
+        Log log = Log.instance(context);
+        JavaFileObject prevSource = log.useSource(file);
+        try {
+            ParserFactory fac = ParserFactory.instance(context);
+            JCCompilationUnit cut = fac.newParser(file.getCharContent(true), true, true, true).parseCompilationUnit();
+            
+            cut.sourcefile = file;
+            
+            return cut;
+        } finally {
+            log.useSource(prevSource);
+        }
+    }
+    
+}
diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/ProxyFileManager.java b/java.source.base/src/org/netbeans/modules/java/source/parsing/ProxyFileManager.java
index 4bec852f5..2fb834808 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/parsing/ProxyFileManager.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/parsing/ProxyFileManager.java
@@ -1068,4 +1068,7 @@ boolean hasLocation() {
             }
         }
     }
+    public boolean contains(Location l, FileObject f) {
+        return true;
+    }
 }
diff --git a/java.source.base/src/org/netbeans/modules/java/source/pretty/ImportAnalysis2.java b/java.source.base/src/org/netbeans/modules/java/source/pretty/ImportAnalysis2.java
index 0720bcd3d..47b956101 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/pretty/ImportAnalysis2.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/pretty/ImportAnalysis2.java
@@ -27,7 +27,7 @@
 import com.sun.source.tree.MemberSelectTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.Tree.Kind;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.tools.javac.comp.Modules;
 import com.sun.tools.javac.model.JavacElements;
 import com.sun.tools.javac.util.Context;
@@ -178,7 +178,7 @@ private String getFQN(ImportTree imp) {
     private String getFQN(Tree expression) {
         final StringBuffer result = new StringBuffer();
 
-        new TreeScanner<Void, Void>() {
+        new ErrorAwareTreeScanner<Void, Void>() {
 
             @Override
             public Void visitMemberSelect(MemberSelectTree tree, Void p) {
@@ -402,7 +402,7 @@ private PackageElement getPackageOf(Element el) {
         
         usedImplicitlyImportedClassesCache = new HashMap<String, Element>();
         
-        new TreeScanner<Void, Void>() {
+        new ErrorAwareTreeScanner<Void, Void>() {
             @Override
             public Void visitIdentifier(IdentifierTree node, Void p) {
                 Element e = overlay.wrap(model, elements, model.getElement(node));
diff --git a/java.source.base/src/org/netbeans/modules/java/source/pretty/VeryPretty.java b/java.source.base/src/org/netbeans/modules/java/source/pretty/VeryPretty.java
index 81fc43da3..556aac3cc 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/pretty/VeryPretty.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/pretty/VeryPretty.java
@@ -32,7 +32,7 @@
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 
 import com.sun.source.doctree.AttributeTree;
 import com.sun.source.doctree.AttributeTree.ValueKind;
@@ -496,7 +496,7 @@ private void doPrintOriginalTree(java.util.List<? extends JCTree> toPrint, final
         final int newStart = out.length() + initialOffset;
 
         final int[] realEnd = {endPos(lastTree)};
-        new TreeScanner<Void, Void>() {
+        new ErrorAwareTreeScanner<Void, Void>() {
             @Override
             public Void scan(Tree node, Void p) {
                 if (node != null) {
@@ -2560,7 +2560,7 @@ public Void visitOther(DocTree node, Void p) {
         return null;
     }
 
-    private final class Linearize extends TreeScanner<Boolean, java.util.List<Tree>> {
+    private final class Linearize extends ErrorAwareTreeScanner<Boolean, java.util.List<Tree>> {
         @Override
         public Boolean scan(Tree node, java.util.List<Tree> p) {
             p.add(node);
@@ -2573,7 +2573,7 @@ public Boolean reduce(Boolean r1, Boolean r2) {
         }
     }
 
-    private final class CopyTags extends TreeScanner<Void, java.util.List<Tree>> {
+    private final class CopyTags extends ErrorAwareTreeScanner<Void, java.util.List<Tree>> {
         private final CompilationUnitTree fake;
         private final SourcePositions sp;
         public CopyTags(CompilationUnitTree fake, SourcePositions sp) {
@@ -2603,20 +2603,16 @@ private void adjustSpans(Iterable<? extends Tree> original, String code) {
             return; //nothing to  copy
         }
         
-        try {
             ClassPath empty = ClassPathSupport.createClassPath(new URL[0]);
             ClasspathInfo cpInfo = ClasspathInfo.create(JavaPlatformManager.getDefault().getDefaultPlatform().getBootstrapLibraries(), empty, empty);
-            JavacTaskImpl javacTask = JavacParser.createJavacTask(cpInfo, null, null, null, null, null, null, null, null);
+            JavacTaskImpl javacTask = JavacParser.createJavacTask(cpInfo, null, null, null, null, null, null, null, Arrays.asList(FileObjects.memoryFileObject("", "Scratch.java", code)));
             com.sun.tools.javac.util.Context ctx = javacTask.getContext();
             JavaCompiler.instance(ctx).genEndPos = true;
-            CompilationUnitTree tree = javacTask.parse(FileObjects.memoryFileObject("", "", code)).iterator().next(); //NOI18N
+            CompilationUnitTree tree = javacTask.parse().iterator().next(); //NOI18N
             SourcePositions sp = JavacTrees.instance(ctx).getSourcePositions();
             ClassTree clazz = (ClassTree) tree.getTypeDecls().get(0);
 
             new CopyTags(tree, sp).scan(clazz.getModifiers().getAnnotations(), linearized);
-        } catch (IOException ex) {
-            Exceptions.printStackTrace(ex);
-        }
     }
 
     private boolean reallyPrintAnnotations;
diff --git a/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java b/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java
index 2d9ff59cb..71f87b6a1 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/save/CasualDiff.java
@@ -26,7 +26,7 @@
 import com.sun.source.util.DocSourcePositions;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.tools.javac.api.JavacTrees;
 import com.sun.tools.javac.code.*;
 import static com.sun.tools.javac.code.Flags.*;
@@ -487,6 +487,16 @@ protected CasualDiff(Context context, DiffContext diffContext, TreeUtilities tre
         // TODO: the package name actually ends at the end of the name, so the semicolon could be treated as part
         // of the diffed list
         int start = td.oldTopLevel.getPackage() != null ? td.endPos(td.oldTopLevel.getPackage()) : 0;
+        
+        //XXX: no-javac-patch:
+        td.tokenSequence.move(start);
+        
+        while (td.tokenSequence.movePrevious()) {
+            if (td.isNoop(td.tokenSequence.token().id())) {
+                start = td.tokenSequence.offset();
+            }
+        }
+        //XXX: no-javac-patch end
 
         List<JCImport> originalJC = new LinkedList<JCImport>();
         List<JCImport> nueJC = new LinkedList<JCImport>();
@@ -1597,6 +1607,18 @@ private boolean isComment(JavaTokenId tid) {
         }
     }
 
+    private boolean isNoop(JavaTokenId tid) {
+        switch (tid) {
+            case LINE_COMMENT:
+            case BLOCK_COMMENT:
+            case JAVADOC_COMMENT:
+            case WHITESPACE:
+                return true;
+            default:
+                return false;
+        }
+    }
+
     private int dimension(JCTree t, int afterPos) {
         if (t.getKind() != Kind.ARRAY_TYPE) {
             return 0;
@@ -5055,7 +5077,7 @@ private int getPosAfterCommentStart(Tree t, int minPos) {
     }
     
     private int getPosAfterTreeComments(JCTree t, int end) {
-        class Scn extends TreeScanner<Void, Void> {
+        class Scn extends ErrorAwareTreeScanner<Void, Void> {
             int max = -1;
             
             @Override
@@ -5675,7 +5697,7 @@ private int getCommentCorrectedOldPos(JCTree tree) {
 
     private int getCommentCorrectedEndPos(JCTree tree) {
         final int[] res = new int[] {endPos(tree)};
-        new TreeScanner<Void, Void>() {
+        new ErrorAwareTreeScanner<Void, Void>() {
             @Override public Void scan(Tree node, Void p) {
                 if (node != null) {
                     CommentSet ch = comments.getComments(node);
diff --git a/java.source.base/src/org/netbeans/modules/java/source/save/Reformatter.java b/java.source.base/src/org/netbeans/modules/java/source/save/Reformatter.java
index 1daebe211..433493d70 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/save/Reformatter.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/save/Reformatter.java
@@ -44,6 +44,7 @@
 import org.netbeans.api.java.platform.JavaPlatformManager;
 import org.netbeans.api.java.source.*;
 import org.netbeans.api.java.source.CodeStyle.WrapStyle;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import org.netbeans.api.lexer.Token;
 import org.netbeans.api.lexer.TokenHierarchy;
 import org.netbeans.api.lexer.TokenSequence;
@@ -51,6 +52,7 @@
 import org.netbeans.modules.editor.indent.spi.ExtraLock;
 import org.netbeans.modules.editor.indent.spi.ReformatTask;
 import org.netbeans.modules.java.source.JavaSourceAccessor;
+import org.netbeans.modules.java.source.NoJavacHelper;
 import org.netbeans.modules.java.source.parsing.FileObjects;
 import org.netbeans.modules.java.source.parsing.JavacParser;
 import org.netbeans.modules.parsing.api.Embedding;
@@ -105,13 +107,12 @@ public static String reformat(String text, CodeStyle style) {
 
     public static String reformat(String text, CodeStyle style, int rightMargin) {
         StringBuilder sb = new StringBuilder(text);
-        try {
             ClassPath empty = ClassPathSupport.createClassPath(new URL[0]);
             ClasspathInfo cpInfo = ClasspathInfo.create(JavaPlatformManager.getDefault().getDefaultPlatform().getBootstrapLibraries(), empty, empty);
-            JavacTaskImpl javacTask = JavacParser.createJavacTask(cpInfo, null, null, null, null, null, null, null, null);
+            JavacTaskImpl javacTask = JavacParser.createJavacTask(cpInfo, null, null, null, null, null, null, null, Arrays.asList(FileObjects.memoryFileObject("","Scratch.java", text)));
             com.sun.tools.javac.util.Context ctx = javacTask.getContext();
             JavaCompiler.instance(ctx).genEndPos = true;
-            CompilationUnitTree tree = javacTask.parse(FileObjects.memoryFileObject("","", text)).iterator().next(); //NOI18N
+            CompilationUnitTree tree = javacTask.parse().iterator().next(); //NOI18N
             SourcePositions sp = JavacTrees.instance(ctx).getSourcePositions();
             TokenSequence<JavaTokenId> tokens = TokenHierarchy.create(text, JavaTokenId.language()).tokenSequence(JavaTokenId.language());
             for (Diff diff : Pretty.reformat(text, tokens, new TreePath(tree), sp, style, rightMargin)) {
@@ -124,8 +125,6 @@ public static String reformat(String text, CodeStyle style, int rightMargin) {
                 }
             }
 
-        } catch (IOException ioe) {
-        }
         return sb.toString();
     }
     
@@ -386,12 +385,14 @@ private TreePath getCommonPath(int startOffset, int endOffset) {
     public static class Factory implements ReformatTask.Factory {
 
         public ReformatTask createTask(Context context) {
+            if (!NoJavacHelper.hasWorkingJavac())
+                return null;
             Source source = Source.create(context.document());
             return source != null ? new Reformatter(source, context) : null;
         }        
     }
 
-    private static class Pretty extends TreePathScanner<Boolean, Void> {
+    private static class Pretty extends ErrorAwareTreePathScanner<Boolean, Void> {
 
         private static final String OPERATOR = "operator"; //NOI18N
         private static final String EMPTY = ""; //NOI18N
diff --git a/java.source.base/src/org/netbeans/modules/java/source/save/Reindenter.java b/java.source.base/src/org/netbeans/modules/java/source/save/Reindenter.java
index 76183ae18..c0e247e63 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/save/Reindenter.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/save/Reindenter.java
@@ -43,7 +43,7 @@
 import com.sun.source.tree.VariableTree;
 import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.util.SourcePositions;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.tools.javac.api.JavacTaskImpl;
 import com.sun.tools.javac.api.JavacTool;
 import com.sun.tools.javac.api.JavacTrees;
@@ -65,6 +65,8 @@
 import javax.tools.DiagnosticListener;
 import javax.tools.JavaFileObject;
 
+import com.sun.tools.javac.parser.ParserFactory;
+import com.sun.tools.javac.util.Log;
 import org.netbeans.api.java.lexer.JavaTokenId;
 import org.netbeans.api.java.source.CodeStyle;
 import org.netbeans.api.lexer.TokenHierarchy;
@@ -73,8 +75,12 @@
 import org.netbeans.modules.editor.indent.spi.Context.Region;
 import org.netbeans.modules.editor.indent.spi.ExtraLock;
 import org.netbeans.modules.editor.indent.spi.IndentTask;
+import org.netbeans.modules.java.source.NoJavacHelper;
+import org.netbeans.modules.java.source.TreeUtilitiesAccessor;
 import org.netbeans.modules.java.source.parsing.FileObjects;
 import org.netbeans.modules.java.source.parsing.JavacParser;
+import org.netbeans.modules.java.source.parsing.ParsingUtils;
+import org.netbeans.modules.java.source.parsing.PrefetchableJavaFileObject;
 import org.netbeans.modules.parsing.impl.Utilities;
 import org.openide.filesystems.FileObject;
 
@@ -223,13 +229,13 @@ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
                 text = context.document().getText(currentEmbeddingStartOffset, currentEmbeddingLength);
                 if (JavacParser.MIME_TYPE.equals(context.mimePath())) {
                     FileObject fo = Utilities.getFileObject(context.document());
-                    cut = javacTask.parse(FileObjects.memoryFileObject("", fo != null ? fo.getNameExt() : "", text)).iterator().next(); //NOI18N
+                    cut = ParsingUtils.parseArbitrarySource(javacTask, FileObjects.memoryFileObject("", fo != null ? fo.getNameExt() : "", text));
                     parsedTree = cut;
                     sp = JavacTrees.instance(ctx).getSourcePositions();
                 } else {
                     final SourcePositions[] psp = new SourcePositions[1];
                     cut = null;
-                    parsedTree = javacTask.parseStatement("{" + text + "}", psp);
+                    parsedTree = TreeUtilitiesAccessor.getInstance().parseStatement(javacTask, "{" + text + "}", psp);
                     sp = new SourcePositions() {
                         @Override
                         public long getStartPosition(CompilationUnitTree file, Tree tree) {
@@ -834,7 +840,7 @@ private int getEndPosition(Tree last) {
                 ts.token().id().primaryCategory().equals("literal")) //NOI18N
                 ? ts.offset() : startOffset;
 
-        new TreeScanner<Void, Void>() {
+        new ErrorAwareTreeScanner<Void, Void>() {
 
             @Override
             public Void scan(Tree node, Void p) {
@@ -1198,6 +1204,8 @@ private int getCol(String text) {
 
         @Override
         public IndentTask createTask(Context context) {
+            if (!NoJavacHelper.hasWorkingJavac())
+                return null;
             return new Reindenter(context);
         }
     }
diff --git a/java.source.base/src/org/netbeans/modules/java/source/usages/SourceAnalyzerFactory.java b/java.source.base/src/org/netbeans/modules/java/source/usages/SourceAnalyzerFactory.java
index 609265dae..aad480c90 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/usages/SourceAnalyzerFactory.java
+++ b/java.source.base/src/org/netbeans/modules/java/source/usages/SourceAnalyzerFactory.java
@@ -19,8 +19,8 @@
 package org.netbeans.modules.java.source.usages;
 
 import com.sun.source.tree.*;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import com.sun.tools.javac.api.JavacTaskImpl;
 import com.sun.tools.javac.code.Kinds;
@@ -271,7 +271,7 @@ protected final void addClassReferences (final Pair<BinaryName,String> name, fin
         }
     }
         
-    private static class UsagesVisitor extends TreePathScanner<Void,Map<Pair<BinaryName,String>,UsagesData<String>>> {
+    private static class UsagesVisitor extends ErrorAwareTreePathScanner<Void,Map<Pair<BinaryName,String>,UsagesData<String>>> {
 
         enum State {EXTENDS, IMPLEMENTS, GT, OTHER, IMPORT, PACKAGE_ANN};
 
@@ -827,7 +827,7 @@ public Void visitModule(
                 activeClass.push(name);
                 try {
                     addAndClearImports(name, p);
-                    node.accept(new TreeScanner<Void, Set<Symbol>>() {
+                    node.accept(new ErrorAwareTreeScanner<Void, Set<Symbol>>() {
                                 @Override
                                 public Void visitExports(ExportsTree node, Set<Symbol> p) {
                                     final Symbol sym = ((JCTree.JCExports)node).directive.packge;
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/APIIsSelfContainedTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/APIIsSelfContainedTest.java
index a3363bff9..579e1f73b 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/APIIsSelfContainedTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/APIIsSelfContainedTest.java
@@ -187,8 +187,6 @@ private void verifySelfContainedAPI(Element e, TypeElement in) {
         
         return new FileObject[] {
             FileUtil.getArchiveRoot(root.getFileObject("java/modules/org-netbeans-modules-java-source.jar")),
-            FileUtil.getArchiveRoot(root.getFileObject("java/modules/ext/nb-javac-api.jar")),
-            FileUtil.getArchiveRoot(root.getFileObject("java/modules/ext/nb-javac-impl.jar")),
         };
     }
     
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/CommentCollectorTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/CommentCollectorTest.java
index 92aa8dc96..e5cef1a3b 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/CommentCollectorTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/CommentCollectorTest.java
@@ -19,7 +19,7 @@
 package org.netbeans.api.java.source;
 
 import com.sun.source.tree.*;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.JCClassDecl;
 import org.junit.Test;
@@ -127,7 +127,7 @@ public void run(WorkingCopy workingCopy) throws Exception {
                 cu.accept(printer, null);
 
 
-                TreeVisitor<Void, Void> w = new TreeScanner<Void, Void>() {
+                TreeVisitor<Void, Void> w = new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(MethodTree node, Void aVoid) {
                         switch (node.getName().toString()) {
@@ -205,7 +205,7 @@ public void run(WorkingCopy workingCopy) throws Exception {
                 cu.accept(printer, null);
 
 
-                TreeVisitor<Void, Void> w = new TreeScanner<Void, Void>() {
+                TreeVisitor<Void, Void> w = new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitClass(ClassTree node, Void aVoid) {
                         verify(node, CommentSet.RelativePosition.PRECEDING, service, "/** (COMM1) This comment belongs before class */");
@@ -282,7 +282,7 @@ public void run(WorkingCopy workingCopy) throws Exception {
 
                 JCTree.JCClassDecl clazz = (JCTree.JCClassDecl) cu.getTypeDecls().get(0);
                 final boolean[] processed = new boolean[1];
-                TreeVisitor<Void, Void> w = new TreeScanner<Void, Void>() {
+                TreeVisitor<Void, Void> w = new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitExpressionStatement(ExpressionStatementTree node, Void p) {
                         verify(node, CommentSet.RelativePosition.PRECEDING, service, "// Test");
@@ -329,7 +329,7 @@ public void run(WorkingCopy workingCopy) throws Exception {
                 cu.accept(printer, null);
 
                 JCTree.JCClassDecl clazz = (JCTree.JCClassDecl) cu.getTypeDecls().get(0);
-                TreeVisitor<Void, Void> w = new TreeScanner<Void, Void>() {
+                TreeVisitor<Void, Void> w = new ErrorAwareTreeScanner<Void, Void>() {
 
                     @Override
                     public Void visitReturn(ReturnTree node, Void aVoid) {
@@ -382,7 +382,7 @@ public void run(final WorkingCopy workingCopy) throws Exception {
                 workingCopy.toPhase(JavaSource.Phase.PARSED);
                 final CommentHandlerService service = CommentHandlerService.instance(workingCopy.impl.getJavacTask().getContext());
 
-                TreeScanner<Void, Void> w = new TreeScanner<Void, Void>() {
+                ErrorAwareTreeScanner<Void, Void> w = new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitVariable(VariableTree node, Void p) {
                         GeneratorUtilities.get(workingCopy).importComments(node, workingCopy.getCompilationUnit());
@@ -433,7 +433,7 @@ public void run(final WorkingCopy workingCopy) throws Exception {
                 workingCopy.toPhase(JavaSource.Phase.PARSED);
                 final CommentHandlerService service = CommentHandlerService.instance(workingCopy.impl.getJavacTask().getContext());
 
-                TreeScanner<Void, Void> w = new TreeScanner<Void, Void>() {
+                ErrorAwareTreeScanner<Void, Void> w = new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(MethodTree node, Void p) {
                         if (node.getName().contentEquals("m3")) {
@@ -471,7 +471,7 @@ public void run(final WorkingCopy workingCopy) throws Exception {
                 workingCopy.toPhase(JavaSource.Phase.PARSED);
                 final CommentHandlerService service = CommentHandlerService.instance(workingCopy.impl.getJavacTask().getContext());
 
-                TreeScanner<Void, Void> w = new TreeScanner<Void, Void>() {
+                ErrorAwareTreeScanner<Void, Void> w = new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(MethodTree node, Void p) {
                         GeneratorUtilities.get(workingCopy).importComments(node, workingCopy.getCompilationUnit());
@@ -517,7 +517,7 @@ public void run(final WorkingCopy workingCopy) throws Exception {
                 workingCopy.toPhase(JavaSource.Phase.PARSED);
                 final CommentHandlerService service = CommentHandlerService.instance(workingCopy.impl.getJavacTask().getContext());
 
-                TreeScanner<Void, Void> w = new TreeScanner<Void, Void>() {
+                ErrorAwareTreeScanner<Void, Void> w = new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(MethodTree node, Void p) {
                         if (node.getName().contentEquals("test")) {
@@ -552,7 +552,7 @@ public void run(final WorkingCopy workingCopy) throws Exception {
                 workingCopy.toPhase(JavaSource.Phase.PARSED);
                 final CommentHandlerService service = CommentHandlerService.instance(workingCopy.impl.getJavacTask().getContext());
 
-                TreeScanner<Void, Void> w = new TreeScanner<Void, Void>() {
+                ErrorAwareTreeScanner<Void, Void> w = new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitClass(ClassTree node, Void p) {
                         GeneratorUtilities.get(workingCopy).importComments(node, workingCopy.getCompilationUnit());
@@ -746,7 +746,7 @@ void verify(Tree tree, CommentSet.RelativePosition position, CommentHandler serv
         }
     }
 
-    private static class CommentPrinter extends TreeScanner<Void, Void> {
+    private static class CommentPrinter extends ErrorAwareTreeScanner<Void, Void> {
         private CommentHandlerService service;
 
         CommentPrinter(CommentHandlerService service) {
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/ElementHandleTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/ElementHandleTest.java
index b36f5adf4..83e9add71 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/ElementHandleTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/ElementHandleTest.java
@@ -43,6 +43,7 @@
 import javax.lang.model.type.TypeMirror;
 import org.netbeans.api.java.classpath.ClassPath;
 import org.netbeans.junit.NbTestCase;
+import org.netbeans.modules.java.source.ElementUtils;
 import org.netbeans.modules.java.source.usages.IndexUtil;
 import org.netbeans.spi.java.classpath.ClassPathProvider;
 import org.netbeans.spi.java.classpath.support.ClassPathSupport;
@@ -171,7 +172,7 @@ public void run(CompilationController parameter) {
                     }
                 }
                 assertNotNull (retentionPolicyClassHandle[0]);
-                Element csl = elements.getTypeElementByBinaryName("java.util.Collections$SingletonList");
+                Element csl = ElementUtils.getTypeElementByBinaryName(parameter, "java.util.Collections$SingletonList");
                 assertNotNull (csl);
                 innerClassHandle[0] = ElementHandle.create(csl);
                 assertNotNull (innerClassHandle[0]);
@@ -179,16 +180,16 @@ public void run(CompilationController parameter) {
                 assertNotNull (cadd);
                 collectionAddHandle[0] = ElementHandle.create(cadd);
                 assertNotNull (collectionAddHandle[0]);
-                TypeElement annonClass = elements.getTypeElementByBinaryName("java.lang.String$1"); //NOI18N
+                TypeElement annonClass = ElementUtils.getTypeElementByBinaryName(parameter, "java.lang.String$1"); //NOI18N
                 assertNotNull (annonClass);
                 annonClassHandle[0] = ElementHandle.create(annonClass);
                 assertNotNull (annonClassHandle[0]);
-                TypeElement listClass = elements.getTypeElementByBinaryName("java.util.List"); //NOI18N
+                TypeElement listClass = ElementUtils.getTypeElementByBinaryName(parameter, "java.util.List"); //NOI18N
                 assertNotNull(listClass);
                 List<? extends TypeParameterElement> tpes = listClass.getTypeParameters();
                 assertEquals(tpes.size(), 1);
                 genParList[0] = ElementHandle.create(tpes.get(0));
-                TypeElement collsClass = elements.getTypeElementByBinaryName("java.util.Collections"); //NOI18N
+                TypeElement collsClass = ElementUtils.getTypeElementByBinaryName(parameter, "java.util.Collections"); //NOI18N
                 assertNotNull(collsClass);
                 for (Element member : collsClass.getEnclosedElements()) {
                     if (member.getKind() == ElementKind.METHOD && member.getSimpleName().contentEquals("min")) {
@@ -249,7 +250,7 @@ public void run(CompilationController parameter) {
                 assertEquals(resolved,retentionClassElement);
                 resolved = innerClassHandle[0].resolve(parameter);
                 assertNotNull (resolved);
-                Element csl = elements.getTypeElementByBinaryName("java.util.Collections$SingletonList");
+                Element csl = ElementUtils.getTypeElementByBinaryName(parameter, "java.util.Collections$SingletonList");
                 assertNotNull (csl);
                 assertEquals(resolved,csl);
                 resolved = collectionAddHandle[0].resolve(parameter);
@@ -259,18 +260,18 @@ public void run(CompilationController parameter) {
                 assertEquals (resolved, cadd);
                 resolved = annonClassHandle[0].resolve(parameter);
                 assertNotNull (resolved);
-                TypeElement annonClass = elements.getTypeElementByBinaryName("java.lang.String$1"); //NOI18N
+                TypeElement annonClass = ElementUtils.getTypeElementByBinaryName(parameter, "java.lang.String$1"); //NOI18N
                 assertNotNull (annonClass);
                 assertEquals(resolved,annonClass);
                 
-                TypeElement listClass = elements.getTypeElementByBinaryName("java.util.List"); //NOI18N
+                TypeElement listClass = ElementUtils.getTypeElementByBinaryName(parameter, "java.util.List"); //NOI18N
                 assertNotNull(listClass);
                 TypeParameterElement tpe = listClass.getTypeParameters().get(0);
                 resolved = genParList[0].resolve(parameter);
                 assertEquals(tpe, resolved);
                 
                 tpe = null;
-                TypeElement collsClass = elements.getTypeElementByBinaryName("java.util.Collections"); //NOI18N
+                TypeElement collsClass = ElementUtils.getTypeElementByBinaryName(parameter, "java.util.Collections"); //NOI18N
                 assertNotNull(collsClass);
                 for (Element member : collsClass.getEnclosedElements()) {
                     if (member.getKind() == ElementKind.METHOD && member.getSimpleName().contentEquals("min")) {
@@ -345,7 +346,7 @@ public void run(CompilationController parameter) {
                 assertNotNull (cadd);
                 collectionAddHandle[0] = ElementHandle.create(cadd);
                 assertNotNull (collectionAddHandle[0]);
-                TypeElement annonClass = elements.getTypeElementByBinaryName("java.lang.String$1"); //NOI18N
+                TypeElement annonClass = ElementUtils.getTypeElementByBinaryName(parameter, "java.lang.String$1"); //NOI18N
                 assertNotNull (annonClass);
                 annonClassHandle[0] = ElementHandle.create(annonClass);
                 assertNotNull (annonClassHandle[0]);
@@ -383,13 +384,13 @@ public void run(CompilationController parameter) {
                 }
                 assertNotNull (retentionClassElement);
                 assertTrue(retentionPolicyClassHandle[0].signatureEquals(retentionClassElement));
-                Element csl = elements.getTypeElementByBinaryName("java.util.Collections$SingletonList");
+                Element csl = ElementUtils.getTypeElementByBinaryName(parameter, "java.util.Collections$SingletonList");
                 assertNotNull (csl);
                 assertTrue(innerClassHandle[0].signatureEquals(csl));
                 Element cadd = getCollectionAdd(elements.getTypeElement(java.util.Collection.class.getName()));
                 assertNotNull(cadd);
                 assertTrue (collectionAddHandle[0].signatureEquals(cadd));
-                TypeElement annonClass = elements.getTypeElementByBinaryName("java.lang.String$1"); //NOI18N
+                TypeElement annonClass = ElementUtils.getTypeElementByBinaryName(parameter, "java.lang.String$1"); //NOI18N
                 assertNotNull (annonClass);
                 assertTrue(annonClassHandle[0].signatureEquals(annonClass));
             }
@@ -483,7 +484,7 @@ public void run(CompilationController parameter) {
                 assertNotNull (cadd);
                 collectionAddHandle[0] = ElementHandle.create(cadd);
                 assertNotNull (collectionAddHandle[0]);
-                TypeElement annonClass = elements.getTypeElementByBinaryName("java.lang.String$1"); //NOI18N
+                TypeElement annonClass = ElementUtils.getTypeElementByBinaryName(parameter, "java.lang.String$1"); //NOI18N
                 assertNotNull (annonClass);
                 annonClassHandle[0] = ElementHandle.create(annonClass);
                 assertNotNull (annonClassHandle[0]);
@@ -565,7 +566,7 @@ public void run(CompilationController parameter) {
                 assertEquals("java.lang.annotation.RetentionPolicy", handle.getBinaryName());
                 assertEquals("java.lang.annotation.RetentionPolicy", handle.getQualifiedName());
                 
-                element = elements.getTypeElementByBinaryName("java.util.Collections$SingletonList");
+                element = ElementUtils.getTypeElementByBinaryName(parameter, "java.util.Collections$SingletonList");
                 assertNotNull (element);                
                 handle = ElementHandle.create(element);
                 assertEquals("java.util.Collections$SingletonList", handle.getBinaryName());
@@ -597,7 +598,7 @@ public void testTypesRankNPE () throws Exception {
 
             public void run(CompilationController parameter) throws Exception {
                 JavacElements elements = (JavacElements) parameter.getElements();
-                TypeElement te = elements.getTypeElementByBinaryName("java.lang.String$1");
+                TypeElement te = ElementUtils.getTypeElementByBinaryName(parameter, "java.lang.String$1");
                 List<? extends Element> content = elements.getAllMembers(te);                
             }
         }, true);
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/JavaSourceTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/JavaSourceTest.java
index 8c0bf2cf2..855379a19 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/JavaSourceTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/JavaSourceTest.java
@@ -44,8 +44,9 @@
 import com.sun.source.tree.*;
 import com.sun.source.util.SimpleTreeVisitor;
 import com.sun.source.util.SourcePositions;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
+import com.sun.tools.javac.api.JavacTaskImpl;
 import junit.framework.*;
 import org.apache.lucene.analysis.Analyzer;
 import org.apache.lucene.document.FieldSelector;
@@ -160,6 +161,8 @@ public static Test suite() {
         suite.addTest(new JavaSourceTest("testModificationJob"));
 //        suite.addTest(new JavaSourceTest("testInterference"));
         suite.addTest(new JavaSourceTest("testDocumentChanges"));
+        suite.addTest(new JavaSourceTest("testMultipleFiles"));
+        suite.addTest(new JavaSourceTest("testMultipleFilesSameJavac"));
         /*
         suite.addTest(new JavaSourceTest("testParsingDelay"));
 //        suite.addTest(new JavaSourceTest("testJavaSourceIsReclaimable"));     fails in trunk
@@ -261,6 +264,59 @@ public void testModificationJob () throws Exception {
         assertTrue ("Time out",latch.await(15,TimeUnit.SECONDS));
     }
 
+    public void testMultipleFiles () throws Exception {
+        final FileObject testFile1 = createTestFile("Test1");
+        final FileObject testFile2 = createTestFile("Test2");
+        final ClassPath bootPath = createBootPath();
+        final ClassPath compilePath = createCompilePath();
+        final ClassPath srcPath = createSourcePath();
+        final JavaSource js = JavaSource.create(ClasspathInfo.create(bootPath, compilePath, srcPath), testFile1, testFile2);
+        boolean[] test1 = new boolean[1];
+        boolean[] test2 = new boolean[1];
+        js.runUserActionTask(new Task<CompilationController>() {
+            @Override
+            public void run(CompilationController parameter) throws Exception {
+                parameter.toPhase(Phase.RESOLVED);
+                
+                //TODO: safer checks!
+                if (parameter.getCompilationUnit().toString().contains("Test1")) {
+                    test1[0] = true;
+                } else if (parameter.getCompilationUnit().toString().contains("Test2")) {
+                    test2[0] = true;
+                } else {
+                   fail();
+                }
+            }
+        }, true);
+        assertTrue ("Test1", test1[0]);
+        assertTrue ("Test2", test2[0]);
+    }
+
+    public void testMultipleFilesSameJavac() throws Exception {
+        final FileObject testFile1 = createTestFile("Test1");
+        final FileObject testFile2 = createTestFile("Test2");
+        final ClassPath bootPath = createBootPath();
+        final ClassPath compilePath = createCompilePath();
+        final ClassPath srcPath = createSourcePath();
+        final JavaSource js = JavaSource.create(ClasspathInfo.create(bootPath, compilePath, srcPath), testFile1, testFile2);
+        js.runUserActionTask(new Task<CompilationController>() {
+            private JavacTaskImpl seenTask;
+
+            @Override
+            public void run(CompilationController parameter) throws Exception {
+                parameter.toPhase(Phase.RESOLVED);
+                
+                JavacTaskImpl currentTask = parameter.impl.getJavacTask();
+                
+                if (seenTask == null) {
+                    seenTask= currentTask;
+                } else if (seenTask != currentTask) {
+                   fail();
+                }
+            }
+        }, true);
+    }
+
     public void testInterference () throws MalformedURLException, IOException, InterruptedException {
         FileObject testFile1 = createTestFile ("Test1");
         FileObject testFile2 = createTestFile ("Test2");
@@ -2020,7 +2076,7 @@ public void run (CompilationController controler) {
         }
     }
 
-    private static class ScannerImpl extends TreePathScanner<Void, Void> {
+    private static class ScannerImpl extends ErrorAwareTreePathScanner<Void, Void> {
 
         private CompilationInfo info;
 
@@ -2054,7 +2110,7 @@ public void run (WorkingCopy copy) throws IOException {
         }
     }
 
-    private static class TransformImpl extends TreeScanner<Void, Object> {
+    private static class TransformImpl extends ErrorAwareTreeScanner<Void, Object> {
 
         private WorkingCopy copy;
 
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/SourceUtilsTestUtil.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/SourceUtilsTestUtil.java
index b413ae0d9..8768ba003 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/SourceUtilsTestUtil.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/SourceUtilsTestUtil.java
@@ -28,11 +28,13 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.regex.Pattern;
+import java.util.stream.Collectors;
 import javax.swing.event.ChangeListener;
 import javax.swing.text.Document;
 import junit.framework.Assert;
 import org.netbeans.api.editor.mimelookup.MimePath;
 import org.netbeans.api.java.classpath.ClassPath;
+import org.netbeans.api.java.classpath.JavaClassPathConstants;
 import org.netbeans.api.java.queries.SourceForBinaryQuery;
 import org.netbeans.api.java.source.JavaSource.Phase;
 import org.netbeans.editor.BaseDocument;
@@ -75,7 +77,7 @@
     
     private static SourceUtilsTestUtil DEFAULT_LOOKUP = null;
     private static final Set<String> NB_JAVAC = Collections.unmodifiableSet(new HashSet<String>(
-        Arrays.asList("nb-javac-api.jar","nb-javac-impl.jar")));    //NOI18N
+        Arrays.asList("nb-javac-api.jar","nb-javac-impl.jar", "vanilla-javac-api.jar")));    //NOI18N
     
     public SourceUtilsTestUtil() {
 //        Assert.assertNull(DEFAULT_LOOKUP);
@@ -217,37 +219,14 @@ public static void compileRecursively(FileObject sourceRoot) throws Exception {
     
     public static synchronized List<URL> getBootClassPath() {
         if (bootClassPath == null) {
-            try {
-                String cp = System.getProperty("sun.boot.class.path");
-                String tools = System.getProperty("tools.jar.location");
-                if (tools != null) {
-                    cp = cp + System.getProperty("path.separator") + tools;
-                }
-                List<URL> urls = new ArrayList<URL>();
-                for (String path : cp.split(Pattern.quote(System.getProperty("path.separator")))) {
-                    final File f = new File(path);
-                    if (!f.canRead())
-                        continue;
-                    //Remove nb-javac-impl.jar & nb-javac-api.jar added to test as boot prepend
-                    if (NB_JAVAC.contains(f.getName())) {
-                        continue;
-                    }
-
-                    FileObject fo = FileUtil.toFileObject(f);
-                    
-                    if (FileUtil.isArchiveFile(fo)) {
-                        fo = FileUtil.getArchiveRoot(fo);
-                    }
-                    
-                    if (fo != null) {
-                        urls.add(fo.getURL());
-                    }
-                }
-                bootClassPath = urls;
-            } catch (FileStateInvalidException e) {
-                if (log.isLoggable(Level.SEVERE))
-                    log.log(Level.SEVERE, e.getMessage(), e);
-            }
+            bootClassPath = TestUtil.getBootClassPath()
+                                    .entries()
+                                    .stream()
+                                    .map(e -> e.getURL())
+                                    .filter(u -> {
+                                        return NB_JAVAC.stream().noneMatch(j -> u.getPath().contains(j));
+                                    })
+                                    .collect(Collectors.toList());
         }
 
         return bootClassPath;
@@ -301,7 +280,7 @@ public TestProxyClassPathProvider(FileObject sourceRoot, FileObject buildRoot, F
         
         public ClassPath findClassPath(FileObject file, String type) {
             try {
-            if (ClassPath.BOOT == type) {
+            if (ClassPath.BOOT == type || JavaClassPathConstants.MODULE_BOOT_PATH.equals(type)) {
                 return ClassPathSupport.createClassPath(getBootClassPath().toArray(new URL[0]));
             }
             
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/SourceUtilsTestUtil2.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/SourceUtilsTestUtil2.java
index f1837bb0d..5f8e84f9b 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/SourceUtilsTestUtil2.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/SourceUtilsTestUtil2.java
@@ -20,9 +20,13 @@
 
 import com.sun.source.tree.Tree;
 import org.apache.lucene.store.FSDirectory;
+import org.netbeans.modules.java.source.parsing.JavacParser;
+import org.netbeans.modules.java.source.parsing.JavacParser.TreeLoaderRegistry;
 import org.netbeans.modules.java.source.transform.Transformer;
 import org.netbeans.modules.parsing.lucene.LuceneIndex;
 import org.netbeans.modules.parsing.lucene.support.IndexManagerTestUtilities;
+import org.openide.util.Exceptions;
+import org.openide.util.Lookup;
 
 /**
  *
@@ -55,5 +59,22 @@ private SourceUtilsTestUtil2() {
     
     public static void disableLocks() {
     }
-    
+
+    public static void disableArtificalParameterNames() {
+        try {
+            Class treeLoader = Class.forName("org.netbeans.modules.java.source.nbjavac.parsing.TreeLoader");
+            treeLoader.getField("DISABLE_ARTIFICAL_PARAMETER_NAMES").set(null, true);
+        } catch (Exception ex) {
+            //ignore
+        }
+    }
+
+    public static void disableConfinementTest() {
+        try {
+            Class treeLoader = Class.forName("org.netbeans.modules.java.source.nbjavac.parsing.TreeLoader");
+            treeLoader.getField("DISABLE_CONFINEMENT_TEST").set(null, true);
+        } catch (Exception ex) {
+            //ignore
+        }
+    }
 }
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/TreeUtilitiesTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/TreeUtilitiesTest.java
index 3786376a7..ca0ccbb03 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/TreeUtilitiesTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/TreeUtilitiesTest.java
@@ -21,6 +21,7 @@
 import com.sun.source.tree.AssignmentTree;
 import com.sun.source.tree.BlockTree;
 import com.sun.source.tree.ClassTree;
+import com.sun.source.tree.ExpressionTree;
 import com.sun.source.tree.MemberSelectTree;
 import com.sun.source.tree.MethodTree;
 import com.sun.source.tree.Scope;
@@ -29,8 +30,10 @@
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.File;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -41,6 +44,7 @@
 import javax.lang.model.type.TypeMirror;
 import org.netbeans.api.java.classpath.ClassPath;
 import org.netbeans.api.java.source.Comment.Style;
+import org.netbeans.api.java.source.JavaSource.Phase;
 import org.netbeans.junit.NbTestCase;
 import org.netbeans.spi.java.classpath.support.ClassPathSupport;
 import org.openide.filesystems.FileObject;
@@ -490,7 +494,7 @@ public void testIsCompileTimeConstant() throws Exception {
 
         final List<Boolean> result = new ArrayList<Boolean>();
 
-        new TreePathScanner<Void, Void>() {
+        new ErrorAwareTreePathScanner<Void, Void>() {
             @Override public Void visitAssignment(AssignmentTree node, Void p) {
                 result.add(info.getTreeUtilities().isCompileTimeConstantExpression(new TreePath(getCurrentPath(), node.getExpression())));
                 return super.visitAssignment(node, p);
@@ -511,6 +515,22 @@ public void run(CompilationController parameter) throws Exception {
         }, true);
     }
     
+    public void testStaticBlock() throws Exception {
+        ClassPath boot = ClassPathSupport.createClassPath(SourceUtilsTestUtil.getBootClassPath().toArray(new URL[0]));
+        JavaSource js = JavaSource.create(ClasspathInfo.create(boot, ClassPath.EMPTY, ClassPath.EMPTY));
+        js.runUserActionTask(new Task<CompilationController>() {
+            @Override
+            public void run(CompilationController parameter) throws Exception {
+                final SourcePositions[] sp = new SourcePositions[1];
+                BlockTree block = parameter.getTreeUtilities().parseStaticBlock("static { }", sp);
+                assertNotNull(block);
+                assertEquals(0, sp[0].getStartPosition(null, block));
+                assertEquals(10, sp[0].getEndPosition(null, block));
+                assertNull(parameter.getTreeUtilities().parseStaticBlock("static", new SourcePositions[1]));
+            }
+        }, true);
+    }
+    
     public void testJavacInitializationElements() throws Exception {
         ClassPath boot = ClassPathSupport.createClassPath(SourceUtilsTestUtil.getBootClassPath().toArray(new URL[0]));
         JavaSource js = JavaSource.create(ClasspathInfo.create(boot, ClassPath.EMPTY, ClassPath.EMPTY));
@@ -543,4 +563,25 @@ public void run(CompilationController parameter) throws Exception {
             }
         }, true);
     }
+
+    public void testDisableAccessRightsCrash() throws Exception {
+        ClassPath boot = ClassPathSupport.createClassPath(SourceUtilsTestUtil.getBootClassPath().toArray(new URL[0]));
+        FileObject testFile = FileUtil.createData(FileUtil.createMemoryFileSystem().getRoot(), "Test.java");
+        try (Writer w = new OutputStreamWriter(testFile.getOutputStream())) {
+            w.append("public class Test {}");
+        }
+        JavaSource js = JavaSource.create(ClasspathInfo.create(boot, ClassPath.EMPTY, ClassPath.EMPTY), testFile);
+        js.runUserActionTask(new Task<CompilationController>() {
+            @Override
+            public void run(CompilationController parameter) throws Exception {
+                parameter.toPhase(Phase.RESOLVED);
+                TreePath clazzPath = new TreePath(new TreePath(parameter.getCompilationUnit()),
+                                                  parameter.getCompilationUnit().getTypeDecls().get(0));
+                Scope scope = parameter.getTrees().getScope(clazzPath);
+                Scope disableScope = parameter.getTreeUtilities().toScopeWithDisabledAccessibilityChecks(scope);
+                ExpressionTree et = parameter.getTreeUtilities().parseExpression("1 + 1", new SourcePositions[1]);
+                parameter.getTreeUtilities().attributeTree(et, disableScope);
+            }
+        }, true);
+    }
 }
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/TypeMirrorHandleTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/TypeMirrorHandleTest.java
index 3da1a8171..db1ab94b9 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/TypeMirrorHandleTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/TypeMirrorHandleTest.java
@@ -20,7 +20,7 @@
 package org.netbeans.api.java.source;
 
 import com.sun.source.tree.VariableTree;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.File;
 import java.io.OutputStream;
 import java.net.URL;
@@ -187,7 +187,7 @@ public void testTypeMirrorHandleUnion() throws Exception {
 
             public void run(final CompilationController info) throws Exception {
                 info.toPhase(Phase.RESOLVED);
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override public Void visitVariable(VariableTree node, Void p) {
                         if (node.getName().contentEquals("e")) {
                             TypeMirror tm = info.getTrees().getTypeMirror(getCurrentPath());
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/AnnotationTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/AnnotationTest.java
index 47a37abdd..a35210481 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/AnnotationTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/AnnotationTest.java
@@ -20,8 +20,8 @@
 
 import com.sun.source.tree.*;
 import com.sun.source.util.SourcePositions;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.File;
 import java.io.IOException;
 import java.util.Arrays;
@@ -220,7 +220,7 @@ public void testAddDefaultValue() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 CompilationUnitTree cut = workingCopy.getCompilationUnit();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(MethodTree node, Void p) {
                         workingCopy.rewrite(node, workingCopy.getTreeMaker().setInitialValue(node, workingCopy.getTreeMaker().Identifier("A.E")));
@@ -257,7 +257,7 @@ public void testRemoveDefaultValue() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 CompilationUnitTree cut = workingCopy.getCompilationUnit();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(MethodTree node, Void p) {
                         workingCopy.rewrite(node, workingCopy.getTreeMaker().setInitialValue(node, null));
@@ -733,7 +733,7 @@ public void run(final WorkingCopy workingCopy) throws IOException {
 
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitModifiers(ModifiersTree node, Void p) {
                         String toParse = "new Object() {" + annotationSpecification + " void test() {} }";
@@ -951,7 +951,7 @@ public void run(final WorkingCopy workingCopy) throws IOException {
                 final TreeMaker make = workingCopy.getTreeMaker();
                 CompilationUnitTree cut = workingCopy.getCompilationUnit();
                 
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override public Void visitIdentifier(IdentifierTree node, Void p) {
                         if (node.getName().contentEquals("MyEntity"))
                             workingCopy.rewrite(node, make.Identifier("MyEntity1"));
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ArraysTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ArraysTest.java
index 75de49150..d48a44011 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ArraysTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ArraysTest.java
@@ -32,7 +32,7 @@
 import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.File;
 import java.io.IOException;
 import java.util.Collections;
@@ -512,7 +512,7 @@ public void run(WorkingCopy workingCopy) throws IOException {
     }
 
     public void testRewriteType() throws Exception {
-        final class ReplaceQualifiedNames extends TreePathScanner<Void, Void> {
+        final class ReplaceQualifiedNames extends ErrorAwareTreePathScanner<Void, Void> {
             private final WorkingCopy copy;
 
             public ReplaceQualifiedNames(WorkingCopy copy) {
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/BlockTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/BlockTest.java
index 45f083d91..0c233bc78 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/BlockTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/BlockTest.java
@@ -20,7 +20,7 @@
 
 import java.io.File;
 import com.sun.source.tree.*;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import org.netbeans.api.java.source.Task;
 import org.netbeans.api.java.source.JavaSource;
 import static org.netbeans.api.java.source.JavaSource.*;
@@ -160,7 +160,7 @@ public void testBlockDoesNotStripFollowingStatements() throws Exception {
             public void run(final WorkingCopy workingCopy) throws java.io.IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
 
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitIdentifier(IdentifierTree node, Void p) {
                         if (node.getName().contentEquals("a")) {
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/CommentsTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/CommentsTest.java
index e77fed3a0..8d7d1546e 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/CommentsTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/CommentsTest.java
@@ -21,8 +21,8 @@
 import com.sun.source.tree.*;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.*;
 import java.util.Collections;
 import java.util.EnumSet;
@@ -1499,7 +1499,7 @@ public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitVariable(VariableTree node, Void p) {
                         GeneratorUtilities gu = GeneratorUtilities.get(workingCopy);
@@ -1633,7 +1633,7 @@ public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final CompilationUnitTree cut = workingCopy.getCompilationUnit();
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitIf(IfTree node, Void p) {
                         node = GeneratorUtilities.get(workingCopy).importComments(node, cut);
                         workingCopy.rewrite(node.getThenStatement(), make.Block(Collections.singletonList(node.getThenStatement()), false));
@@ -1683,7 +1683,7 @@ public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final CompilationUnitTree cut = workingCopy.getCompilationUnit();
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitIf(IfTree node, Void p) {
                         node = GeneratorUtilities.get(workingCopy).importComments(node, cut);
                         workingCopy.rewrite(node.getThenStatement(), make.Block(Collections.singletonList(node.getThenStatement()), false));
@@ -1918,7 +1918,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker tm = wc.getTreeMaker();
                 final TreeUtilities tu = wc.getTreeUtilities();
-                wc.getCompilationUnit().accept(new TreeScanner<Void, Void>() {
+                wc.getCompilationUnit().accept(new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(MethodTree mt, Void p) {
                         Tree nt = tm.setLabel(mt, mt.getName());
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/CompilationUnitTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/CompilationUnitTest.java
index f7e9e578e..c40241785 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/CompilationUnitTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/CompilationUnitTest.java
@@ -19,7 +19,7 @@
 package org.netbeans.api.java.source.gen;
 
 import com.sun.source.tree.*;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.File;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
@@ -724,7 +724,7 @@ public void test121729() throws Exception {
             public void run(final WorkingCopy parameter) throws Exception {
                 parameter.toPhase(Phase.ELEMENTS_RESOLVED);
                 
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitClass(ClassTree node, Void p) {
                         assertNotNull(parameter.getTrees().getElement(getCurrentPath()));
@@ -739,7 +739,7 @@ public Void visitClass(ClassTree node, Void p) {
             public void run(final WorkingCopy parameter) throws Exception {
                 parameter.toPhase(Phase.ELEMENTS_RESOLVED);
                 
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitClass(ClassTree node, Void p) {
                         assertNotNull(parameter.getTrees().getElement(getCurrentPath()));
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ConstructorTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ConstructorTest.java
index 68030351d..3e8a3d3a1 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ConstructorTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ConstructorTest.java
@@ -21,7 +21,7 @@
 import com.sun.source.tree.*;
 import java.io.File;
 import static com.sun.source.tree.Tree.Kind.*;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.util.*;
 import java.io.IOException;
 import java.util.EnumSet;
@@ -287,7 +287,7 @@ public void run(final WorkingCopy workingCopy) throws java.io.IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
 
                     @Override
                     public Void scan(Tree node, Void p) {
@@ -332,7 +332,7 @@ public void run(final WorkingCopy workingCopy) throws java.io.IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
 
                     @Override
                     public Void scan(Tree node, Void p) {
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/DoctreeTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/DoctreeTest.java
index 116a709a0..eae473034 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/DoctreeTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/DoctreeTest.java
@@ -45,7 +45,7 @@
 import com.sun.source.tree.MethodTree;
 import com.sun.source.util.DocTreeScanner;
 import com.sun.source.util.DocTrees;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -119,7 +119,7 @@ public void testAddDocComment() throws Exception {
             public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         ParamTree param = make.Param(false, make.DocIdentifier("test"), new LinkedList<DocTree>());
@@ -183,7 +183,7 @@ public void test232353 () throws Exception {
             public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         if("test".contentEquals(mt.getName())) {
@@ -245,7 +245,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -304,7 +304,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -365,7 +365,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -426,7 +426,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -488,7 +488,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -552,7 +552,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -615,7 +615,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -681,7 +681,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -750,7 +750,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -836,7 +836,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -899,7 +899,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -959,7 +959,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1022,7 +1022,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1082,7 +1082,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1141,7 +1141,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1200,7 +1200,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1259,7 +1259,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1318,7 +1318,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1381,7 +1381,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1444,7 +1444,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1507,7 +1507,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1584,7 +1584,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1647,7 +1647,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1710,7 +1710,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1772,7 +1772,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1834,7 +1834,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1892,7 +1892,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -1950,7 +1950,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -2018,7 +2018,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -2080,7 +2080,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -2139,7 +2139,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
 
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
@@ -2200,7 +2200,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
@@ -2263,7 +2263,7 @@ public void run(final WorkingCopy wc) throws IOException {
                 wc.toPhase(JavaSource.Phase.RESOLVED);
                 final TreeMaker make = wc.getTreeMaker();
                 final DocTrees trees = wc.getDocTrees();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitMethod(final MethodTree mt, Void p) {
                         DocCommentTree docTree = trees.getDocCommentTree(getCurrentPath());
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/EnumTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/EnumTest.java
index 3f1a05207..e035fffed 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/EnumTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/EnumTest.java
@@ -23,7 +23,7 @@
 import java.io.*;
 import com.sun.source.tree.*;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.util.Collections;
 import java.util.EnumSet;
 import java.util.LinkedList;
@@ -1100,7 +1100,7 @@ public void run(final WorkingCopy workingCopy) throws IOException {
                 CompilationUnitTree cut = workingCopy.getCompilationUnit();
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override
                     public Void visitVariable(VariableTree node, Void p) {
                         Element type = workingCopy.getTrees().getElement(new TreePath(getCurrentPath(), node.getType()));
@@ -1544,7 +1544,7 @@ public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
                 CompilationUnitTree cut = workingCopy.getCompilationUnit();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override public Void visitClass(ClassTree node, Void p) {
                         if (node.getSimpleName().length() == 0) {
                             MethodTree method = make.Method(make.Modifiers(EnumSet.of(Modifier.PUBLIC)),
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ForLoopTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ForLoopTest.java
index 0dbf3e815..6d72f66ae 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ForLoopTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ForLoopTest.java
@@ -19,7 +19,7 @@
 package org.netbeans.api.java.source.gen;
 
 import com.sun.source.tree.*;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.*;
 import java.util.Collections;
 import java.util.EnumSet;
@@ -768,7 +768,7 @@ public void testInitializerVariable185746() throws Exception {
             public void run(final WorkingCopy workingCopy) throws java.io.IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitVariable(VariableTree node, Void p) {
                         if (node.getName().contentEquals("i"))
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/GuardedBlockTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/GuardedBlockTest.java
index db30e4057..0e020ea61 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/GuardedBlockTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/GuardedBlockTest.java
@@ -35,7 +35,7 @@
 import com.sun.source.tree.StatementTree;
 import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
@@ -807,7 +807,7 @@ public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 CompilationUnitTree cut = workingCopy.getCompilationUnit();
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitIdentifier(IdentifierTree node, Void p) {
                         if ("X".equals(node.getName().toString())) {
@@ -895,7 +895,7 @@ public void run(final WorkingCopy workingCopy) throws IOException {
                 CompilationUnitTree cut = workingCopy.getCompilationUnit();
                 final TreeMaker make = workingCopy.getTreeMaker();
                 final TreeUtilities tu = workingCopy.getTreeUtilities();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                   @Override
                   public Void visitMethod(MethodTree mt, Void p) {
                      Tree nt = make.setLabel(mt, mt.getName());
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/LambdaTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/LambdaTest.java
index ac9af2dde..5d4c3e2e2 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/LambdaTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/LambdaTest.java
@@ -34,8 +34,8 @@
 import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.File;
 import java.io.IOException;
 import java.util.Collections;
@@ -93,7 +93,7 @@ public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 CompilationUnitTree cut = workingCopy.getCompilationUnit();
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLiteral(LiteralTree node, Void p) {
                         workingCopy.rewrite(node, make.MemberReference(ReferenceMode.INVOKE, make.Identifier("Test"), "taragui", Collections.<ExpressionTree>emptyList()));
                         return super.visitLiteral(node, p);
@@ -133,7 +133,7 @@ public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 CompilationUnitTree cut = workingCopy.getCompilationUnit();
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitVariable(VariableTree node, Void p) {
                         if (node.getName().contentEquals("e")) {
                             workingCopy.rewrite(node, make.setLabel(node, "f"));
@@ -174,7 +174,7 @@ public void testAddFirstLambdaParam() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.addLambdaParameter(node, make.Variable(make.Modifiers(EnumSet.noneOf(Modifier.class)), "e", null, null)));
                         return super.visitLambdaExpression(node, p);
@@ -213,7 +213,7 @@ public void testAddSecondLambdaParam() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.addLambdaParameter(node, make.Variable(make.Modifiers(EnumSet.noneOf(Modifier.class)), "f", null, null)));
                         return super.visitLambdaExpression(node, p);
@@ -252,7 +252,7 @@ public void testAddSecondLambdaParamNoParenthesis() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.addLambdaParameter(node, make.Variable(make.Modifiers(EnumSet.noneOf(Modifier.class)), "f", null, null)));
                         return super.visitLambdaExpression(node, p);
@@ -291,7 +291,7 @@ public void testPrependSecondLambdaParam() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.insertLambdaParameter(node, 0, make.Variable(make.Modifiers(EnumSet.noneOf(Modifier.class)), "f", null, null)));
                         return super.visitLambdaExpression(node, p);
@@ -330,7 +330,7 @@ public void testRemoveFirstLambdaParam() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.removeLambdaParameter(node, 0));
                         return super.visitLambdaExpression(node, p);
@@ -369,7 +369,7 @@ public void testRemoveSecondLambdaParam() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.removeLambdaParameter(node, 1));
                         return super.visitLambdaExpression(node, p);
@@ -408,7 +408,7 @@ public void testOnlyLambdaParam() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.removeLambdaParameter(node, 0));
                         return super.visitLambdaExpression(node, p);
@@ -447,7 +447,7 @@ public void testLambdaFullBody2Expression() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         ReturnTree t = (ReturnTree) ((BlockTree) node.getBody()).getStatements().get(0);
                         workingCopy.rewrite(node, make.setLambdaBody(node, t.getExpression()));
@@ -489,7 +489,7 @@ public void testLambdaExpression2FullBody() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.setLambdaBody(node, make.Block(Collections.singletonList(make.Return((ExpressionTree) node.getBody())), false)));
                         return super.visitLambdaExpression(node, p);
@@ -532,7 +532,7 @@ public void testLambdaExpression2FullBodyTreeMatch() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.setLambdaBody(node, make.Block(Collections.singletonList(make.Return((ExpressionTree) node.getBody())), false)));
                         return super.visitLambdaExpression(node, p);
@@ -571,7 +571,7 @@ public void testMethodReferenceDiff() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitMemberReference(MemberReferenceTree node, Void p) {
                         workingCopy.rewrite(node, make.MemberReference(node.getMode(), make.Identifier("Test"), node.getName(), node.getTypeArguments()));
                         return super.visitMemberReference(node, p);
@@ -610,7 +610,7 @@ public void testMethodReferenceNameDiff() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitMemberReference(MemberReferenceTree node, Void p) {
                         workingCopy.rewrite(node, make.setLabel(node, "taragui2"));
                         return super.visitMemberReference(node, p);
@@ -649,7 +649,7 @@ public void testMethodReferenceFirstTypeParam() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitMemberReference(MemberReferenceTree node, Void p) {
                         workingCopy.rewrite(node, make.MemberReference(node.getMode(), node.getQualifierExpression(), node.getName(), Collections.singletonList(make.Identifier("String"))));
                         return super.visitMemberReference(node, p);
@@ -688,7 +688,7 @@ public void testMethodReferenceLastTypeParam() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitMemberReference(MemberReferenceTree node, Void p) {
                         workingCopy.rewrite(node, make.MemberReference(node.getMode(), node.getQualifierExpression(), node.getName(), null));
                         return super.visitMemberReference(node, p);
@@ -729,7 +729,7 @@ public void testLambdaExpressionImplicit2ExplicitParamTypes() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         for (VariableTree par : node.getParameters()) {
                             workingCopy.rewrite(par.getType(), make.Identifier("String"));
@@ -772,7 +772,7 @@ public void testLambdaExpressionExplicit2ImplicitParamTypes() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         for (VariableTree par : node.getParameters()) {
                             workingCopy.rewrite(par, make.Variable(par.getModifiers(), par.getName(), null, par.getInitializer()));
@@ -895,7 +895,7 @@ public void testAddSecondLambdaParamWithType() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         VariableTree vt = node.getParameters().get(0);
                         workingCopy.rewrite(node, make.addLambdaParameter(node, make.Variable(vt.getModifiers(), "f", vt.getType(), vt.getInitializer())));
@@ -935,7 +935,7 @@ public void testChangeLambdaToImplicit() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void scan(Tree node, Void p) {
                         return super.scan(node, p);
@@ -986,7 +986,7 @@ public void testChangeLambdaToExplicit() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
 
                     @Override
                     public Void scan(Tree node, Void p) {
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MemberAdditionTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MemberAdditionTest.java
index f730937ea..b7c0179bc 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MemberAdditionTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MemberAdditionTest.java
@@ -28,7 +28,7 @@
 import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -200,7 +200,7 @@ private ClassTree findTopLevelClass(CompilationInfo info) {
         return i.topLevel;
     }
 
-    private static class TopLevelClassInfo extends TreeScanner<Void, Boolean> {
+    private static class TopLevelClassInfo extends ErrorAwareTreeScanner<Void, Boolean> {
 
         private ClassTree topLevel;
 
@@ -211,7 +211,7 @@ public Void visitClass(ClassTree node, Boolean p) {
 
     }
 
-    private static class FindVariableDeclaration extends TreeScanner<Void, Boolean> {
+    private static class FindVariableDeclaration extends ErrorAwareTreeScanner<Void, Boolean> {
 
         private VariableTree var;
 
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MethodBodyTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MethodBodyTest.java
index ebcddb20a..159bbf61f 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MethodBodyTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MethodBodyTest.java
@@ -20,7 +20,7 @@
 
 import com.sun.source.tree.*;
 import com.sun.source.util.SourcePositions;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.File;
 import java.util.Collections;
 import java.util.EnumSet;
@@ -320,7 +320,7 @@ public void run(WorkingCopy workingCopy) throws java.io.IOException {
                 MethodTree method = (MethodTree) clazz.getMembers().get(1);
                 final NewClassTree[] nctFin = new NewClassTree[1];
                 
-                new TreeScanner() {
+                new ErrorAwareTreeScanner() {
                     @Override
                     public Object visitNewClass(NewClassTree node, Object p) {
                         nctFin[0] = node;
@@ -378,7 +378,7 @@ public void run(WorkingCopy workingCopy) throws java.io.IOException {
                 MethodTree method = (MethodTree) clazz.getMembers().get(1);
                 final NewClassTree[] nctFin = new NewClassTree[1];
                 
-                new TreeScanner() {
+                new ErrorAwareTreeScanner() {
                     @Override
                     public Object visitNewClass(NewClassTree node, Object p) {
                         nctFin[0] = node;
@@ -652,7 +652,7 @@ private void performChainedMethodCallsDotPlacementTest(String... settings) throw
                 public void run(final WorkingCopy workingCopy) throws java.io.IOException {
                     workingCopy.toPhase(Phase.RESOLVED);
                     TreeMaker treeMaker = workingCopy.getTreeMaker();
-                    new TreeScanner<Void, Void>() {
+                    new ErrorAwareTreeScanner<Void, Void>() {
                         @Override public Void visitReturn(ReturnTree node, Void p) {
                             ExpressionTree parsed = workingCopy.getTreeUtilities().parseExpression("str.toString().length()", new SourcePositions[1]);
                             workingCopy.rewrite(node.getExpression(), parsed);
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ModifiersTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ModifiersTest.java
index cd87c9207..5e87b930d 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ModifiersTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ModifiersTest.java
@@ -31,7 +31,7 @@
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -1453,7 +1453,7 @@ public void run(final WorkingCopy workingCopy) throws java.io.IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
                 ClassTree clazz = (ClassTree) workingCopy.getCompilationUnit().getTypeDecls().get(0);
-                new TreeScanner() {
+                new ErrorAwareTreeScanner() {
                     @Override
                     public Object visitVariable(VariableTree var, Object p) {
                         ModifiersTree mods = var.getModifiers();
@@ -1495,7 +1495,7 @@ public void run(final WorkingCopy workingCopy) throws java.io.IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
                 ClassTree clazz = (ClassTree) workingCopy.getCompilationUnit().getTypeDecls().get(0);
-                new TreeScanner() {
+                new ErrorAwareTreeScanner() {
                     @Override public Object visitMethod(MethodTree node, Object p) {
                         if (node.getName().contentEquals("add")) {
                             workingCopy.rewrite(node.getModifiers(), make.addModifiersModifier(node.getModifiers(), Modifier.DEFAULT));
@@ -1537,7 +1537,7 @@ public void run(final WorkingCopy workingCopy) throws java.io.IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
                 ClassTree clazz = (ClassTree) workingCopy.getCompilationUnit().getTypeDecls().get(0);
-                new TreeScanner() {
+                new ErrorAwareTreeScanner() {
                     @Override public Object visitMethod(MethodTree node, Object p) {
                         if (node.getName().contentEquals("find")) {
                             workingCopy.rewrite(node.getModifiers(), make.Modifiers(Collections.emptySet()));
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MoveTreeTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MoveTreeTest.java
index d58a5dc48..bdf6d6fad 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MoveTreeTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MoveTreeTest.java
@@ -34,7 +34,7 @@
 import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.tree.WhileLoopTree;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.File;
 import java.io.IOException;
 import java.util.Arrays;
@@ -721,7 +721,7 @@ public void run(final WorkingCopy workingCopy) throws IOException {
                 VariableTree locVar = (VariableTree) method.getBody().getStatements().get(0);
                 TypeCastTree tct = (TypeCastTree) locVar.getInitializer();
                 
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitMethodInvocation(MethodInvocationTree node, Void p) {
                         if (node.getArguments().size() == 1) {
                             workingCopy.tag(node, "test");
@@ -784,7 +784,7 @@ public void run(final WorkingCopy workingCopy) throws IOException {
                 VariableTree locVar = (VariableTree) method.getBody().getStatements().get(0);
                 TreeMaker make = workingCopy.getTreeMaker();
                 
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitMethodInvocation(MethodInvocationTree node, Void p) {
                         if (node.getArguments().size() == 1) {
                             workingCopy.tag(node, "test");
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MultiCatchTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MultiCatchTest.java
index fb88f990a..36ebee78b 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MultiCatchTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/MultiCatchTest.java
@@ -19,7 +19,7 @@
 package org.netbeans.api.java.source.gen;
 
 import com.sun.source.tree.*;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -137,7 +137,7 @@ public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitIdentifier(IdentifierTree node, Void p) {
                         if (node.getName().contentEquals("FileNotFoundException")) {
                             workingCopy.rewrite(node, make.Identifier("IOException"));
@@ -186,7 +186,7 @@ public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitUnionType(UnionTypeTree node, Void p) {
                         List<Tree> alternatives = new ArrayList<Tree>(node.getTypeAlternatives());
                         alternatives.add(make.Identifier("IOException"));
@@ -235,7 +235,7 @@ public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitUnionType(UnionTypeTree node, Void p) {
                         List<Tree> alternatives = new ArrayList<Tree>(node.getTypeAlternatives());
                         alternatives.add(0, make.Identifier("IOException"));
@@ -284,7 +284,7 @@ public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitUnionType(UnionTypeTree node, Void p) {
                         List<Tree> alternatives = new ArrayList<Tree>(node.getTypeAlternatives());
                         alternatives.add(1, make.Identifier("IOException"));
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/RefactoringRegressionsTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/RefactoringRegressionsTest.java
index 29d899d6d..4ff35d6db 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/RefactoringRegressionsTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/RefactoringRegressionsTest.java
@@ -26,7 +26,7 @@
 import java.io.IOException;
 import java.util.Collections;
 import com.sun.source.tree.*;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.util.EnumSet;
 import java.util.List;
 import java.util.Map;
@@ -562,7 +562,7 @@ public void testDefaultAnnotationAttributeValue121873() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 CompilationUnitTree cut = workingCopy.getCompilationUnit();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitMemberSelect(MemberSelectTree node, Void p) {
                         if ("E".equals(node.getIdentifier().toString())) {
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/RewriteOccasionalStatements.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/RewriteOccasionalStatements.java
index fc0d51c0a..837922142 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/RewriteOccasionalStatements.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/RewriteOccasionalStatements.java
@@ -20,7 +20,7 @@
 
 import com.sun.source.tree.*;
 import com.sun.source.tree.Tree.Kind;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import org.junit.Test;
 import org.netbeans.api.java.source.*;
 import org.netbeans.junit.NbTestSuite;
@@ -451,7 +451,7 @@ public void run(WorkingCopy wc) throws Exception {
 */
 
 
-    class SimpleScanner extends TreeScanner<Void, Void> {
+    class SimpleScanner extends ErrorAwareTreeScanner<Void, Void> {
         private final WorkingCopy wc;
         protected GeneratorUtilities gu;
 
@@ -501,7 +501,7 @@ public void run(final WorkingCopy workingCopy) throws Exception {
                 workingCopy.toPhase(JavaSource.Phase.RESOLVED);
                 CompilationUnitTree cut = workingCopy.getCompilationUnit();
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitMethodInvocation(MethodInvocationTree node, Void p) {
                         if (node.getMethodSelect().getKind() == Kind.IDENTIFIER && ((IdentifierTree) node.getMethodSelect()).getName().contentEquals("a")) {
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/SwitchTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/SwitchTest.java
index c62c1348b..c21399e63 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/SwitchTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/SwitchTest.java
@@ -25,7 +25,7 @@
 import com.sun.source.tree.SwitchTree;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -170,7 +170,7 @@ public void run(final WorkingCopy copy) throws IOException {
                     return;
                 }
                 final TreeMaker make = copy.getTreeMaker();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override public Void visitIf(IfTree node, Void p) {
                         List<StatementTree> statements = new ArrayList<StatementTree>(((BlockTree) node.getThenStatement()).getStatements());
                         statements.add(make.Break(null));
@@ -218,7 +218,7 @@ public void run(final WorkingCopy copy) throws IOException {
                     return;
                 }
                 final TreeMaker make = copy.getTreeMaker();
-                new TreePathScanner<Void, Void>() {
+                new ErrorAwareTreePathScanner<Void, Void>() {
                     @Override public Void visitCase(CaseTree node, Void p) {
                         IfTree nue = make.If(make.Binary(Kind.EQUAL_TO, make.Identifier("p"), make.Literal(0)), make.Block(node.getStatements().subList(0, node.getStatements().size() - 1), false), null);
                         copy.rewrite(getCurrentPath().getParentPath().getLeaf(), nue);
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/TryTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/TryTest.java
index 828562c2d..4c0a268f8 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/TryTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/TryTest.java
@@ -19,7 +19,7 @@
 package org.netbeans.api.java.source.gen;
 
 import com.sun.source.tree.*;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.File;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -506,7 +506,7 @@ public void run(final WorkingCopy workingCopy) throws java.io.IOException {
                 workingCopy.toPhase(Phase.RESOLVED); //for RESOLVED, the 1.7 runtime (java.lang.AutoCloseable) would be needed
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitVariable(VariableTree node, Void p) {
                         if (node.getName().contentEquals("in")) {
diff --git a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/TypeAnnotationTest.java b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/TypeAnnotationTest.java
index a38162096..c7727d521 100644
--- a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/TypeAnnotationTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/TypeAnnotationTest.java
@@ -19,7 +19,7 @@
 package org.netbeans.api.java.source.gen;
 
 import com.sun.source.tree.*;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -162,7 +162,7 @@ public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreePathScanner<Void, Void>(){
+                new ErrorAwareTreePathScanner<Void, Void>(){
                     @Override public Void visitAnnotatedType(AnnotatedTypeTree node, Void p) {
                         workingCopy.rewrite(node, WorkingCopyTest.MakeAnnotatedTypeTemp(make, node.getUnderlyingType(), alter.alter(workingCopy, node.getAnnotations())));
                         return null;
@@ -210,7 +210,7 @@ public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreePathScanner<Void, Void>(){
+                new ErrorAwareTreePathScanner<Void, Void>(){
                     @Override public Void visitAnnotatedType(AnnotatedTypeTree node, Void p) {
                         workingCopy.rewrite(node, WorkingCopyTest.MakeAnnotatedTypeTemp(make, make.Identifier("String"), node.getAnnotations()));
                         return null;
@@ -258,7 +258,7 @@ public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreePathScanner<Void, Void>(){
+                new ErrorAwareTreePathScanner<Void, Void>(){
                     @Override public Void visitParameterizedType(ParameterizedTypeTree node, Void p) {
                         List<AnnotationTree> annotations = Collections.singletonList(workingCopy.getTreeMaker().TypeAnnotation(make.Identifier("A"), Collections.<ExpressionTree>emptyList()));
                         Tree orig = node.getTypeArguments().get(0);
@@ -308,7 +308,7 @@ public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
 
-                new TreePathScanner<Void, Void>(){
+                new ErrorAwareTreePathScanner<Void, Void>(){
                     @Override public Void visitAnnotatedType(AnnotatedTypeTree node, Void p) {
                         workingCopy.rewrite(node, node.getUnderlyingType());
                         return super.visitAnnotatedType(node, p);
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/TestUtil.java b/java.source.base/test/unit/src/org/netbeans/modules/java/source/TestUtil.java
index 7dbba90b2..cf658e7f0 100644
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/TestUtil.java
+++ b/java.source.base/test/unit/src/org/netbeans/modules/java/source/TestUtil.java
@@ -30,21 +30,37 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.Iterator;
+import java.util.List;
 import java.util.Properties;
+import java.util.regex.Pattern;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 import javax.swing.text.Document;
 import junit.framework.TestCase;
+import static junit.framework.TestCase.assertFalse;
+import org.netbeans.ProxyURLStreamHandlerFactory;
+import org.netbeans.api.annotations.common.NonNull;
 import org.netbeans.api.editor.mimelookup.MimePath;
 import org.netbeans.api.editor.mimelookup.test.MockMimeLookup;
+import org.netbeans.api.java.classpath.ClassPath;
 import org.netbeans.editor.BaseDocument;
 import org.netbeans.junit.NbTestCase;
 import org.netbeans.modules.java.preprocessorbridge.spi.JavaFileFilterImplementation;
 import org.netbeans.spi.editor.document.DocumentFactory;
+import org.netbeans.spi.java.classpath.PathResourceImplementation;
+import org.netbeans.spi.java.classpath.support.ClassPathSupport;
 import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.filesystems.URLMapper;
 import org.openide.loaders.DataObject;
+import org.openide.util.BaseUtilities;
 import org.openide.util.Utilities;
 
 
@@ -387,4 +403,67 @@ public Document createDocument(String mimeType) {
             
         });
       }
+
+    public static ClassPath getBootClassPath() {
+        String cp = System.getProperty("sun.boot.class.path");
+        if (cp != null) {
+            List<URL> urls = new ArrayList<>();
+            String[] paths = cp.split(Pattern.quote(System.getProperty("path.separator")));
+            for (String path : paths) {
+                File f = new File(path);
+
+                if (!f.canRead())
+                    continue;
+
+                FileObject fo = FileUtil.toFileObject(f);
+                if (FileUtil.isArchiveFile(fo)) {
+                    fo = FileUtil.getArchiveRoot(fo);
+                }
+                if (fo != null) {
+                    urls.add(fo.toURL());
+                }
+            }
+            return ClassPathSupport.createClassPath((URL[])urls.toArray(new URL[0]));
+        } else {
+            ProxyURLStreamHandlerFactory.register();
+            final List<PathResourceImplementation> modules = new ArrayList<>();
+            final File installDir = new File(System.getProperty("java.home"));
+            final URI imageURI = getImageURI(installDir);
+            try {
+                final FileObject jrtRoot = URLMapper.findFileObject(imageURI.toURL());
+                final FileObject root = getModulesRoot(jrtRoot);
+                for (FileObject module : root.getChildren()) {
+                    modules.add(ClassPathSupport.createResource(module.toURL()));
+                }
+            } catch (MalformedURLException e) {
+                throw new IllegalStateException(e);
+            }
+            assertFalse(modules.isEmpty());
+            return ClassPathSupport.createClassPath(modules);
+        }
+    }
+
+    private static final String PROTOCOL = "nbjrt"; //NOI18N
+
+    private static URI getImageURI(@NonNull final File jdkHome) {
+        try {
+            return new URI(String.format(
+                "%s:%s!/%s",  //NOI18N
+                PROTOCOL,
+                BaseUtilities.toURI(jdkHome).toString(),
+                ""));
+        } catch (URISyntaxException e) {
+            throw new IllegalStateException();
+        }
+    }
+
+    @NonNull
+    private static FileObject getModulesRoot(@NonNull final FileObject jrtRoot) {
+        final FileObject modules = jrtRoot.getFileObject("modules");    //NOI18N
+        //jimage v1 - modules are located in the root
+        //jimage v2 - modules are located in "modules" folder
+        return modules == null ?
+            jrtRoot :
+            modules;
+    }
 }
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/CompileWorkerTestBase.java b/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/CompileWorkerTestBase.java
index 743511c16..ad8e5a330 100644
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/CompileWorkerTestBase.java
+++ b/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/CompileWorkerTestBase.java
@@ -18,7 +18,6 @@
  */
 package org.netbeans.modules.java.source.indexing;
 
-import com.sun.source.tree.CompilationUnitTree;
 import java.io.File;
 import java.net.URL;
 import java.util.ArrayList;
@@ -26,16 +25,10 @@
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
-import java.util.Map;
 import java.util.Set;
-import javax.tools.JavaFileObject;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import static org.junit.Assert.*;
+import javax.swing.event.ChangeListener;
 import org.netbeans.api.java.classpath.ClassPath;
+import org.netbeans.api.java.queries.SourceLevelQuery;
 import org.netbeans.api.java.source.SourceUtilsTestUtil;
 import org.netbeans.api.java.source.TestUtilities;
 import org.netbeans.junit.NbTestCase;
@@ -52,7 +45,9 @@
 import org.netbeans.modules.parsing.impl.indexing.SuspendSupport.SuspendStatusImpl;
 import org.netbeans.modules.parsing.impl.indexing.lucene.LuceneIndexFactory;
 import org.netbeans.modules.parsing.spi.indexing.Context;
+import org.netbeans.modules.parsing.spi.indexing.ErrorsCache;
 import org.netbeans.spi.java.classpath.support.ClassPathSupport;
+import org.netbeans.spi.java.queries.SourceLevelQueryImplementation2;
 import org.openide.filesystems.FileObject;
 import org.openide.filesystems.FileUtil;
 
@@ -66,10 +61,10 @@ public CompileWorkerTestBase(String name) {
         super(name);
     }
     
-    public void test219787() throws Exception {
-        ParsingOutput result = runIndexing(Arrays.asList(compileTuple("test/Test3.java", "package test; public class Test3")),
-                                           Arrays.asList(virtualCompileTuple("test/Test1.virtual", "package test; public class Test1 {}"),
-                                                         virtualCompileTuple("test/Test2.virtual", "package test; public class Test2 {}")));
+    public void testClassesLivingElsewhere() throws Exception {
+        ParsingOutput result = runIndexing(Arrays.asList(compileTuple("test/Test1.java", "package test; public class Test1 { Test2a t; } class Test1a { }"),
+                                                         compileTuple("test/Test2.java", "package test; public class Test2 { Test1a t; } class Test2a { }")),
+                                           Arrays.asList());
         
         assertFalse(result.lowMemory);
         assertTrue(result.success);
@@ -80,10 +75,15 @@ public void test219787() throws Exception {
             createdFiles.add(getWorkDir().toURI().relativize(created.toURI()).getPath());
         }
         
-        assertEquals(new HashSet<String>(Arrays.asList("cache/s1/java/15/classes/test/Test3.sig")), createdFiles);
+        assertEquals(new HashSet<String>(Arrays.asList("cache/s1/java/15/classes/test/Test1.sig",
+                                                       "cache/s1/java/15/classes/test/Test1a.sig",
+                                                       "cache/s1/java/15/classes/test/Test2.sig",
+                                                       "cache/s1/java/15/classes/test/Test2a.sig")),
+                     createdFiles);
+        assertFalse(ErrorsCache.isInError(getRoot(), true));
     }
-    
-    private ParsingOutput runIndexing(List<CompileTuple> files, List<CompileTuple> virtualFiles) throws Exception {
+
+    protected ParsingOutput runIndexing(List<CompileTuple> files, List<CompileTuple> virtualFiles) throws Exception {
         TransactionContext txc = TransactionContext.beginStandardTransaction(src.toURL(), true, false, false);
         Factory f = new JavaCustomIndexer.Factory();
         Context ctx = SPIAccessor.getInstance().createContext(CacheFolder.getDataFolder(src.toURL()), src.toURL(), f.getIndexerName(), f.getIndexVersion(), LuceneIndexFactory.getDefault(), false, false, true, SPIAccessor.getInstance().createSuspendStatus(new SuspendStatusImpl() {
@@ -118,7 +118,7 @@ public boolean isSuspendSupported() {
     
     @Override
     protected void setUp() throws Exception {
-        SourceUtilsTestUtil.prepareTest(new String[0], new Object[0]);
+        SourceUtilsTestUtil.prepareTest(new String[0], new Object[] {new SourceLevelQueryImpl()});
         
         clearWorkDir();
         File wdFile = getWorkDir();
@@ -134,6 +134,7 @@ protected void setUp() throws Exception {
     }
     
     private FileObject src;
+    private String sourceLevel;
     
     private FileObject createSrcFile(String pathAndName, String content) throws Exception {
         FileObject testFile = FileUtil.createData(src, pathAndName);
@@ -142,13 +143,41 @@ private FileObject createSrcFile(String pathAndName, String content) throws Exce
         return testFile;
     }
     
-    private CompileTuple virtualCompileTuple(String relativePath, String content) throws Exception {
+    protected CompileTuple virtualCompileTuple(String relativePath, String content) throws Exception {
         FileObject file = createSrcFile(relativePath, "");
         return new CompileTuple(FileObjects.sourceFileObject(file, src, null, content), SPIAccessor.getInstance().create(new FileObjectIndexable(src, relativePath)), true, true);
     }
     
-    private CompileTuple compileTuple(String relativePath, String content) throws Exception {
+    protected CompileTuple compileTuple(String relativePath, String content) throws Exception {
         FileObject file = createSrcFile(relativePath, content);
         return new CompileTuple(FileObjects.sourceFileObject(file, src), SPIAccessor.getInstance().create(new FileObjectIndexable(src, relativePath)), false, true);
     }
+    
+    protected FileObject getRoot() {
+        return src;
+    }
+
+    protected void setSourceLevel(String sourceLevel) {
+        this.sourceLevel = sourceLevel;
+    }
+
+    private final class SourceLevelQueryImpl implements SourceLevelQueryImplementation2 {
+
+        @Override
+        public Result getSourceLevel(FileObject file) {
+            return new Result() {
+                @Override
+                public String getSourceLevel() {
+                    return sourceLevel;
+                }
+
+                @Override
+                public void addChangeListener(ChangeListener l) {}
+
+                @Override
+                public void removeChangeListener(ChangeListener l) {}
+            };
+        }
+
+    }
 }
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorkerTest.java b/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorkerTest.java
new file mode 100644
index 000000000..86ba81f20
--- /dev/null
+++ b/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorkerTest.java
@@ -0,0 +1,195 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.source.indexing;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import static junit.framework.TestCase.assertFalse;
+import static junit.framework.TestCase.assertTrue;
+import org.netbeans.modules.java.source.indexing.CompileWorker.ParsingOutput;
+import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.CompileTuple;
+import org.netbeans.modules.parsing.spi.indexing.Context;
+
+/**
+ *
+ * @author lahvac
+ */
+public class VanillaCompileWorkerTest extends CompileWorkerTestBase {
+    
+    public VanillaCompileWorkerTest(String name) {
+        super(name);
+    }
+    
+    @Override
+    protected ParsingOutput runCompileWorker(Context context, JavaParsingContext javaContext, Collection<? extends CompileTuple> files) {
+        return new VanillaCompileWorker().compile(null, context, javaContext, files);
+    }
+    
+    public void testVanillaWorker() throws Exception {
+        ParsingOutput result = runIndexing(Arrays.asList(compileTuple("test/Test3.java", "package test; public class Test3"),
+                                                         compileTuple("test/Test4.java", "package test; public class Test4 { Undef undef; }")),
+                                           Arrays.asList(virtualCompileTuple("test/Test1.virtual", "package test; public class Test1 {}"),
+                                                         virtualCompileTuple("test/Test2.virtual", "package test; public class Test2 {}")));
+
+        assertFalse(result.lowMemory);
+        assertTrue(result.success);
+
+        Set<String> createdFiles = new HashSet<String>();
+
+        for (File created : result.createdFiles) {
+            createdFiles.add(getWorkDir().toURI().relativize(created.toURI()).getPath());
+        }
+
+        assertEquals(new HashSet<String>(Arrays.asList("cache/s1/java/15/classes/test/Test3.sig",
+                                                       "cache/s1/java/15/classes/test/Test4.sig")), createdFiles);
+        result = runIndexing(Arrays.asList(compileTuple("test/Test4.java", "package test; public class Test4 { void t() { Undef undef; } }")),
+                             Collections.emptyList());
+
+        assertFalse(result.lowMemory);
+        assertTrue(result.success);
+    }
+
+    public void testRepair1() throws Exception {
+        ParsingOutput result = runIndexing(Arrays.asList(compileTuple("test/Test4.java", "package test; public class Test4 { public void test() { Undef undef; } }")),
+                                           Arrays.asList());
+
+        assertFalse(result.lowMemory);
+        assertTrue(result.success);
+
+        Set<String> createdFiles = new HashSet<String>();
+
+        for (File created : result.createdFiles) {
+            createdFiles.add(getWorkDir().toURI().relativize(created.toURI()).getPath());
+        }
+
+        assertEquals(new HashSet<String>(Arrays.asList("cache/s1/java/15/classes/test/Test4.sig")), createdFiles);
+    }
+
+    public void testRepair2() throws Exception {
+        ParsingOutput result = runIndexing(Arrays.asList(compileTuple("test/Test4.java", "package test; public class Test4 { @Undef public void test1() { } @Deprecated @Undef public void test2() { } }")),
+                                           Arrays.asList());
+
+        assertFalse(result.lowMemory);
+        assertTrue(result.success);
+
+        Set<String> createdFiles = new HashSet<String>();
+
+        for (File created : result.createdFiles) {
+            createdFiles.add(getWorkDir().toURI().relativize(created.toURI()).getPath());
+        }
+
+        assertEquals(new HashSet<String>(Arrays.asList("cache/s1/java/15/classes/test/Test4.sig")), createdFiles);
+        //TODO: check file content!!!
+    }
+
+    public void testRepair3() throws Exception {
+        ParsingOutput result = runIndexing(Arrays.asList(compileTuple("test/Test4.java", "package test; public class Test4 { public <T> void test1(T t) { } }")),
+                                           Arrays.asList());
+
+        assertFalse(result.lowMemory);
+        assertTrue(result.success);
+
+        Set<String> createdFiles = new HashSet<String>();
+
+        for (File created : result.createdFiles) {
+            createdFiles.add(getWorkDir().toURI().relativize(created.toURI()).getPath());
+        }
+
+        assertEquals(new HashSet<String>(Arrays.asList("cache/s1/java/15/classes/test/Test4.sig")), createdFiles);
+        //TODO: check file content!!!
+    }
+
+    public void testRepair4() throws Exception {
+        ParsingOutput result = runIndexing(Arrays.asList(compileTuple("test/Test4.java", "package test; import java.util.List; public class Test4 { public List<Undef> test() { } }")),
+                                           Arrays.asList());
+
+        assertFalse(result.lowMemory);
+        assertTrue(result.success);
+
+        Set<String> createdFiles = new HashSet<String>();
+
+        for (File created : result.createdFiles) {
+            createdFiles.add(getWorkDir().toURI().relativize(created.toURI()).getPath());
+        }
+
+        assertEquals(new HashSet<String>(Arrays.asList("cache/s1/java/15/classes/test/Test4.sig")), createdFiles);
+        //TODO: check file content!!!
+    }
+
+    public void testRepairEnum() throws Exception {
+        ParsingOutput result = runIndexing(Arrays.asList(compileTuple("test/Test4.java", "package test; public enum Test4 { A {} }")),
+                                           Arrays.asList());
+
+        assertFalse(result.lowMemory);
+        assertTrue(result.success);
+
+        Set<String> createdFiles = new HashSet<String>();
+
+        for (File created : result.createdFiles) {
+            createdFiles.add(getWorkDir().toURI().relativize(created.toURI()).getPath());
+        }
+
+        assertEquals(new HashSet<String>(Arrays.asList("cache/s1/java/15/classes/test/Test4.sig",
+                                                       "cache/s1/java/15/classes/test/Test4$1.sig")),
+                     createdFiles);
+        //TODO: check file content!!!
+    }
+
+    public void testRepairWildcard() throws Exception {
+        ParsingOutput result = runIndexing(Arrays.asList(compileTuple("test/Test4.java", "package test; import java.util.*; public class Test4 { void test(List<? extends Undef> l1, List<? super Undef> l2) { } }")),
+                                           Arrays.asList());
+
+        assertFalse(result.lowMemory);
+        assertTrue(result.success);
+
+        Set<String> createdFiles = new HashSet<String>();
+
+        for (File created : result.createdFiles) {
+            createdFiles.add(getWorkDir().toURI().relativize(created.toURI()).getPath());
+        }
+
+        assertEquals(new HashSet<String>(Arrays.asList("cache/s1/java/15/classes/test/Test4.sig")),
+                     createdFiles);
+        //TODO: check file content!!!
+    }
+
+    public void testModuleInfoAndSourceLevel8() throws Exception {
+        setSourceLevel("8");
+
+        ParsingOutput result = runIndexing(Arrays.asList(compileTuple("module-info.java", "module m {}"),
+                                                         compileTuple("test/Test.java", "package test; public class Test { }")),
+                                           Arrays.asList());
+
+        assertFalse(result.lowMemory);
+        assertTrue(result.success);
+
+        Set<String> createdFiles = new HashSet<String>();
+
+        for (File created : result.createdFiles) {
+            createdFiles.add(getWorkDir().toURI().relativize(created.toURI()).getPath());
+        }
+
+        assertEquals(new HashSet<String>(Arrays.asList("cache/s1/java/15/classes/test/Test.sig")),
+                     createdFiles);
+    }
+}
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/ClasspathInfoTest.java b/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/ClasspathInfoTest.java
index 9300b5cb4..f534bc288 100644
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/ClasspathInfoTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/ClasspathInfoTest.java
@@ -27,6 +27,7 @@
 import java.io.PrintWriter;
 import java.net.URL;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.EnumSet;
 import java.util.List;
 import java.util.Enumeration;
@@ -45,6 +46,7 @@
 import org.netbeans.api.java.classpath.ClassPath;
 import org.netbeans.api.java.source.ClasspathInfo;
 import org.netbeans.junit.NbTestCase;
+import org.netbeans.modules.java.source.ElementUtils;
 import org.netbeans.modules.java.source.JavaSourceAccessor;
 import org.netbeans.modules.java.source.TestUtil;
 import org.netbeans.modules.java.source.indexing.TransactionContext;
@@ -108,9 +110,8 @@ public void testCreate() {
     
     public void testGetTypeDeclaration() throws Exception {
         ClasspathInfo ci = ClasspathInfo.create( bootPath, classPath, null);
-        JavacTaskImpl jTask = JavacParser.createJavacTask(ci,  (DiagnosticListener) null, (String) null, null, null, null, null, null, null);
+        JavacTaskImpl jTask = JavacParser.createJavacTask(ci,  (DiagnosticListener) null, (String) null, null, null, null, null, null, Collections.emptyList());
         jTask.enter(); 
-	JavacElements elements = (JavacElements) jTask.getElements();
 	
         List<String> notFound = new LinkedList<String>();
         JarFile jf = new JarFile( rtJar );       
@@ -121,7 +122,7 @@ public void testGetTypeDeclaration() throws Exception {
                 String typeName = jeName.substring( 0, jeName.length() - ".class".length() );
 
                 typeName = typeName.replace( "/", "." ); //.replace( "$", "." );
-                TypeElement te = elements.getTypeElementByBinaryName( typeName );
+                TypeElement te = ElementUtils.getTypeElementByBinaryName(jTask, typeName );
 //                assertNotNull( "Declaration for " + typeName + " should not be null.", td );
                 if ( te == null ) {
                     if (!typeName.endsWith("package-info")) {
@@ -148,7 +149,7 @@ public void testGetPackageDeclaration() throws Exception {
                     // empty package
                     continue;
                 }
-                PackageElement pd = JavacParser.createJavacTask(ci,  (DiagnosticListener) null, (String) null, null, null, null, null, null, null).getElements().getPackageElement( packageName );
+                PackageElement pd = JavacParser.createJavacTask(ci,  (DiagnosticListener) null, (String) null, null, null, null, null, null, Collections.emptyList()).getElements().getPackageElement( packageName );
                 assertNotNull( "Declaration for " + packageName + " should not be null.", pd );
             }
         }
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/JavacParserTest.java b/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/JavacParserTest.java
index d9e31a47c..0a3fd93f4 100644
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/JavacParserTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/JavacParserTest.java
@@ -22,7 +22,7 @@
 import com.sun.source.tree.CompilationUnitTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.tools.javac.code.Source;
 import java.io.File;
 import java.io.FileOutputStream;
@@ -31,6 +31,7 @@
 import java.net.URL;
 import java.util.Arrays;
 import java.util.HashSet;
+import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicReference;
 import javax.lang.model.element.TypeElement;
@@ -51,11 +52,14 @@
 import org.netbeans.api.lexer.TokenSequence;
 import org.netbeans.junit.NbTestCase;
 import org.netbeans.modules.java.source.tasklist.CompilerSettings;
+import org.netbeans.modules.openide.util.GlobalLookup;
 import org.netbeans.spi.java.classpath.support.ClassPathSupport;
 import org.openide.cookies.EditorCookie;
 import org.openide.filesystems.FileObject;
 import org.openide.filesystems.FileUtil;
 import org.openide.loaders.DataObject;
+import org.openide.util.Lookup;
+import org.openide.util.lookup.Lookups;
 
 /**
  *
@@ -75,7 +79,7 @@ protected void setUp() throws Exception {
         prepareTest();
     }
 
-    public void Dtest1() throws Exception {
+    public void testMultiSource() throws Exception {
         FileObject f1 = createFile("test/Test1.java", "package test; class Test1");
         FileObject f2 = createFile("test/Test2.java", "package test; class Test2{}");
         FileObject f3 = createFile("test/Test3.java", "package test; class Test3{}");
@@ -86,7 +90,7 @@ public void Dtest1() throws Exception {
         SourceUtilsTestUtil.compileRecursively(sourceRoot);
 
         js.runUserActionTask(new Task<CompilationController>() {
-
+            TypeElement storedJLObject;
             public void run(CompilationController parameter) throws Exception {
                 if ("Test3".equals(parameter.getFileObject().getName())) {
                     TypeElement te = parameter.getElements().getTypeElement("test.Test1");
@@ -95,10 +99,50 @@ public void run(CompilationController parameter) throws Exception {
                 }
                 assertEquals(Phase.PARSED, parameter.toPhase(Phase.PARSED));
                 assertNotNull(parameter.getCompilationUnit());
+                TypeElement jlObject = parameter.getElements().getTypeElement("java.lang.Object");
+
+                if (storedJLObject == null) {
+                    storedJLObject = jlObject;
+                } else {
+                    assertEquals(storedJLObject, jlObject);
+                }
             }
         }, true);
     }
 
+    public void testMultiSourceVanilla() throws Exception {
+        Lookup noSP = Lookups.exclude(Lookup.getDefault(), JavacParser.SequentialParsing.class);
+        GlobalLookup.execute(noSP, () -> {
+            try {
+                FileObject f1 = createFile("test/Test1.java", "package test; class Test1");
+                FileObject f2 = createFile("test/Test2.java", "package test; class Test2{}");
+                FileObject f3 = createFile("test/Test3.java", "package test; class Test3{}");
+
+                ClasspathInfo cpInfo = ClasspathInfo.create(f2);
+                JavaSource js = JavaSource.create(cpInfo, f2, f3);
+
+                SourceUtilsTestUtil.compileRecursively(sourceRoot);
+
+                js.runUserActionTask(new Task<CompilationController>() {
+                    TypeElement storedJLObject;
+                    public void run(CompilationController parameter) throws Exception {
+                        assertEquals(Phase.PARSED, parameter.toPhase(Phase.PARSED));
+                        assertNotNull(parameter.getCompilationUnit());
+                        TypeElement jlObject = parameter.getElements().getTypeElement("java.lang.Object");
+
+                        if (storedJLObject == null) {
+                            storedJLObject = jlObject;
+                        } else {
+                            assertFalse(Objects.equals(storedJLObject, jlObject));
+                        }
+                    }
+                }, true);
+            } catch (Exception ex) {
+                throw new AssertionError(ex);
+            }
+        });
+    }
+
     public void test199332() throws Exception {
         settings.commandLine = "-Xlint:serial";
 
@@ -158,7 +202,7 @@ public void run(final CompilationController parameter) throws Exception {
                 
                 assertSame(tree.get(), parameter.getCompilationUnit());
                 
-                new TreePathScanner<Void, long[]>() {
+                new ErrorAwareTreePathScanner<Void, long[]>() {
 
                     @Override
                     public Void scan(Tree tree, long[] parentSpan) {
@@ -249,7 +293,7 @@ public void run(final CompilationController parameter) throws Exception {
                 
                 assertSame(tree.get(), parameter.getCompilationUnit());
                 
-                new TreePathScanner<Void, long[]>() {
+                new ErrorAwareTreePathScanner<Void, long[]>() {
 
                     @Override
                     public Void scan(Tree tree, long[] parentSpan) {
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/ModuleOraculumTest.java b/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/ModuleOraculumTest.java
index a85f9bc17..834e965b2 100644
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/ModuleOraculumTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/ModuleOraculumTest.java
@@ -91,7 +91,6 @@ public void testOraculumLibrarySourceWithRoot() {
                 cpInfo,
                 parser,
                 null,
-                null,
                 false);
         assertNotNull(impl);
         final Options opts = Options.instance(impl.getContext());
@@ -112,7 +111,6 @@ public void testOraculumLibrarySourceWithoutRootWithSourcePath() {
                 cpInfo,
                 parser,
                 null,
-                null,
                 false);
         assertNotNull(impl);
         final Options opts = Options.instance(impl.getContext());
@@ -129,7 +127,6 @@ public void testOraculumLibrarySourceWithoutRootWithoutSourcePath() {
                 cpInfo,
                 parser,
                 null,
-                null,
                 false);
         assertNotNull(impl);
         final Options opts = Options.instance(impl.getContext());
@@ -147,7 +144,6 @@ public void testOraculumLibrarySourceNoModuleInfo() throws IOException {
                 cpInfo,
                 parser,
                 null,
-                null,
                 false);
         assertNotNull(impl);
         final Options opts = Options.instance(impl.getContext());
@@ -165,7 +161,6 @@ public void testOraculumProjectSource() throws IOException {
                 cpInfo,
                 parser,
                 null,
-                null,
                 false);
         assertNotNull(impl);
         final Options opts = Options.instance(impl.getContext());
@@ -185,7 +180,6 @@ public void testOraculumLibrarySourceWithRootExpliciteXModule() throws IOExcepti
                 cpInfo,
                 parser,
                 null,
-                null,
                 false);
         assertNotNull(impl);
         final Options opts = Options.instance(impl.getContext());
@@ -218,7 +212,6 @@ public void testRootCache() {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertEquals("Test", Options.instance(impl.getContext()).get("-XD-Xmodule:"));    //NOI18N
             List<? extends FileObject> roots = h.getRoots();
@@ -231,7 +224,6 @@ public void testRootCache() {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertEquals("Test", Options.instance(impl.getContext()).get("-XD-Xmodule:"));    //NOI18N
             roots = h.getRoots();
@@ -242,7 +234,6 @@ public void testRootCache() {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertEquals("Next", Options.instance(impl.getContext()).get("-XD-Xmodule:"));    //NOI18N
             roots = h.getRoots();
@@ -269,7 +260,6 @@ public void testModuleNameCache() {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertEquals("Test", Options.instance(impl.getContext()).get("-XD-Xmodule:"));    //NOI18N
             List<? extends String> names = h.getModuleNames();
@@ -282,7 +272,6 @@ public void testModuleNameCache() {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertEquals("Test", Options.instance(impl.getContext()).get("-XD-Xmodule:"));    //NOI18N
             names = h.getModuleNames();
@@ -293,7 +282,6 @@ public void testModuleNameCache() {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertEquals("Next", Options.instance(impl.getContext()).get("-XD-Xmodule:"));    //NOI18N
             names = h.getModuleNames();
@@ -320,7 +308,6 @@ public void testModuleNameCache_ModuleInfoUpdated() throws IOException {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertEquals("Test", Options.instance(impl.getContext()).get("-XD-Xmodule:"));    //NOI18N
             List<? extends String> names = h.getModuleNames();
@@ -334,7 +321,6 @@ public void testModuleNameCache_ModuleInfoUpdated() throws IOException {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertEquals("TestUpdated", Options.instance(impl.getContext()).get("-XD-Xmodule:"));    //NOI18N
             names = h.getModuleNames();
@@ -347,7 +333,6 @@ public void testModuleNameCache_ModuleInfoUpdated() throws IOException {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertEquals("TestUpdated", Options.instance(impl.getContext()).get("-XD-Xmodule:"));    //NOI18N
             names = h.getModuleNames();
@@ -373,7 +358,6 @@ public void testModuleNameCache_ModuleInfoDeleted() throws IOException {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertEquals("Test", Options.instance(impl.getContext()).get("-XD-Xmodule:"));    //NOI18N
             List<? extends String> names = h.getModuleNames();
@@ -387,7 +371,6 @@ public void testModuleNameCache_ModuleInfoDeleted() throws IOException {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertNull(Options.instance(impl.getContext()).get("-XD-Xmodule:"));    //NOI18N
             names = h.getModuleNames();
@@ -400,7 +383,6 @@ public void testModuleNameCache_ModuleInfoDeleted() throws IOException {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertNull(Options.instance(impl.getContext()).get("-XD-Xmodule:"));    //NOI18N
             names = h.getModuleNames();
@@ -427,7 +409,6 @@ public void testModuleNameCache_ModuleInfoCreated() throws IOException {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertNull(Options.instance(impl.getContext()).get("-XD-Xmodule:"));    //NOI18N
             List<? extends String> names = h.getModuleNames();
@@ -441,7 +422,6 @@ public void testModuleNameCache_ModuleInfoCreated() throws IOException {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertEquals("TestNew", Options.instance(impl.getContext()).get("-XD-Xmodule:"));    //NOI18N
             names = h.getModuleNames();
@@ -454,7 +434,6 @@ public void testModuleNameCache_ModuleInfoCreated() throws IOException {
                     cpInfo,
                     parser,
                     null,
-                    null,
                     false);
             assertEquals("TestNew", Options.instance(impl.getContext()).get("-XD-Xmodule:"));    //NOI18N
             names = h.getModuleNames();
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/TestJavaPlatformProviderImpl.java b/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/TestJavaPlatformProviderImpl.java
index 2991d1461..7edd1f1af 100644
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/TestJavaPlatformProviderImpl.java
+++ b/java.source.base/test/unit/src/org/netbeans/modules/java/source/parsing/TestJavaPlatformProviderImpl.java
@@ -31,6 +31,7 @@
 import org.netbeans.api.java.platform.JavaPlatform;
 import org.netbeans.modules.java.platform.implspi.JavaPlatformProvider;
 import org.netbeans.api.java.platform.Specification;
+import org.netbeans.modules.java.source.TestUtil;
 import org.netbeans.spi.java.classpath.support.ClassPathSupport;
 import org.openide.filesystems.FileObject;
 import org.openide.filesystems.FileStateInvalidException;
@@ -82,24 +83,7 @@ public Map getProperties() {
 
         private static synchronized ClassPath getBootClassPath() {
             if (bootClassPath == null) {
-                String cp = System.getProperty("sun.boot.class.path");
-                List<URL> urls = new ArrayList<>();
-                String[] paths = cp.split(Pattern.quote(System.getProperty("path.separator")));
-                for (String path : paths) {
-                    File f = new File(path);
-
-                    if (!f.canRead())
-                        continue;
-
-                    FileObject fo = FileUtil.toFileObject(f);
-                    if (FileUtil.isArchiveFile(fo)) {
-                        fo = FileUtil.getArchiveRoot(fo);
-                    }
-                    if (fo != null) {
-                        urls.add(fo.toURL());
-                    }
-                }
-                bootClassPath = ClassPathSupport.createClassPath((URL[])urls.toArray(new URL[0]));
+                bootClassPath = TestUtil.getBootClassPath();
             }
             return bootClassPath;
         }
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/transform/Transformer.java b/java.source.base/test/unit/src/org/netbeans/modules/java/source/transform/Transformer.java
index c0b243038..3e1898916 100644
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/transform/Transformer.java
+++ b/java.source.base/test/unit/src/org/netbeans/modules/java/source/transform/Transformer.java
@@ -22,7 +22,7 @@
 import org.netbeans.modules.java.source.query.CommentHandler;
 import org.openide.util.NbBundle;
 import com.sun.source.tree.*;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.tools.javac.model.JavacTypes;
 import com.sun.tools.javac.util.Context;
 import java.util.List;
@@ -39,7 +39,7 @@
  * is done by a supplied ImmutableTreeTranslator implementation.  A new context
  * is set upon successful completion of this Transformer.
  */
-public abstract class Transformer<R, P> extends TreeScanner<R,P> {
+public abstract class Transformer<R, P> extends ErrorAwareTreeScanner<R,P> {
 
     CommentHandler commentHandler;
     public TreeMaker make;
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/usages/CompromiseSATest.java b/java.source.base/test/unit/src/org/netbeans/modules/java/source/usages/CompromiseSATest.java
index 7d072b85a..0b3bcf164 100644
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/usages/CompromiseSATest.java
+++ b/java.source.base/test/unit/src/org/netbeans/modules/java/source/usages/CompromiseSATest.java
@@ -50,6 +50,7 @@
 import org.netbeans.modules.classfile.ClassName;
 import org.netbeans.modules.classfile.Method;
 import org.netbeans.modules.classfile.Variable;
+import org.netbeans.modules.java.source.ElementUtils;
 import org.netbeans.modules.java.source.usages.ClassIndexImpl.UsageType;
 
 /**
@@ -223,8 +224,7 @@ private void performClassSignatureFromElementTest (final String testClassName) t
         InputStream in = this.prepareData (testClassName);
 	try {
 	    JavacTask jt = prepareJavac ();
-	    JavacElements elements = (JavacElements) jt.getElements();
-	    TypeElement be = elements.getTypeElementByBinaryName(testClassName);
+	    TypeElement be = ElementUtils.getTypeElementByBinaryName(jt, testClassName);
             assertNotNull ("Javac Error", be);
 	    String className = ClassFileUtil.encodeClassName(be);
 	    ClassFile cf = new ClassFile (in, true);
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/usages/SourceAnalyzerTest.java b/java.source.base/test/unit/src/org/netbeans/modules/java/source/usages/SourceAnalyzerTest.java
index d04a73699..1e0fd81b4 100644
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/usages/SourceAnalyzerTest.java
+++ b/java.source.base/test/unit/src/org/netbeans/modules/java/source/usages/SourceAnalyzerTest.java
@@ -23,6 +23,7 @@
 import com.sun.tools.javac.api.JavacTaskImpl;
 import java.io.File;
 import java.util.ArrayDeque;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.EnumSet;
 import java.util.List;
@@ -106,14 +107,14 @@ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
                 true,
                 false,
                 true);
+            final JavaFileObject jfo = FileObjects.sourceFileObject(javaFile, src);
             final JavacTaskImpl jt = JavacParser.createJavacTask(
                 cpInfo,
                 diag,
                 SourceLevelQuery.getSourceLevel(src),  //NOI18N
                 SourceLevelQuery.Profile.DEFAULT,
-                null, null, null, null, null);
-            final JavaFileObject jfo = FileObjects.sourceFileObject(javaFile, src);
-            final Iterable<? extends CompilationUnitTree> trees = jt.parse(jfo);
+                null, null, null, null, Arrays.asList(jfo));
+            final Iterable<? extends CompilationUnitTree> trees = jt.parse();
             jt.enter();
             jt.analyze();
             final SourceAnalyzerFactory.SimpleAnalyzer sa = SourceAnalyzerFactory.createSimpleAnalyzer();
@@ -159,14 +160,14 @@ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
                 true,
                 false,
                 true);
+            final JavaFileObject jfo = FileObjects.sourceFileObject(javaFile, src);
             final JavacTaskImpl jt = JavacParser.createJavacTask(
                 cpInfo,
                 diag,
                 SourceLevelQuery.getSourceLevel(src),  //NOI18N
                 SourceLevelQuery.Profile.DEFAULT,
-                null, null, null, null, null);
-            final JavaFileObject jfo = FileObjects.sourceFileObject(javaFile, src);
-            final Iterable<? extends CompilationUnitTree> trees = jt.parse(jfo);
+                null, null, null, null, Arrays.asList(jfo));
+            final Iterable<? extends CompilationUnitTree> trees = jt.parse();
             jt.enter();
             jt.analyze();
             final SourceAnalyzerFactory.SimpleAnalyzer sa = SourceAnalyzerFactory.createSimpleAnalyzer();
@@ -208,14 +209,14 @@ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
                 true,
                 false,
                 true);
+            final JavaFileObject jfo = FileObjects.sourceFileObject(javaFile, src);
             final JavacTaskImpl jt = JavacParser.createJavacTask(
                 cpInfo,
                 diag,
                 SourceLevelQuery.getSourceLevel(src),  //NOI18N
                 SourceLevelQuery.Profile.DEFAULT,
-                null, null, null, null, null);
-            final JavaFileObject jfo = FileObjects.sourceFileObject(javaFile, src);
-            final Iterable<? extends CompilationUnitTree> trees = jt.parse(jfo);
+                null, null, null, null, Arrays.asList(jfo));
+            final Iterable<? extends CompilationUnitTree> trees = jt.parse();
             jt.enter();
             jt.analyze();
             final SourceAnalyzerFactory.SimpleAnalyzer sa = SourceAnalyzerFactory.createSimpleAnalyzer();
diff --git a/java.source.nbjavac/build.xml b/java.source.nbjavac/build.xml
new file mode 100644
index 000000000..da36c62f1
--- /dev/null
+++ b/java.source.nbjavac/build.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<project basedir="." default="netbeans" name="java.source.nbjavac">
+    <description>Builds, tests, and runs the project org.netbeans.modules.java.source.nbjavac</description>
+    <import file="../nbbuild/templates/projectized.xml"/>
+</project>
diff --git a/java.source.nbjavac/manifest.mf b/java.source.nbjavac/manifest.mf
new file mode 100644
index 000000000..0abeede7f
--- /dev/null
+++ b/java.source.nbjavac/manifest.mf
@@ -0,0 +1,6 @@
+Manifest-Version: 1.0
+AutoUpdate-Show-In-Client: false
+OpenIDE-Module: org.netbeans.modules.java.source.nbjavac
+OpenIDE-Module-Implementation-Version: 1
+OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/java/source/nbjavac/Bundle.properties
+OpenIDE-Module-Requires: org.netbeans.modules.nbjavac
diff --git a/java.source.nbjavac/nbproject/project.properties b/java.source.nbjavac/nbproject/project.properties
new file mode 100644
index 000000000..b688af17f
--- /dev/null
+++ b/java.source.nbjavac/nbproject/project.properties
@@ -0,0 +1,22 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+is.eager=true
+javac.source=1.8
+javac.compilerargs=-Xlint -Xlint:-serial
+spec.version.base=1.0
+requires.nb.javac.impl=true
diff --git a/java.source.nbjavac/nbproject/project.xml b/java.source.nbjavac/nbproject/project.xml
new file mode 100644
index 000000000..5adc7ac2f
--- /dev/null
+++ b/java.source.nbjavac/nbproject/project.xml
@@ -0,0 +1,180 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+
+-->
+<project xmlns="http://www.netbeans.org/ns/project/1">
+    <type>org.netbeans.modules.apisupport.project</type>
+    <configuration>
+        <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
+            <code-name-base>org.netbeans.modules.java.source.nbjavac</code-name-base>
+            <module-dependencies>
+                <dependency>
+                    <code-name-base>org.netbeans.api.annotations.common</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <release-version>1</release-version>
+                        <specification-version>1.28</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.api.java</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <release-version>1</release-version>
+                        <specification-version>1.66</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.api.java.classpath</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <release-version>1</release-version>
+                        <specification-version>1.54</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.lib.nbjavac</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <implementation-version/>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.libs.javacapi</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <specification-version>8.21</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.libs.javacimpl</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <release-version>1</release-version>
+                        <implementation-version/>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.modules.java.source.base</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <implementation-version/>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.modules.parsing.api</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <release-version>1</release-version>
+                        <specification-version>9.7</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.modules.parsing.indexing</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <implementation-version/>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.openide.filesystems</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <specification-version>9.11</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.openide.util</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <specification-version>9.8</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.openide.util.lookup</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <specification-version>8.34</specification-version>
+                    </run-dependency>
+                </dependency>
+            </module-dependencies>
+            <test-dependencies>
+                <test-type>
+                    <name>unit</name>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.lib.nbjavac</code-name-base>
+                        <compile-dependency/>
+                        <test/>
+                    </test-dependency>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.libs.junit4</code-name-base>
+                        <compile-dependency/>
+                    </test-dependency>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.modules.editor.mimelookup</code-name-base>
+                        <compile-dependency/>
+                        <test/>
+                    </test-dependency>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.modules.java.source</code-name-base>
+                        <compile-dependency/>
+                    </test-dependency>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.modules.java.source.base</code-name-base>
+                        <recursive/>
+                        <compile-dependency/>
+                        <test/>
+                    </test-dependency>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
+                        <recursive/>
+                        <compile-dependency/>
+                    </test-dependency>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.modules.parsing.indexing</code-name-base>
+                        <compile-dependency/>
+                        <test/>
+                    </test-dependency>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.modules.parsing.nb</code-name-base>
+                        <compile-dependency/>
+                    </test-dependency>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.modules.projectapi.nb</code-name-base>
+                        <compile-dependency/>
+                    </test-dependency>
+                </test-type>
+            </test-dependencies>
+            <public-packages/>
+        </data>
+    </configuration>
+</project>
diff --git a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/Bundle.properties b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/Bundle.properties
new file mode 100644
index 000000000..01c54b7f1
--- /dev/null
+++ b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/Bundle.properties
@@ -0,0 +1,18 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+OpenIDE-Module-Name=Java Source nb-javac Bridge
diff --git a/java.source.base/src/org/netbeans/modules/java/source/usages/ClassNamesForFileOraculumImpl.java b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/ClassNamesForFileOraculumImpl.java
similarity index 97%
rename from java.source.base/src/org/netbeans/modules/java/source/usages/ClassNamesForFileOraculumImpl.java
rename to java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/ClassNamesForFileOraculumImpl.java
index 828fc5165..b22d05065 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/usages/ClassNamesForFileOraculumImpl.java
+++ b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/ClassNamesForFileOraculumImpl.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.netbeans.modules.java.source.usages;
+package org.netbeans.modules.java.source.nbjavac.indexing;
 
 import com.sun.tools.javac.api.ClassNamesForFileOraculum;
 import java.util.LinkedList;
diff --git a/java.source.base/src/org/netbeans/modules/java/source/indexing/MultiPassCompileWorker.java b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/MultiPassCompileWorker.java
similarity index 97%
rename from java.source.base/src/org/netbeans/modules/java/source/indexing/MultiPassCompileWorker.java
rename to java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/MultiPassCompileWorker.java
index 3dc4f07dd..629d01cb9 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/indexing/MultiPassCompileWorker.java
+++ b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/MultiPassCompileWorker.java
@@ -17,9 +17,10 @@
  * under the License.
  */
 
-package org.netbeans.modules.java.source.indexing;
+package org.netbeans.modules.java.source.nbjavac.indexing;
 
 import com.sun.source.tree.CompilationUnitTree;
+import com.sun.tools.javac.api.ClassNamesForFileOraculum;
 import com.sun.tools.javac.api.JavacTaskImpl;
 import com.sun.tools.javac.code.Symbol.ClassSymbol;
 import com.sun.tools.javac.code.Symtab;
@@ -59,12 +60,17 @@
 import org.netbeans.api.java.queries.CompilerOptionsQuery;
 import org.netbeans.api.java.source.ClasspathInfo;
 import org.netbeans.api.java.source.ElementHandle;
-import org.netbeans.modules.java.source.TreeLoader;
+import org.netbeans.modules.java.source.indexing.APTUtils;
+import org.netbeans.modules.java.source.indexing.CompileWorker;
+import org.netbeans.modules.java.source.indexing.DiagnosticListenerImpl;
+import org.netbeans.modules.java.source.indexing.JavaCustomIndexer;
 import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.CompileTuple;
+import org.netbeans.modules.java.source.indexing.JavaIndex;
+import org.netbeans.modules.java.source.indexing.JavaParsingContext;
+import org.netbeans.modules.java.source.nbjavac.parsing.TreeLoader;
 import org.netbeans.modules.java.source.parsing.FileObjects;
 import org.netbeans.modules.java.source.parsing.JavacParser;
 import org.netbeans.modules.java.source.parsing.OutputFileManager;
-import org.netbeans.modules.java.source.usages.ClassNamesForFileOraculumImpl;
 import org.netbeans.modules.java.source.usages.ExecutableFilesIndex;
 import org.netbeans.modules.parsing.spi.indexing.Context;
 import org.netbeans.modules.parsing.spi.indexing.Indexable;
@@ -81,7 +87,7 @@
     private boolean checkForMemLow = true;
 
     @Override
-    ParsingOutput compile(
+    protected ParsingOutput compile(
             final ParsingOutput previous,
             final Context context,
             final JavaParsingContext javaContext,
@@ -158,7 +164,6 @@ ParsingOutput compile(
                                 diagnosticListener,
                                 javaContext.getSourceLevel(),
                                 javaContext.getProfile(),
-                                cnffOraculum,
                                 javaContext.getFQNs(),
                                 new CancelService() {
                                     public @Override boolean isCanceled() {
@@ -166,7 +171,9 @@ ParsingOutput compile(
                                     }
                                 },
                                 active.aptGenerated ? null : APTUtils.get(context.getRoot()),
-                                CompilerOptionsQuery.getOptions(context.getRoot()));
+                                CompilerOptionsQuery.getOptions(context.getRoot()),
+                                Collections.emptyList());
+                        jt.getContext().put(ClassNamesForFileOraculum.class, cnffOraculum);
                         Iterable<? extends Processor> processors = jt.getProcessors();
                         aptEnabled = processors != null && processors.iterator().hasNext();
                         if (JavaIndex.LOG.isLoggable(Level.FINER)) {
diff --git a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/NBJavacCompileWorkerProvider.java b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/NBJavacCompileWorkerProvider.java
new file mode 100644
index 000000000..1029796da
--- /dev/null
+++ b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/NBJavacCompileWorkerProvider.java
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.source.nbjavac.indexing;
+
+import java.util.List;
+import org.netbeans.modules.java.source.indexing.CompileWorker;
+import org.netbeans.modules.java.source.indexing.JavaCustomIndexer;
+import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.CompileTuple;
+import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.CompileWorkerProvider;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ * @author lahvac
+ */
+@ServiceProvider(service=JavaCustomIndexer.CompileWorkerProvider.class, position=100)
+public class NBJavacCompileWorkerProvider implements CompileWorkerProvider {
+
+    private static final int TRESHOLD = 500;
+
+    @Override
+    public CompileWorker[] getWorkers(List<CompileTuple> toCompile) {
+        return new CompileWorker[] {
+            toCompile.size() < TRESHOLD ? new SuperOnePassCompileWorker() : new OnePassCompileWorker(),
+            new MultiPassCompileWorker()
+        };
+    }
+
+}
diff --git a/java.source.base/src/org/netbeans/modules/java/source/indexing/OnePassCompileWorker.java b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/OnePassCompileWorker.java
similarity index 95%
rename from java.source.base/src/org/netbeans/modules/java/source/indexing/OnePassCompileWorker.java
rename to java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/OnePassCompileWorker.java
index 7746c5b1f..3cae20c94 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/indexing/OnePassCompileWorker.java
+++ b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/OnePassCompileWorker.java
@@ -17,9 +17,10 @@
  * under the License.
  */
 
-package org.netbeans.modules.java.source.indexing;
+package org.netbeans.modules.java.source.nbjavac.indexing;
 
 import com.sun.source.tree.CompilationUnitTree;
+import com.sun.tools.javac.api.ClassNamesForFileOraculum;
 import com.sun.tools.javac.api.JavacTaskImpl;
 import com.sun.tools.javac.code.Symbol.ClassSymbol;
 import com.sun.tools.javac.code.Type;
@@ -41,7 +42,6 @@
 import java.util.logging.Level;
 import java.util.stream.Collectors;
 import java.util.stream.StreamSupport;
-import javax.annotation.processing.Processor;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ModuleElement;
 import javax.lang.model.element.TypeElement;
@@ -52,13 +52,20 @@
 import org.netbeans.api.java.source.ElementHandle;
 import org.netbeans.lib.nbjavac.services.CancelAbort;
 import org.netbeans.lib.nbjavac.services.CancelService;
-import org.netbeans.modules.java.source.TreeLoader;
+import org.netbeans.modules.java.source.indexing.APTUtils;
+import org.netbeans.modules.java.source.indexing.CompileWorker;
+import org.netbeans.modules.java.source.indexing.DiagnosticListenerImpl;
+import org.netbeans.modules.java.source.indexing.JavaCustomIndexer;
 import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.CompileTuple;
+import org.netbeans.modules.java.source.indexing.JavaIndex;
+import org.netbeans.modules.java.source.indexing.JavaParsingContext;
+import org.netbeans.modules.java.source.indexing.SourcePrefetcher;
+import org.netbeans.modules.java.source.nbjavac.parsing.TreeLoader;
 import org.netbeans.modules.java.source.parsing.FileManagerTransaction;
 import org.netbeans.modules.java.source.parsing.FileObjects;
 import org.netbeans.modules.java.source.parsing.JavacParser;
 import org.netbeans.modules.java.source.parsing.OutputFileManager;
-import org.netbeans.modules.java.source.usages.ClassNamesForFileOraculumImpl;
+//import org.netbeans.modules.java.source.usages.ClassNamesForFileOraculumImpl;
 import org.netbeans.modules.java.source.usages.ExecutableFilesIndex;
 import org.netbeans.modules.parsing.spi.indexing.Context;
 import org.netbeans.modules.parsing.spi.indexing.Indexable;
@@ -75,7 +82,7 @@
 final class OnePassCompileWorker extends CompileWorker {
 
     @Override
-    ParsingOutput compile(
+    protected ParsingOutput compile(
             final ParsingOutput previous,
             final Context context,
             final JavaParsingContext javaContext,
@@ -120,7 +127,6 @@ ParsingOutput compile(
                                     dc,
                                     javaContext.getSourceLevel(),
                                     javaContext.getProfile(),
-                                    cnffOraculum,
                                     javaContext.getFQNs(),
                                     new CancelService() {
                                         public @Override boolean isCanceled() {
@@ -128,7 +134,9 @@ ParsingOutput compile(
                                         }
                                     },
                                     tuple.aptGenerated ? null : APTUtils.get(context.getRoot()),
-                                    CompilerOptionsQuery.getOptions(context.getRoot()));
+                                    CompilerOptionsQuery.getOptions(context.getRoot()),
+                                    Collections.emptyList());
+                                jt.getContext().put(ClassNamesForFileOraculum.class, cnffOraculum);
                             }
                             for (CompilationUnitTree cut : jt.parse(tuple.jfo)) { //TODO: should be exactly one
                                 if (units != null) {
diff --git a/java.source.base/src/org/netbeans/modules/java/source/indexing/SuperOnePassCompileWorker.java b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/SuperOnePassCompileWorker.java
similarity index 95%
rename from java.source.base/src/org/netbeans/modules/java/source/indexing/SuperOnePassCompileWorker.java
rename to java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/SuperOnePassCompileWorker.java
index eb7dde55d..85e71caac 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/indexing/SuperOnePassCompileWorker.java
+++ b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/indexing/SuperOnePassCompileWorker.java
@@ -17,13 +17,12 @@
  * under the License.
  */
 
-package org.netbeans.modules.java.source.indexing;
+package org.netbeans.modules.java.source.nbjavac.indexing;
 
 import com.sun.source.tree.CompilationUnitTree;
 import com.sun.source.tree.PackageTree;
 import com.sun.source.tree.Tree;
 import com.sun.tools.javac.api.JavacTaskImpl;
-import com.sun.tools.javac.code.Symbol.ClassSymbol;
 import com.sun.tools.javac.code.Symbol.TypeSymbol;
 import com.sun.tools.javac.comp.AttrContext;
 import com.sun.tools.javac.comp.Enter;
@@ -56,13 +55,20 @@
 import org.netbeans.api.java.queries.CompilerOptionsQuery;
 import org.netbeans.api.java.source.ClasspathInfo;
 import org.netbeans.api.java.source.ElementHandle;
-import org.netbeans.modules.java.source.TreeLoader;
+import org.netbeans.modules.java.source.indexing.APTUtils;
+import org.netbeans.modules.java.source.indexing.CompileWorker;
+import org.netbeans.modules.java.source.indexing.DiagnosticListenerImpl;
+import org.netbeans.modules.java.source.indexing.JavaCustomIndexer;
 import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.CompileTuple;
+import org.netbeans.modules.java.source.indexing.JavaIndex;
+import org.netbeans.modules.java.source.indexing.JavaParsingContext;
+import org.netbeans.modules.java.source.indexing.SourcePrefetcher;
+import org.netbeans.modules.java.source.nbjavac.parsing.TreeLoader;
 import org.netbeans.modules.java.source.parsing.FileManagerTransaction;
 import org.netbeans.modules.java.source.parsing.FileObjects;
 import org.netbeans.modules.java.source.parsing.JavacParser;
 import org.netbeans.modules.java.source.parsing.OutputFileManager;
-import org.netbeans.modules.java.source.usages.ClassNamesForFileOraculumImpl;
+//import org.netbeans.modules.java.source.usages.ClassNamesForFileOraculumImpl;
 import org.netbeans.modules.java.source.usages.ExecutableFilesIndex;
 import org.netbeans.modules.parsing.spi.indexing.Context;
 import org.netbeans.modules.parsing.spi.indexing.Indexable;
@@ -78,7 +84,7 @@
 final class SuperOnePassCompileWorker extends CompileWorker {
 
     @Override
-    ParsingOutput compile(
+    protected ParsingOutput compile(
             final ParsingOutput previous,
             final Context context,
             final JavaParsingContext javaContext,
@@ -90,7 +96,7 @@ ParsingOutput compile(
         final Set<Indexable> finished = previous != null ? previous.finishedFiles : new HashSet<>();
         final Set<ElementHandle<TypeElement>> modifiedTypes = previous != null ? previous.modifiedTypes : new HashSet<>();
         final Set<javax.tools.FileObject> aptGenerated = previous != null ? previous.aptGenerated : new HashSet<>();
-        final ClassNamesForFileOraculumImpl cnffOraculum = new ClassNamesForFileOraculumImpl(file2FQNs);
+//        final ClassNamesForFileOraculumImpl cnffOraculum = new ClassNamesForFileOraculumImpl(file2FQNs);
 
         final DiagnosticListenerImpl dc = new DiagnosticListenerImpl();
         final LinkedList<CompilationUnitTree> trees = new LinkedList<CompilationUnitTree>();
@@ -124,7 +130,6 @@ ParsingOutput compile(
                                     dc,
                                     javaContext.getSourceLevel(),
                                     javaContext.getProfile(),
-                                    cnffOraculum,
                                     javaContext.getFQNs(),
                                     new CancelService() {
                                         public @Override boolean isCanceled() {
@@ -132,7 +137,8 @@ ParsingOutput compile(
                                         }
                                     },
                                     tuple.aptGenerated ? null : APTUtils.get(context.getRoot()),
-                                    CompilerOptionsQuery.getOptions(context.getRoot()));
+                                    CompilerOptionsQuery.getOptions(context.getRoot()),
+                                    Collections.emptyList());
                             }
                             for (CompilationUnitTree cut : jt.parse(tuple.jfo)) { //TODO: should be exactly one
                                 if (units != null) {
diff --git a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/ContextEnhancerImpl.java b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/ContextEnhancerImpl.java
new file mode 100644
index 000000000..e596ccb33
--- /dev/null
+++ b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/ContextEnhancerImpl.java
@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.source.nbjavac.parsing;
+
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javadoc.main.JavadocClassFinder;
+import org.netbeans.modules.java.source.parsing.JavacParser.ContextEnhancer;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ * @author lahvac
+ */
+@ServiceProvider(service=ContextEnhancer.class, supersedes="org.netbeans.modules.java.source.parsing.JavacParser$VanillaJavacContextEnhancer")
+public class ContextEnhancerImpl implements ContextEnhancer {
+
+    @Override
+    public void enhance(Context context, boolean backgroundCompilation) {
+        if (!backgroundCompilation)
+            JavadocClassFinder.preRegister(context);
+    }
+    
+}
diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/FindAnonymousVisitor.java b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/FindAnonymousVisitor.java
similarity index 92%
rename from java.source.base/src/org/netbeans/modules/java/source/parsing/FindAnonymousVisitor.java
rename to java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/FindAnonymousVisitor.java
index 6a6644ef6..78c2f65cf 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/parsing/FindAnonymousVisitor.java
+++ b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/FindAnonymousVisitor.java
@@ -17,13 +17,13 @@
  * under the License.
  */
 
-package org.netbeans.modules.java.source.parsing;
+package org.netbeans.modules.java.source.nbjavac.parsing;
 
 import com.sun.source.tree.ClassTree;
 import com.sun.source.tree.MethodTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.VariableTree;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.tools.javac.tree.JCTree.JCClassDecl;
 import java.util.HashSet;
 import java.util.Set;
@@ -34,7 +34,7 @@
  * Finds anonymous and local classes in given method tree.
  * @author Tomas Zezula
  */
-class FindAnonymousVisitor extends TreeScanner<Void,Void> {
+class FindAnonymousVisitor extends ErrorAwareTreeScanner<Void,Void> {
 
     private static enum Mode {COLLECT, CHECK};
 
diff --git a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/PartialReparserImpl.java b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/PartialReparserImpl.java
new file mode 100644
index 000000000..37c3474bf
--- /dev/null
+++ b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/PartialReparserImpl.java
@@ -0,0 +1,226 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.source.nbjavac.parsing;
+
+import com.sun.source.tree.ClassTree;
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.MethodTree;
+import com.sun.source.tree.Tree;
+import com.sun.source.util.TreePath;
+import com.sun.tools.javac.api.JavacTaskImpl;
+import com.sun.tools.javac.api.JavacTrees;
+import com.sun.tools.javac.parser.LazyDocCommentTable;
+import com.sun.tools.javac.tree.EndPosTable;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.CouplingAbort;
+import com.sun.tools.javac.util.Log;
+import com.sun.tools.javac.util.Options;
+import com.sun.tools.javac.util.Position.LineMapImpl;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticListener;
+import javax.tools.JavaFileObject;
+import org.netbeans.api.java.source.JavaSource.Phase;
+import org.netbeans.modules.*;
+import org.netbeans.modules.java.source.parsing.CompilationInfoImpl;
+import org.netbeans.modules.java.source.parsing.JavacFlowListener;
+import org.netbeans.modules.java.source.parsing.JavacParser;
+import org.netbeans.modules.java.source.parsing.JavacParser.PartialReparser;
+import org.netbeans.modules.parsing.api.Snapshot;
+import org.openide.filesystems.FileObject;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ * @author lahvac
+ */
+@ServiceProvider(service = PartialReparser.class, position = 100)
+public class PartialReparserImpl implements PartialReparser {
+    private static final Logger LOGGER = Logger.getLogger(PartialReparserImpl.class.getName());
+
+    @Override
+    public boolean reparseMethod (final CompilationInfoImpl ci,
+            final Snapshot snapshot,
+            final MethodTree orig,
+            final String newBody) throws IOException {
+        assert ci != null;
+        final FileObject fo = ci.getFileObject();
+        if (LOGGER.isLoggable(Level.FINER)) {
+            LOGGER.log(Level.FINER, "Reparse method in: {0}", fo);          //NOI18N
+        }
+        final Phase currentPhase = ci.getPhase();
+        if (Phase.PARSED.compareTo(currentPhase) > 0) {
+            return false;
+        }
+        try {
+            final CompilationUnitTree cu = ci.getCompilationUnit();
+            if (cu == null || newBody == null) {
+                return false;
+            }
+            final JavacTaskImpl task = ci.getJavacTask();
+            if (Options.instance(task.getContext()).isSet(JavacParser.LOMBOK_DETECTED)) {
+                return false;
+            }
+            PartialReparserService pr = PartialReparserService.instance(task.getContext());
+            if (((JCTree.JCMethodDecl)orig).localEnv == null) {
+                //We are seeing interface method or abstract or native method with body.
+                //Don't do any optimalization of this broken code - has no attr env.
+                return false;
+            }
+            final JavacTrees jt = JavacTrees.instance(task);
+            final int origStartPos = (int) jt.getSourcePositions().getStartPosition(cu, orig.getBody());
+            final int origEndPos = (int) jt.getSourcePositions().getEndPosition(cu, orig.getBody());
+            if (origStartPos < 0) {
+                LOGGER.log(Level.WARNING, "Javac returned startpos: {0} < 0", new Object[]{origStartPos});  //NOI18N
+                return false;
+            }
+            if (origStartPos > origEndPos) {
+                LOGGER.log(Level.WARNING, "Javac returned startpos: {0} > endpos: {1}", new Object[]{origStartPos, origEndPos});  //NOI18N
+                return false;
+            }
+            final FindAnonymousVisitor fav = new FindAnonymousVisitor();
+            fav.scan(orig.getBody(), null);
+            if (fav.hasLocalClass) {
+                if (LOGGER.isLoggable(Level.FINER)) {
+                    LOGGER.log(Level.FINER, "Skeep reparse method (old local classes): {0}", fo);   //NOI18N
+                }
+                return false;
+            }
+            final int firstInner = fav.firstInner;
+            final int noInner = fav.noInner;
+            final Context ctx = task.getContext();
+            final TreeLoader treeLoader = TreeLoader.instance(ctx);
+            if (treeLoader != null) {
+                treeLoader.startPartialReparse();
+            }
+            try {
+                final Log l = Log.instance(ctx);
+                l.startPartialReparse();
+                final JavaFileObject prevLogged = l.useSource(cu.getSourceFile());
+                JCTree.JCBlock block;
+                try {
+                    DiagnosticListener dl = ci.getDiagnosticListener();
+                    assert dl instanceof CompilationInfoImpl.DiagnosticListenerImpl;
+                    ((CompilationInfoImpl.DiagnosticListenerImpl)dl).startPartialReparse(origStartPos, origEndPos);
+                    long start = System.currentTimeMillis();
+                    Map<JCTree,LazyDocCommentTable.Entry> docComments = new HashMap<>();
+                    block = pr.reparseMethodBody(cu, orig, newBody + " ", firstInner, docComments);
+                    LOGGER.log(Level.FINER, "Reparsed method in: {0}", fo);     //NOI18N
+                    if (block == null) {
+                        LOGGER.log(
+                            Level.FINER,
+                            "Skeep reparse method, invalid position, newBody: ",       //NOI18N
+                            newBody);
+                        return false;
+                    }
+                    final int newEndPos = (int) jt.getSourcePositions().getEndPosition(cu, block);
+                    if (newEndPos != origStartPos + newBody.length()) {
+                        return false;
+                    }
+                    fav.reset();
+                    fav.scan(block, null);
+                    final int newNoInner = fav.noInner;
+                    if (fav.hasLocalClass || noInner != newNoInner) {
+                        if (LOGGER.isLoggable(Level.FINER)) {
+                            LOGGER.log(Level.FINER, "Skeep reparse method (new local classes): {0}", fo);   //NOI18N
+                        }
+                        return false;
+                    }
+                    ((LazyDocCommentTable) ((JCTree.JCCompilationUnit)cu).docComments).table.keySet().removeAll(fav.docOwners);
+                    ((LazyDocCommentTable) ((JCTree.JCCompilationUnit)cu).docComments).table.putAll(docComments);
+                    long end = System.currentTimeMillis();
+                    if (fo != null) {
+                        JavacParser.logTime (fo,Phase.PARSED,(end-start));
+                    }
+                    final int delta = newEndPos - origEndPos;
+                    final EndPosTable endPos = ((JCTree.JCCompilationUnit)cu).endPositions;
+                    final TranslatePositionsVisitor tpv = new TranslatePositionsVisitor(orig, endPos, delta);
+                    tpv.scan(cu, null);
+                    ((JCTree.JCMethodDecl)orig).body = block;
+                    if (Phase.RESOLVED.compareTo(currentPhase)<=0) {
+                        start = System.currentTimeMillis();
+                        pr.reattrMethodBody(orig, block);
+                        if (LOGGER.isLoggable(Level.FINER)) {
+                            LOGGER.log(Level.FINER, "Resolved method in: {0}", fo);     //NOI18N
+                        }
+                        if (!((CompilationInfoImpl.DiagnosticListenerImpl)dl).hasPartialReparseErrors()) {
+                            final JavacFlowListener fl = JavacFlowListener.instance(ctx);
+                            if (fl != null && fl.hasFlowCompleted(fo)) {
+                                if (LOGGER.isLoggable(Level.FINER)) {
+                                    final List<? extends Diagnostic> diag = ci.getDiagnostics();
+                                    if (!diag.isEmpty()) {
+                                        LOGGER.log(Level.FINER, "Reflow with errors: {0} {1}", new Object[]{fo, diag});     //NOI18N
+                                    }
+                                }
+                                TreePath tp = TreePath.getPath(cu, orig);       //todo: store treepath in changed method => improve speed
+                                Tree t = tp.getParentPath().getLeaf();
+                                pr.reflowMethodBody(cu, (ClassTree) t, orig);
+                                if (LOGGER.isLoggable(Level.FINER)) {
+                                    LOGGER.log(Level.FINER, "Reflowed method in: {0}", fo); //NOI18N
+                                }
+                            }
+                        }
+                        end = System.currentTimeMillis();
+                        if (fo != null) {
+                            JavacParser.logTime (fo, Phase.ELEMENTS_RESOLVED,0L);
+                            JavacParser.logTime (fo,Phase.RESOLVED,(end-start));
+                        }
+                    }
+
+                    //fix CompilationUnitTree.getLineMap:
+                    long startM = System.currentTimeMillis();
+                    char[] chars = snapshot.getText().toString().toCharArray();
+                    ((LineMapImpl) cu.getLineMap()).build(chars, chars.length);
+                    LOGGER.log(Level.FINER, "Rebuilding LineMap took: {0}", System.currentTimeMillis() - startM);
+
+                    ((CompilationInfoImpl.DiagnosticListenerImpl)dl).endPartialReparse (delta);
+                } finally {
+                    l.endPartialReparse();
+                    l.useSource(prevLogged);
+                }
+                ci.update(snapshot);
+            } finally {
+              if (treeLoader != null) {
+                  treeLoader.endPartialReparse();
+              }
+            }
+        } catch (CouplingAbort ca) {
+            //Needs full reparse
+            return false;
+        } catch (Throwable t) {
+            if (t instanceof ThreadDeath) {
+                throw (ThreadDeath) t;
+            }
+            boolean a = false;
+            assert a = true;
+            if (a) {
+                JavacParser.dumpSource(ci, t);
+            }
+            return false;
+        }
+        return true;
+    }
+
+}
diff --git a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/PartialReparser.java b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/PartialReparserService.java
similarity index 64%
rename from lib.nbjavac/src/org/netbeans/lib/nbjavac/services/PartialReparser.java
rename to java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/PartialReparserService.java
index 0080cc0da..30ed25d63 100644
--- a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/PartialReparser.java
+++ b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/PartialReparserService.java
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.netbeans.lib.nbjavac.services;
+package org.netbeans.modules.java.source.nbjavac.parsing;
 
 import com.sun.source.tree.BlockTree;
 import com.sun.source.tree.ClassTree;
@@ -34,6 +34,9 @@
 import com.sun.tools.javac.comp.TypeEnter;
 import com.sun.tools.javac.parser.JavacParser;
 import com.sun.tools.javac.parser.LazyDocCommentTable;
+import com.sun.tools.javac.parser.Scanner;
+import com.sun.tools.javac.parser.ScannerFactory;
+import com.sun.tools.javac.tree.EndPosTable;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.JCBlock;
 import com.sun.tools.javac.tree.JCTree.JCClassDecl;
@@ -49,20 +52,22 @@
 import com.sun.tools.javac.util.Names;
 import java.nio.CharBuffer;
 import java.util.Map;
+import org.netbeans.lib.nbjavac.services.CancelService;
+import org.netbeans.lib.nbjavac.services.NBParserFactory;
 
 /**
  *
  * @author Tomas Zezula
  */
-public class PartialReparser {
+public class PartialReparserService {
     
-    protected static final Context.Key<PartialReparser> partialReparserKey = new Context.Key<PartialReparser>();
+    protected static final Context.Key<PartialReparserService> partialReparserKey = new Context.Key<PartialReparserService>();
     
-    public static PartialReparser instance(Context ctx) {
-        PartialReparser res = ctx.get(partialReparserKey);
+    public static PartialReparserService instance(Context ctx) {
+        PartialReparserService res = ctx.get(partialReparserKey);
         
         if (res == null) {
-            ctx.put(partialReparserKey, res = new PartialReparser(ctx));
+            ctx.put(partialReparserKey, res = new PartialReparserService(ctx));
         }
         
         return res;
@@ -70,15 +75,14 @@ public static PartialReparser instance(Context ctx) {
 
     private final Context context;
 
-    public PartialReparser(Context context) {
+    public PartialReparserService(Context context) {
         this.context = context;
     }
 
     public JCBlock reparseMethodBody(CompilationUnitTree topLevel, MethodTree methodToReparse, String newBodyText, int annonIndex,
             final Map<? super JCTree,? super LazyDocCommentTable.Entry> docComments) {
-        NBParserFactory parserFactory = (NBParserFactory) NBParserFactory.instance(context);
         CharBuffer buf = CharBuffer.wrap((newBodyText+"\u0000").toCharArray(), 0, newBodyText.length());
-        JavacParser parser = parserFactory.newParser(buf, ((JCBlock)methodToReparse.getBody()).pos, ((JCCompilationUnit)topLevel).endPositions);
+        JavacParser parser = newParser(context, buf, ((JCBlock)methodToReparse.getBody()).pos, ((JCCompilationUnit)topLevel).endPositions);
         final JCStatement statement = parser.parseStatement();
         NBParserFactory.assignAnonymousClassIndices(Names.instance(context), statement, Names.instance(context).empty, annonIndex);
         if (statement.getKind() == Tree.Kind.BLOCK) {
@@ -90,6 +94,56 @@ public JCBlock reparseMethodBody(CompilationUnitTree topLevel, MethodTree method
         return null;
     }
 
+    public JavacParser newParser(Context context, CharSequence input, int startPos, final EndPosTable endPos) {
+        NBParserFactory parserFactory = (NBParserFactory) NBParserFactory.instance(context); //TODO: eliminate the cast
+        ScannerFactory scannerFactory = ScannerFactory.instance(context);
+        CancelService cancelService = CancelService.instance(context);
+        Scanner lexer = scannerFactory.newScanner(input, true);
+        lexer.seek(startPos);
+        if (endPos instanceof NBParserFactory.NBJavacParser.EndPosTableImpl) {
+            ((NBParserFactory.NBJavacParser.EndPosTableImpl)endPos).resetErrorEndPos();
+        }
+        return new NBParserFactory.NBJavacParser(parserFactory, lexer, true, false, true, false, cancelService) {
+            @Override protected JavacParser.AbstractEndPosTable newEndPosTable(boolean keepEndPositions) {
+                return new JavacParser.AbstractEndPosTable(this) {
+
+                    @Override
+                    public void storeEnd(JCTree tree, int endpos) {
+                        ((NBParserFactory.NBJavacParser.EndPosTableImpl)endPos).storeEnd(tree, endpos);
+                    }
+
+                    @Override
+                    protected <T extends JCTree> T to(T t) {
+                        storeEnd(t, token.endPos);
+                        return t;
+                    }
+
+                    @Override
+                    protected <T extends JCTree> T toP(T t) {
+                        storeEnd(t, S.prevToken().endPos);
+                        return t;
+                    }
+
+                    @Override
+                    public int getEndPos(JCTree tree) {
+                        return endPos.getEndPos(tree);
+                    }
+
+                    @Override
+                    public int replaceTree(JCTree oldtree, JCTree newtree) {
+                        return endPos.replaceTree(oldtree, newtree);
+                    }
+
+                    @Override
+                    public void setErrorEndPos(int errPos) {
+                        super.setErrorEndPos(errPos);
+                        ((NBParserFactory.NBJavacParser.EndPosTableImpl)endPos).setErrorEndPos(errPos);
+                    }
+                };
+            }
+        };
+    }
+
     public BlockTree reattrMethodBody(MethodTree methodToReparse, BlockTree block) {
         Attr attr = Attr.instance(context);
         assert ((JCMethodDecl)methodToReparse).localEnv != null;
diff --git a/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/SequentialParsingImpl.java b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/SequentialParsingImpl.java
new file mode 100644
index 000000000..a30b6a2ec
--- /dev/null
+++ b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/SequentialParsingImpl.java
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.source.nbjavac.parsing;
+
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.JavacTaskImpl;
+import java.io.IOException;
+import javax.tools.JavaFileObject;
+import org.netbeans.modules.java.source.parsing.JavacParser.SequentialParsing;
+import org.openide.util.lookup.ServiceProvider;
+
+/**
+ *
+ * @author lahvac
+ */
+@ServiceProvider(service=SequentialParsing.class)
+public class SequentialParsingImpl implements SequentialParsing {
+
+    @Override
+    public Iterable<? extends CompilationUnitTree> parse(JavacTask task, JavaFileObject file) throws IOException {
+        return ((JavacTaskImpl) task).parse(file);
+    }
+    
+}
diff --git a/java.source.base/src/org/netbeans/modules/java/source/parsing/TranslatePositionsVisitor.java b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/TranslatePositionsVisitor.java
similarity index 92%
rename from java.source.base/src/org/netbeans/modules/java/source/parsing/TranslatePositionsVisitor.java
rename to java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/TranslatePositionsVisitor.java
index 832ad84cc..79fdb5b84 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/parsing/TranslatePositionsVisitor.java
+++ b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/TranslatePositionsVisitor.java
@@ -17,24 +17,23 @@
  * under the License.
  */
 
-package org.netbeans.modules.java.source.parsing;
+package org.netbeans.modules.java.source.nbjavac.parsing;
 
 import com.sun.source.tree.CompilationUnitTree;
 import com.sun.source.tree.MethodTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.VariableTree;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.tools.javac.tree.EndPosTable;
 import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
-import org.netbeans.lib.nbjavac.services.NBParserFactory.NBJavacParser.EndPosTableImpl;
 
 /**
  * Helper visitor for partial reparse.
  * Updates tree positions by the given delta.
  * @author Tomas Zezula
  */
-class TranslatePositionsVisitor extends TreeScanner<Void,Void> {
+class TranslatePositionsVisitor extends ErrorAwareTreeScanner<Void,Void> {
 
     private final MethodTree changedMethod;
     private final EndPosTable endPos;
@@ -72,7 +71,7 @@ public Void scan(Tree node, Void p) {
                 else {
                     newPos = pos+delta;
                 }
-                ((EndPosTableImpl) endPos).storeEnd((JCTree)node,newPos);
+                endPos.storeEnd((JCTree)node,newPos);
             }                
         }
         return result;
diff --git a/java.source.base/src/org/netbeans/modules/java/source/TreeLoader.java b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/TreeLoader.java
similarity index 95%
rename from java.source.base/src/org/netbeans/modules/java/source/TreeLoader.java
rename to java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/TreeLoader.java
index f78f2790c..c6b7849cd 100644
--- a/java.source.base/src/org/netbeans/modules/java/source/TreeLoader.java
+++ b/java.source.nbjavac/src/org/netbeans/modules/java/source/nbjavac/parsing/TreeLoader.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.netbeans.modules.java.source;
+package org.netbeans.modules.java.source.nbjavac.parsing;
 
 import com.sun.source.tree.ClassTree;
 import com.sun.source.tree.CompilationUnitTree;
@@ -29,6 +29,7 @@
 import com.sun.source.util.JavacTask;
 import com.sun.source.util.TaskEvent;
 import com.sun.source.util.TaskListener;
+import com.sun.tools.javac.api.DuplicateClassChecker;
 import com.sun.tools.javac.api.JavacTaskImpl;
 import com.sun.tools.javac.code.Kinds;
 import com.sun.tools.javac.code.Scope;
@@ -76,6 +77,7 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import java.util.regex.Pattern;
+import javax.lang.model.element.Name;
 import javax.swing.text.ChangedCharSetException;
 import javax.swing.text.MutableAttributeSet;
 import javax.swing.text.html.HTML;
@@ -91,16 +93,23 @@
 import org.netbeans.api.java.source.ClasspathInfo;
 import org.netbeans.api.java.source.ElementUtilities;
 import org.netbeans.api.java.source.SourceUtils;
+import org.netbeans.modules.java.source.JavaSourceAccessor;
+import org.netbeans.modules.java.source.JavadocHelper;
+import org.netbeans.modules.java.source.indexing.FQN2Files;
 import org.netbeans.modules.java.source.indexing.JavaBinaryIndexer;
 import org.netbeans.modules.java.source.indexing.JavaIndex;
 import org.netbeans.modules.java.source.parsing.FileManagerTransaction;
 import org.netbeans.modules.java.source.parsing.FileObjects;
+import org.netbeans.modules.java.source.parsing.JavacParser;
+import org.netbeans.modules.java.source.parsing.JavacParser.DuplicateClassRegistry;
+import org.netbeans.modules.java.source.parsing.JavacParser.TreeLoaderRegistry;
 import org.netbeans.modules.java.source.parsing.OutputFileManager.InvalidSourcePath;
 import org.netbeans.modules.java.source.usages.ClasspathInfoAccessor;
 import org.netbeans.modules.parsing.impl.indexing.IndexingUtils;
 import org.openide.filesystems.FileObject;
 import org.openide.filesystems.URLMapper;
 import org.openide.util.Exceptions;
+import org.openide.util.lookup.ServiceProvider;
 
 /**
  *
@@ -775,5 +784,31 @@ private boolean canWrite(final ClasspathInfo cpInfo) {
         assert fmTx != null;
         return fmTx.canWrite();
     }
+
+    @ServiceProvider(service=TreeLoaderRegistry.class)
+    public static final class TreeLoaderRegistryImpl implements TreeLoaderRegistry {
+
+        @Override
+        public void enhance(Context context, ClasspathInfo cpInfo, boolean detached) {
+            TreeLoader.preRegister(context, cpInfo, detached);
+        }
+        
+    }
     
+    @ServiceProvider(service=DuplicateClassRegistry.class)
+    public static final class DuplicateClassRegistryImpl implements DuplicateClassRegistry {
+
+        @Override
+        public void enhance(Context context, FQN2Files fqn2Files) {
+            if (fqn2Files == null)
+                return;
+            context.put(DuplicateClassChecker.class, new DuplicateClassChecker() {
+                @Override
+                public boolean check(Name name, JavaFileObject jfo) {
+                    return fqn2Files.check(name, jfo);
+                }
+            });
+        }
+        
+    }
 }
diff --git a/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/CouplingTest.java b/java.source.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/CouplingTest.java
similarity index 97%
rename from lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/CouplingTest.java
rename to java.source.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/CouplingTest.java
index 1bd4415da..e5b1bbf00 100644
--- a/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/CouplingTest.java
+++ b/java.source.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/CouplingTest.java
@@ -20,7 +20,7 @@
 
 import com.sun.source.tree.ClassTree;
 import com.sun.source.tree.CompilationUnitTree;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import com.sun.tools.javac.api.JavacTaskImpl;
 import com.sun.tools.javac.code.Flags;
@@ -45,7 +45,7 @@
 import javax.tools.ToolProvider;
 import junit.framework.TestCase;
 
-/**
+/**TODO: finished?
  *
  * @author lahvac
  */
@@ -108,7 +108,7 @@ protected void tearDown() throws Exception {
 
         final List<String> result = new ArrayList<String>();
 
-        new TreePathScanner<Void, Void>() {
+        new ErrorAwareTreePathScanner<Void, Void>() {
             @Override public Void visitClass(ClassTree node, Void p) {
                 Element el = Trees.instance(ct).getElement(getCurrentPath());
 
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/usages/ClassNamesForFileOraculumImplTest.java b/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/ClassNamesForFileOraculumImplTest.java
similarity index 97%
rename from java.source.base/test/unit/src/org/netbeans/modules/java/source/usages/ClassNamesForFileOraculumImplTest.java
rename to java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/ClassNamesForFileOraculumImplTest.java
index a68082855..e7dace96d 100644
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/usages/ClassNamesForFileOraculumImplTest.java
+++ b/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/ClassNamesForFileOraculumImplTest.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.netbeans.modules.java.source.usages;
+package org.netbeans.modules.java.source.nbjavac.indexing;
 
 import com.sun.tools.javac.api.ClassNamesForFileOraculum;
 import java.io.IOException;
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/MultiPassCompileWorkerTest.java b/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/MultiPassCompileWorkerTest.java
similarity index 85%
rename from java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/MultiPassCompileWorkerTest.java
rename to java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/MultiPassCompileWorkerTest.java
index 0a5e76e7f..b319e25ef 100644
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/MultiPassCompileWorkerTest.java
+++ b/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/MultiPassCompileWorkerTest.java
@@ -16,23 +16,25 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.netbeans.modules.java.source.indexing;
+package org.netbeans.modules.java.source.nbjavac.indexing;
 
 import java.util.Collection;
 import org.netbeans.modules.java.source.indexing.CompileWorker.ParsingOutput;
+import org.netbeans.modules.java.source.indexing.JavaCustomIndexer;
 import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.CompileTuple;
+import org.netbeans.modules.java.source.indexing.JavaParsingContext;
 import org.netbeans.modules.parsing.spi.indexing.Context;
 
 /**
  *
  * @author lahvac
  */
-public class MultiPassCompileWorkerTest extends CompileWorkerTestBase {
+public class MultiPassCompileWorkerTest extends NBJavacCompileWorkerTestBase {
     
     public MultiPassCompileWorkerTest(String name) {
         super(name);
     }
-
+    
     @Override
     protected ParsingOutput runCompileWorker(Context context, JavaParsingContext javaContext, Collection<? extends CompileTuple> files) throws Exception {
         JavaCustomIndexer.NO_ONE_PASS_COMPILE_WORKER = true;
diff --git a/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/NBJavacCompileWorkerTestBase.java b/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/NBJavacCompileWorkerTestBase.java
new file mode 100644
index 000000000..09e57ae57
--- /dev/null
+++ b/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/NBJavacCompileWorkerTestBase.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.java.source.nbjavac.indexing;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+import org.netbeans.modules.java.source.indexing.CompileWorker.ParsingOutput;
+import org.netbeans.modules.java.source.indexing.CompileWorkerTestBase;
+
+/**
+ *
+ * @author lahvac
+ */
+public abstract class NBJavacCompileWorkerTestBase extends CompileWorkerTestBase {
+    
+    public NBJavacCompileWorkerTestBase(String name) {
+        super(name);
+    }
+    
+    public void test219787() throws Exception {
+        ParsingOutput result = runIndexing(Arrays.asList(compileTuple("test/Test3.java", "package test; public class Test3")),
+                                           Arrays.asList(virtualCompileTuple("test/Test1.virtual", "package test; public class Test1 {}"),
+                                                         virtualCompileTuple("test/Test2.virtual", "package test; public class Test2 {}")));
+        
+        assertFalse(result.lowMemory);
+        assertTrue(result.success);
+        
+        Set<String> createdFiles = new HashSet<String>();
+        
+        for (File created : result.createdFiles) {
+            createdFiles.add(getWorkDir().toURI().relativize(created.toURI()).getPath());
+        }
+        
+        assertEquals(new HashSet<String>(Arrays.asList("cache/s1/java/15/classes/test/Test3.sig")), createdFiles);
+    }
+    
+}
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/OnePassCompileWorkerTest.java b/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/OnePassCompileWorkerTest.java
similarity index 87%
rename from java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/OnePassCompileWorkerTest.java
rename to java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/OnePassCompileWorkerTest.java
index 1d109bdad..49b79ca5a 100644
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/OnePassCompileWorkerTest.java
+++ b/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/OnePassCompileWorkerTest.java
@@ -16,18 +16,19 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.netbeans.modules.java.source.indexing;
+package org.netbeans.modules.java.source.nbjavac.indexing;
 
 import java.util.Collection;
 import org.netbeans.modules.java.source.indexing.CompileWorker.ParsingOutput;
 import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.CompileTuple;
+import org.netbeans.modules.java.source.indexing.JavaParsingContext;
 import org.netbeans.modules.parsing.spi.indexing.Context;
 
 /**
  *
  * @author lahvac
  */
-public class OnePassCompileWorkerTest extends CompileWorkerTestBase {
+public class OnePassCompileWorkerTest extends NBJavacCompileWorkerTestBase {
     
     public OnePassCompileWorkerTest(String name) {
         super(name);
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/SuperOnePassCompileWorkerTest.java b/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/SuperOnePassCompileWorkerTest.java
similarity index 87%
rename from java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/SuperOnePassCompileWorkerTest.java
rename to java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/SuperOnePassCompileWorkerTest.java
index dd4f31339..c2f669e72 100644
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/SuperOnePassCompileWorkerTest.java
+++ b/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/SuperOnePassCompileWorkerTest.java
@@ -16,18 +16,19 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.netbeans.modules.java.source.indexing;
+package org.netbeans.modules.java.source.nbjavac.indexing;
 
 import java.util.Collection;
 import org.netbeans.modules.java.source.indexing.CompileWorker.ParsingOutput;
 import org.netbeans.modules.java.source.indexing.JavaCustomIndexer.CompileTuple;
+import org.netbeans.modules.java.source.indexing.JavaParsingContext;
 import org.netbeans.modules.parsing.spi.indexing.Context;
 
 /**
  *
  * @author lahvac
  */
-public class SuperOnePassCompileWorkerTest extends CompileWorkerTestBase {
+public class SuperOnePassCompileWorkerTest extends NBJavacCompileWorkerTestBase {
     
     public SuperOnePassCompileWorkerTest(String name) {
         super(name);
diff --git a/java.source.base/test/unit/src/org/netbeans/modules/java/source/TreeLoaderTest.java b/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/TreeLoaderTest.java
similarity index 98%
rename from java.source.base/test/unit/src/org/netbeans/modules/java/source/TreeLoaderTest.java
rename to java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/TreeLoaderTest.java
index 80869398f..32fed2636 100644
--- a/java.source.base/test/unit/src/org/netbeans/modules/java/source/TreeLoaderTest.java
+++ b/java.source.nbjavac/test/unit/src/org/netbeans/modules/java/source/nbjavac/indexing/TreeLoaderTest.java
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-package org.netbeans.modules.java.source;
+package org.netbeans.modules.java.source.nbjavac.indexing;
 
 import java.io.File;
 import java.io.IOException;
diff --git a/java.source.queriesimpl/src/org/netbeans/modules/java/source/queriesimpl/JavaOperationsImpl.java b/java.source.queriesimpl/src/org/netbeans/modules/java/source/queriesimpl/JavaOperationsImpl.java
index 86f106eaa..7fd88acf3 100644
--- a/java.source.queriesimpl/src/org/netbeans/modules/java/source/queriesimpl/JavaOperationsImpl.java
+++ b/java.source.queriesimpl/src/org/netbeans/modules/java/source/queriesimpl/JavaOperationsImpl.java
@@ -20,7 +20,7 @@
 
 import com.sun.source.tree.*;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -340,7 +340,7 @@ public void renameField(
                 oldVarTree.getInitializer());
         wcopy.rewrite(oldVarTree, newVarTree);
         final VariableElement fieldF = field;
-        final TreePathScanner<Void,Void> scanner = new TreePathScanner<Void, Void>(){
+        final ErrorAwareTreePathScanner<Void,Void> scanner = new ErrorAwareTreePathScanner<Void, Void>(){
             @Override
             public Void visitIdentifier(IdentifierTree node, Void p) {
                 super.visitIdentifier(node, p);
@@ -397,7 +397,7 @@ public int compare(int[] o1, int[] o2) {
         final Trees trees = wcopy.getTrees();
         final GeneratorUtilities utils = GeneratorUtilities.get(wcopy);
         final List<Tree> toImport = new ArrayList<Tree>();
-        final TreePathScanner<Void,Void> scanner = new TreePathScanner<Void, Void>(){
+        final ErrorAwareTreePathScanner<Void,Void> scanner = new ErrorAwareTreePathScanner<Void, Void>(){
             @Override
             public Void scan(Tree node, Void p) {
                 final int start = (int) trees.getSourcePositions().getStartPosition(cu, node);
@@ -518,7 +518,7 @@ private TreePath findClassInCompilationUnit(
             throw new QueryException(ioe);
         }
         final Trees trees = control.getTrees();
-        final TreePathScanner<TreePath,Void> visitor = new TreePathScanner<TreePath, Void>() {
+        final ErrorAwareTreePathScanner<TreePath,Void> visitor = new ErrorAwareTreePathScanner<TreePath, Void>() {
             @Override
             public TreePath visitClass(ClassTree node, Void p) {
                 final Element el = trees.getElement(getCurrentPath());
diff --git a/java.source/nbproject/project.xml b/java.source/nbproject/project.xml
index 9474f22ed..8b375b2e2 100644
--- a/java.source/nbproject/project.xml
+++ b/java.source/nbproject/project.xml
@@ -120,6 +120,14 @@
                         <specification-version>3.0</specification-version>
                     </run-dependency>
                 </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.modules.autoupdate.ui</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <specification-version>1.46</specification-version>
+                    </run-dependency>
+                </dependency>
                 <dependency>
                     <code-name-base>org.netbeans.modules.classfile</code-name-base>
                     <build-prerequisite/>
diff --git a/java.source/src/org/netbeans/api/java/source/UiUtils.java b/java.source/src/org/netbeans/api/java/source/UiUtils.java
index 2b4c32893..3b9d24ffd 100644
--- a/java.source/src/org/netbeans/api/java/source/UiUtils.java
+++ b/java.source/src/org/netbeans/api/java/source/UiUtils.java
@@ -24,7 +24,7 @@
 import com.sun.source.tree.Tree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.tools.javac.util.Context;
 import java.io.IOException;
 import java.util.Collection;
@@ -435,7 +435,7 @@ public void run(CompilationController info) {
     
     // Private innerclasses ----------------------------------------------------
     
-    private static class FindDeclarationVisitor extends TreePathScanner<Void, Void> {
+    private static class FindDeclarationVisitor extends ErrorAwareTreePathScanner<Void, Void> {
         
         private Element element;
         private Tree declTree;
diff --git a/java.source/src/org/netbeans/modules/java/JavaNode.java b/java.source/src/org/netbeans/modules/java/JavaNode.java
index 48403d2c1..4cb93f92a 100644
--- a/java.source/src/org/netbeans/modules/java/JavaNode.java
+++ b/java.source/src/org/netbeans/modules/java/JavaNode.java
@@ -21,7 +21,7 @@
 
 import com.sun.source.tree.ClassTree;
 import com.sun.source.tree.CompilationUnitTree;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.awt.Image;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
@@ -475,7 +475,7 @@ public void run(CompilationController cc) throws Exception {
                 return res[0];
             }
 
-            private static final class ClasssFinder extends TreeScanner<Collection<ClassTree>, Collection<ClassTree>> {
+            private static final class ClasssFinder extends ErrorAwareTreeScanner<Collection<ClassTree>, Collection<ClassTree>> {
 
                 @Override
                 public Collection<ClassTree> visitCompilationUnit(CompilationUnitTree node, Collection<ClassTree> p) {
diff --git a/java.source/src/org/netbeans/modules/java/classfile/CodeGenerator.java b/java.source/src/org/netbeans/modules/java/classfile/CodeGenerator.java
index 69a9f78fc..77dde2b2e 100644
--- a/java.source/src/org/netbeans/modules/java/classfile/CodeGenerator.java
+++ b/java.source/src/org/netbeans/modules/java/classfile/CodeGenerator.java
@@ -45,6 +45,7 @@
 import com.sun.tools.javap.ConstantWriter;
 import com.sun.tools.javap.Context;
 import com.sun.tools.javap.Messages;
+
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
@@ -67,6 +68,7 @@
 import java.util.Set;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+
 import javax.lang.model.element.AnnotationMirror;
 import javax.lang.model.element.AnnotationValue;
 import javax.lang.model.element.AnnotationValueVisitor;
@@ -85,6 +87,8 @@
 import javax.lang.model.util.AbstractElementVisitor9;
 import javax.tools.JavaFileObject;
 import javax.tools.JavaFileObject.Kind;
+
+import com.sun.tools.classfile.ConstantPool.CPInfo;
 import org.netbeans.api.java.classpath.ClassPath;
 import org.netbeans.api.java.source.ClasspathInfo;
 import org.netbeans.api.java.source.ClasspathInfo.PathKind;
@@ -739,19 +743,7 @@ public ConvenientCodeWriter(Context context) {
         
         @Override
         public void writeInstr(Instruction instr) {
-            if (INSTRUCTION_WITH_REFERENCE.contains(instr.getOpcode())) {
-                print(String.format("%4d: %-13s ", instr.getPC(), instr.getMnemonic()));
-                int constantPoolEntry;
-                if (instr.getOpcode() == Opcode.LDC) {
-                    constantPoolEntry = instr.getUnsignedByte(1);
-                } else {
-                    constantPoolEntry = instr.getUnsignedShort(1);
-                }
-                print(constantWriter.stringValue(constantPoolEntry));
-                println();
-            } else {
-                super.writeInstr(instr);
-            }
+            super.writeInstr(instr);
         }
     }
     
diff --git a/java.source/src/org/netbeans/modules/java/source/JBrowseModule.java b/java.source/src/org/netbeans/modules/java/source/JBrowseModule.java
index 2ea38baf1..ebc853a36 100644
--- a/java.source/src/org/netbeans/modules/java/source/JBrowseModule.java
+++ b/java.source/src/org/netbeans/modules/java/source/JBrowseModule.java
@@ -19,8 +19,23 @@
 
 package org.netbeans.modules.java.source;
 
+import java.awt.Dialog;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.prefs.Preferences;
+import org.netbeans.modules.autoupdate.ui.api.PluginManager;
 import org.netbeans.modules.java.source.usages.ClassIndexManager;
+import org.openide.DialogDescriptor;
+import org.openide.DialogDisplayer;
+import org.openide.awt.NotificationDisplayer;
+import org.openide.awt.NotificationDisplayer.Priority;
+import org.openide.awt.StatusDisplayer;
 import org.openide.modules.ModuleInstall;
+import org.openide.util.HelpCtx;
+import org.openide.util.ImageUtilities;
+import org.openide.util.NbBundle;
+import org.openide.util.NbPreferences;
+import org.openide.windows.WindowManager;
 
 /**
  *
@@ -34,8 +49,51 @@
     /** Creates a new instance of JBrowseModule */
     public JBrowseModule() {
     }
-    
-    
+
+    public static final String KEY_WARNING_SHOWN = "nb-javac.warning.shown";
+
+    @Override
+    @NbBundle.Messages({
+        "TITLE_FeaturesLimited=Java features limited",
+        "DESC_FeaturesLimited=<html>No supported javac library available." +
+                             " Most Java editing features are disabled." +
+                             " Please either:" +
+                             "<ul>" +
+                                 "<li>install nb-javac library (<b>highly recommended</b>)</li>" +
+                                 "<li>run NetBeans on JDK 9 or later</li>" +
+                             "</ul>",
+        "BN_Install=Install nb-javac",
+        "DN_nbjavac=nb-javac library"
+    })
+    public void restored() {
+        WindowManager.getDefault().invokeWhenUIReady(() -> {
+            WindowManager.getDefault().invokeWhenUIReady(() -> {
+                Preferences prefs = NbPreferences.forModule(NoJavacHelper.class);
+                if (!NoJavacHelper.hasWorkingJavac() && !prefs.getBoolean(KEY_WARNING_SHOWN, false)) {
+                    String install = Bundle.BN_Install();
+                    Dialog[] d = new Dialog[1];
+                    DialogDescriptor dd = new DialogDescriptor(Bundle.DESC_FeaturesLimited(), Bundle.TITLE_FeaturesLimited(), true, new Object[] {install, DialogDescriptor.CANCEL_OPTION}, install, DialogDescriptor.DEFAULT_ALIGN, HelpCtx.DEFAULT_HELP, evt -> {
+                        if (install.equals(evt.getActionCommand())) {
+                            PluginManager.installSingle("org.netbeans.modules.nbjavac", Bundle.DN_nbjavac());
+                        }
+                        d[0].setVisible(false);
+                    });
+                    d[0] = DialogDisplayer.getDefault().createDialog(dd);
+                    d[0].setVisible(true);
+                    prefs.putBoolean(KEY_WARNING_SHOWN, true);
+                }
+
+                if (!NoJavacHelper.hasNbJavac()) {
+                    NotificationDisplayer.getDefault().notify("Install nb-javac Library", ImageUtilities.loadImageIcon("/org/netbeans/modules/java/source/resources/icons/warning.png", false), "It is recommended to install nb-javac Library to improve Java editing experience.", evt -> {
+                        PluginManager.installSingle("org.netbeans.modules.nbjavac", Bundle.DN_nbjavac());
+                    }, prefs.getBoolean(KEY_WARNING_SHOWN, false) ? Priority.SILENT : Priority.HIGH);
+                    prefs.putBoolean(KEY_WARNING_SHOWN, true);
+                }
+            });
+        });
+        super.restored();
+    }
+
     @Override
     public void close () {
         super.close();
diff --git a/java.source/src/org/netbeans/modules/java/source/parsing/SourceFileObject.java b/java.source/src/org/netbeans/modules/java/source/parsing/SourceFileObject.java
index b6709ba7f..bb51903c1 100644
--- a/java.source/src/org/netbeans/modules/java/source/parsing/SourceFileObject.java
+++ b/java.source/src/org/netbeans/modules/java/source/parsing/SourceFileObject.java
@@ -76,7 +76,7 @@ public SourceFileObject (
         @NullAllowed final JavaFileFilterImplementation filter,
         @NullAllowed final CharSequence content,
         final boolean renderNow) throws IOException {
-        super(handle, filter);
+        super(handle, filter, content != null);
         this.hasFilter = filter != null;
         if (content != null || renderNow) {
             update(content);
diff --git a/java.source/test/unit/src/org/netbeans/api/java/source/gen/LambdaTest.java b/java.source/test/unit/src/org/netbeans/api/java/source/gen/LambdaTest.java
index ac9af2dde..5d4c3e2e2 100644
--- a/java.source/test/unit/src/org/netbeans/api/java/source/gen/LambdaTest.java
+++ b/java.source/test/unit/src/org/netbeans/api/java/source/gen/LambdaTest.java
@@ -34,8 +34,8 @@
 import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.File;
 import java.io.IOException;
 import java.util.Collections;
@@ -93,7 +93,7 @@ public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 CompilationUnitTree cut = workingCopy.getCompilationUnit();
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLiteral(LiteralTree node, Void p) {
                         workingCopy.rewrite(node, make.MemberReference(ReferenceMode.INVOKE, make.Identifier("Test"), "taragui", Collections.<ExpressionTree>emptyList()));
                         return super.visitLiteral(node, p);
@@ -133,7 +133,7 @@ public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 CompilationUnitTree cut = workingCopy.getCompilationUnit();
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitVariable(VariableTree node, Void p) {
                         if (node.getName().contentEquals("e")) {
                             workingCopy.rewrite(node, make.setLabel(node, "f"));
@@ -174,7 +174,7 @@ public void testAddFirstLambdaParam() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.addLambdaParameter(node, make.Variable(make.Modifiers(EnumSet.noneOf(Modifier.class)), "e", null, null)));
                         return super.visitLambdaExpression(node, p);
@@ -213,7 +213,7 @@ public void testAddSecondLambdaParam() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.addLambdaParameter(node, make.Variable(make.Modifiers(EnumSet.noneOf(Modifier.class)), "f", null, null)));
                         return super.visitLambdaExpression(node, p);
@@ -252,7 +252,7 @@ public void testAddSecondLambdaParamNoParenthesis() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.addLambdaParameter(node, make.Variable(make.Modifiers(EnumSet.noneOf(Modifier.class)), "f", null, null)));
                         return super.visitLambdaExpression(node, p);
@@ -291,7 +291,7 @@ public void testPrependSecondLambdaParam() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.insertLambdaParameter(node, 0, make.Variable(make.Modifiers(EnumSet.noneOf(Modifier.class)), "f", null, null)));
                         return super.visitLambdaExpression(node, p);
@@ -330,7 +330,7 @@ public void testRemoveFirstLambdaParam() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.removeLambdaParameter(node, 0));
                         return super.visitLambdaExpression(node, p);
@@ -369,7 +369,7 @@ public void testRemoveSecondLambdaParam() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.removeLambdaParameter(node, 1));
                         return super.visitLambdaExpression(node, p);
@@ -408,7 +408,7 @@ public void testOnlyLambdaParam() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.removeLambdaParameter(node, 0));
                         return super.visitLambdaExpression(node, p);
@@ -447,7 +447,7 @@ public void testLambdaFullBody2Expression() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         ReturnTree t = (ReturnTree) ((BlockTree) node.getBody()).getStatements().get(0);
                         workingCopy.rewrite(node, make.setLambdaBody(node, t.getExpression()));
@@ -489,7 +489,7 @@ public void testLambdaExpression2FullBody() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.setLambdaBody(node, make.Block(Collections.singletonList(make.Return((ExpressionTree) node.getBody())), false)));
                         return super.visitLambdaExpression(node, p);
@@ -532,7 +532,7 @@ public void testLambdaExpression2FullBodyTreeMatch() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         workingCopy.rewrite(node, make.setLambdaBody(node, make.Block(Collections.singletonList(make.Return((ExpressionTree) node.getBody())), false)));
                         return super.visitLambdaExpression(node, p);
@@ -571,7 +571,7 @@ public void testMethodReferenceDiff() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitMemberReference(MemberReferenceTree node, Void p) {
                         workingCopy.rewrite(node, make.MemberReference(node.getMode(), make.Identifier("Test"), node.getName(), node.getTypeArguments()));
                         return super.visitMemberReference(node, p);
@@ -610,7 +610,7 @@ public void testMethodReferenceNameDiff() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitMemberReference(MemberReferenceTree node, Void p) {
                         workingCopy.rewrite(node, make.setLabel(node, "taragui2"));
                         return super.visitMemberReference(node, p);
@@ -649,7 +649,7 @@ public void testMethodReferenceFirstTypeParam() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitMemberReference(MemberReferenceTree node, Void p) {
                         workingCopy.rewrite(node, make.MemberReference(node.getMode(), node.getQualifierExpression(), node.getName(), Collections.singletonList(make.Identifier("String"))));
                         return super.visitMemberReference(node, p);
@@ -688,7 +688,7 @@ public void testMethodReferenceLastTypeParam() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitMemberReference(MemberReferenceTree node, Void p) {
                         workingCopy.rewrite(node, make.MemberReference(node.getMode(), node.getQualifierExpression(), node.getName(), null));
                         return super.visitMemberReference(node, p);
@@ -729,7 +729,7 @@ public void testLambdaExpressionImplicit2ExplicitParamTypes() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         for (VariableTree par : node.getParameters()) {
                             workingCopy.rewrite(par.getType(), make.Identifier("String"));
@@ -772,7 +772,7 @@ public void testLambdaExpressionExplicit2ImplicitParamTypes() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         for (VariableTree par : node.getParameters()) {
                             workingCopy.rewrite(par, make.Variable(par.getModifiers(), par.getName(), null, par.getInitializer()));
@@ -895,7 +895,7 @@ public void testAddSecondLambdaParamWithType() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override public Void visitLambdaExpression(LambdaExpressionTree node, Void p) {
                         VariableTree vt = node.getParameters().get(0);
                         workingCopy.rewrite(node, make.addLambdaParameter(node, make.Variable(vt.getModifiers(), "f", vt.getType(), vt.getInitializer())));
@@ -935,7 +935,7 @@ public void testChangeLambdaToImplicit() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void scan(Tree node, Void p) {
                         return super.scan(node, p);
@@ -986,7 +986,7 @@ public void testChangeLambdaToExplicit() throws Exception {
             public void run(final WorkingCopy workingCopy) throws IOException {
                 workingCopy.toPhase(Phase.RESOLVED);
                 final TreeMaker make = workingCopy.getTreeMaker();
-                new TreeScanner<Void, Void>() {
+                new ErrorAwareTreeScanner<Void, Void>() {
 
                     @Override
                     public Void scan(Tree node, Void p) {
diff --git a/java.sourceui/src/org/netbeans/api/java/source/ui/ElementOpen.java b/java.sourceui/src/org/netbeans/api/java/source/ui/ElementOpen.java
index c6e0d3bc1..5f85fe748 100644
--- a/java.sourceui/src/org/netbeans/api/java/source/ui/ElementOpen.java
+++ b/java.sourceui/src/org/netbeans/api/java/source/ui/ElementOpen.java
@@ -21,7 +21,7 @@
 import com.sun.source.tree.*;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.logging.Level;
@@ -400,7 +400,7 @@ public void run() {
     
     // Private innerclasses ----------------------------------------------------
     
-    private static class FindDeclarationVisitor extends TreePathScanner<Void, Void> {
+    private static class FindDeclarationVisitor extends ErrorAwareTreePathScanner<Void, Void> {
         
         private Element element;
         private Tree declTree;
diff --git a/java.sourceui/src/org/netbeans/modules/java/source/ui/AsyncJavaSymbolDescriptor.java b/java.sourceui/src/org/netbeans/modules/java/source/ui/AsyncJavaSymbolDescriptor.java
index 9e7822b54..d3ca49de5 100644
--- a/java.sourceui/src/org/netbeans/modules/java/source/ui/AsyncJavaSymbolDescriptor.java
+++ b/java.sourceui/src/org/netbeans/modules/java/source/ui/AsyncJavaSymbolDescriptor.java
@@ -25,6 +25,7 @@
 import com.sun.tools.javac.code.Symtab;
 import com.sun.tools.javac.jvm.ClassReader;
 import com.sun.tools.javac.model.JavacElements;
+
 import java.io.File;
 import java.io.IOException;
 import java.lang.ref.Reference;
@@ -42,6 +43,7 @@
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.logging.Logger;
+
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ElementKind;
 import javax.lang.model.element.Modifier;
@@ -58,6 +60,7 @@
 import org.netbeans.api.java.source.ElementHandle;
 import org.netbeans.api.project.ProjectInformation;
 import org.netbeans.modules.java.source.ElementHandleAccessor;
+import org.netbeans.modules.java.source.ElementUtils;
 import org.netbeans.modules.java.source.indexing.JavaIndex;
 import org.netbeans.modules.java.source.parsing.CachingArchiveProvider;
 import org.netbeans.modules.java.source.parsing.CachingFileManager;
@@ -211,8 +214,7 @@ private void fireDescriptorChange(Collection<? extends SymbolDescriptor> replace
             final Symtab syms = Symtab.instance(jt.getContext());
             final Set<?> pkgs = new HashSet<>(getPackages(syms).keySet());
             final Set<?> clzs = new HashSet<>(getClasses(syms).keySet());
-            final JavacElements elements = (JavacElements)jt.getElements();
-            final TypeElement te = (TypeElement) elements.getTypeElementByBinaryName(
+            final TypeElement te = (TypeElement) ElementUtils.getTypeElementByBinaryName(jt,
                     ElementHandleAccessor.getInstance().getJVMSignature(getOwner())[0]);
             if (te != null) {
                 if (ident.equals(getSimpleName(te, null, caseSensitive))) {
diff --git a/java.sourceui/test/unit/src/org/netbeans/api/java/source/ui/ElementHeadersTest.java b/java.sourceui/test/unit/src/org/netbeans/api/java/source/ui/ElementHeadersTest.java
index 6efff9464..af41e11da 100644
--- a/java.sourceui/test/unit/src/org/netbeans/api/java/source/ui/ElementHeadersTest.java
+++ b/java.sourceui/test/unit/src/org/netbeans/api/java/source/ui/ElementHeadersTest.java
@@ -29,11 +29,11 @@
 import org.netbeans.api.java.source.JavaSource;
 import org.netbeans.api.java.source.JavaSource.Phase;
 import org.netbeans.api.java.source.SourceUtilsTestUtil;
+import org.netbeans.api.java.source.SourceUtilsTestUtil2;
 import org.netbeans.api.java.source.TestUtilities;
 import org.netbeans.api.lexer.Language;
 import org.netbeans.junit.NbTestCase;
 import org.netbeans.modules.java.JavaDataLoader;
-import org.netbeans.modules.java.source.TreeLoader;
 import org.openide.cookies.EditorCookie;
 import org.openide.filesystems.FileObject;
 import org.openide.filesystems.FileUtil;
@@ -121,7 +121,7 @@ public void testConstructor133774() throws Exception {
     }
     
     public void test134664() throws Exception {
-        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
+        SourceUtilsTestUtil2.disableConfinementTest();
         performTest("test/Test.java", "package test; public class Test { public Tfst {} }", 43, ElementHeaders.NAME, "Tfst");
     }
 }
diff --git a/java.testrunner.ui/nbproject/project.properties b/java.testrunner.ui/nbproject/project.properties
index 7f641b767..375b0888d 100644
--- a/java.testrunner.ui/nbproject/project.properties
+++ b/java.testrunner.ui/nbproject/project.properties
@@ -17,3 +17,4 @@
 is.eager=true
 javac.source=1.6
 javac.compilerargs=-Xlint -Xlint:-serial
+requires.nb.javac=true
diff --git a/java.testrunner/nbproject/project.properties b/java.testrunner/nbproject/project.properties
index 7f641b767..375b0888d 100644
--- a/java.testrunner/nbproject/project.properties
+++ b/java.testrunner/nbproject/project.properties
@@ -17,3 +17,4 @@
 is.eager=true
 javac.source=1.6
 javac.compilerargs=-Xlint -Xlint:-serial
+requires.nb.javac=true
diff --git a/javaee.injection/nbproject/project.properties b/javaee.injection/nbproject/project.properties
index ab06b416c..bd782ba4c 100644
--- a/javaee.injection/nbproject/project.properties
+++ b/javaee.injection/nbproject/project.properties
@@ -16,3 +16,4 @@
 # under the License.
 javac.source=1.7
 javac.compilerargs=-Xlint -Xlint:-serial
+requires.nb.javac=true
diff --git a/javafx2.editor/test/unit/src/org/netbeans/modules/javafx2/editor/FXMLCompletionTestBase.java b/javafx2.editor/test/unit/src/org/netbeans/modules/javafx2/editor/FXMLCompletionTestBase.java
index 36a847e20..60a616067 100644
--- a/javafx2.editor/test/unit/src/org/netbeans/modules/javafx2/editor/FXMLCompletionTestBase.java
+++ b/javafx2.editor/test/unit/src/org/netbeans/modules/javafx2/editor/FXMLCompletionTestBase.java
@@ -35,6 +35,7 @@
 import org.netbeans.api.java.source.ClasspathInfo;
 import org.netbeans.api.java.source.CompilationController;
 import org.netbeans.api.java.source.JavaSource;
+import org.netbeans.api.java.source.SourceUtilsTestUtil2;
 import org.netbeans.api.java.source.Task;
 import org.netbeans.api.java.source.gen.WhitespaceIgnoringDiff;
 import org.netbeans.api.lexer.Language;
@@ -45,7 +46,6 @@
 import org.netbeans.modules.editor.completion.CompletionItemComparator;
 import org.netbeans.modules.editor.java.Utilities;
 import org.netbeans.modules.java.JavaDataLoader;
-import org.netbeans.modules.java.source.TreeLoader;
 import org.netbeans.modules.java.source.indexing.TransactionContext;
 import org.netbeans.modules.java.source.parsing.JavacParserFactory;
 import org.netbeans.modules.java.source.usages.BinaryAnalyser;
@@ -85,7 +85,7 @@
         System.setProperty("org.openide.util.Lookup", Lkp.class.getName());
         Assert.assertEquals(Lkp.class, Lookup.getDefault().getClass());
 
-        TreeLoader.DISABLE_ARTIFICAL_PARAMETER_NAMES = true;
+        SourceUtilsTestUtil2.disableArtificalParameterNames();
     }
 
     static final int FINISH_OUTTIME = 5 * 60 * 1000;
diff --git a/javafx2.project/nbproject/project.properties b/javafx2.project/nbproject/project.properties
index 4b04a2047..b6bb147a6 100644
--- a/javafx2.project/nbproject/project.properties
+++ b/javafx2.project/nbproject/project.properties
@@ -18,3 +18,4 @@ javac.source=1.8
 javac.compilerargs=-Xlint -Xlint:-serial
 
 test.config.stable.includes=**/NewJavaFX2ProjectTest.class
+requires.nb.javac=true
diff --git a/javawebstart/nbproject/project.properties b/javawebstart/nbproject/project.properties
index 24b5a55b9..5c67e0d26 100644
--- a/javawebstart/nbproject/project.properties
+++ b/javawebstart/nbproject/project.properties
@@ -19,3 +19,4 @@ javac.compilerargs=-Xlint:unchecked
 javac.source=1.7
 extra.module.files=ant/extra/org-netbeans-modules-javawebstart-anttasks.jar
 jnlp.indirect.jars=ant/extra/org-netbeans-modules-javawebstart-anttasks.jar
+requires.nb.javac=true
diff --git a/jshell.support/nbproject/project.properties b/jshell.support/nbproject/project.properties
index 952f643e3..d97a998fa 100644
--- a/jshell.support/nbproject/project.properties
+++ b/jshell.support/nbproject/project.properties
@@ -19,5 +19,5 @@ javac.source=1.8
 javac.compilerargs=-Xlint -Xlint:-serial
 spec.version.base=1.0
 cp.extra=${tools.jar}
-bootclasspath.prepend=${nb_all}/libs.javacapi/external/nb-javac-api.jar${path.separator}${nb_all}/libs.javacimpl/external/nb-javac-impl.jar
 is.eager=true
+requires.nb.javac=true
diff --git a/jshell.support/nbproject/project.xml b/jshell.support/nbproject/project.xml
index e87a5b8e5..0905707d2 100644
--- a/jshell.support/nbproject/project.xml
+++ b/jshell.support/nbproject/project.xml
@@ -122,11 +122,9 @@
                 </dependency>
                 <dependency>
                     <code-name-base>org.netbeans.libs.javacimpl</code-name-base>
-                    <build-prerequisite/>
-                    <compile-dependency/>
                     <run-dependency>
                         <release-version>1</release-version>
-                        <specification-version>0.47</specification-version>
+                        <implementation-version/>
                     </run-dependency>
                 </dependency>
                 <dependency>
@@ -600,11 +598,6 @@
                         <code-name-base>org.netbeans.libs.jshell.compile</code-name-base>
                         <compile-dependency/>
                     </test-dependency>
-<!--
-                    <test-dependency>
-                        <code-name-base>org.netbeans.libs.jshell</code-name-base>
-                    </test-dependency>
--->
                 </test-type>
             </test-dependencies>
             <public-packages/>
diff --git a/junit.ant.ui/nbproject/project.properties b/junit.ant.ui/nbproject/project.properties
index 7f641b767..5d0fa29b1 100644
--- a/junit.ant.ui/nbproject/project.properties
+++ b/junit.ant.ui/nbproject/project.properties
@@ -17,3 +17,4 @@
 is.eager=true
 javac.source=1.6
 javac.compilerargs=-Xlint -Xlint:-serial
+requires.nb.javac=true
\ No newline at end of file
diff --git a/junit.ui/nbproject/project.properties b/junit.ui/nbproject/project.properties
index 7f641b767..375b0888d 100644
--- a/junit.ui/nbproject/project.properties
+++ b/junit.ui/nbproject/project.properties
@@ -17,3 +17,4 @@
 is.eager=true
 javac.source=1.6
 javac.compilerargs=-Xlint -Xlint:-serial
+requires.nb.javac=true
diff --git a/junit.ui/src/org/netbeans/modules/junit/ui/OpenTestAction.java b/junit.ui/src/org/netbeans/modules/junit/ui/OpenTestAction.java
index 8fa9b658d..48b5f4db0 100644
--- a/junit.ui/src/org/netbeans/modules/junit/ui/OpenTestAction.java
+++ b/junit.ui/src/org/netbeans/modules/junit/ui/OpenTestAction.java
@@ -24,7 +24,7 @@
 import com.sun.source.tree.MethodTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.util.SourcePositions;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.io.IOException;
 import java.net.URL;
@@ -354,7 +354,7 @@ public void cancel() {
     /**
      *
      */
-    private static class DeclarationTreeFinder extends TreePathScanner<Void, Void> {
+    private static class DeclarationTreeFinder extends ErrorAwareTreePathScanner<Void, Void> {
 
         private final Element element;
         private final Trees trees;
diff --git a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassFinder.java b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassFinder.java
new file mode 100644
index 000000000..c43f322f4
--- /dev/null
+++ b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassFinder.java
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.lib.nbjavac.services;
+
+import com.sun.tools.javac.code.ClassFinder;
+import com.sun.tools.javac.util.Context;
+import javax.tools.JavaFileObject;
+
+/**
+ *
+ * @author lahvac
+ */
+public class NBClassFinder extends ClassFinder {
+
+    public static void preRegister(Context context) {
+        context.put(classFinderKey, new Context.Factory<ClassFinder>() {
+            public ClassFinder make(Context c) {
+                return new NBClassFinder(c);
+            }
+        });
+    }
+
+    public NBClassFinder(Context context) {
+        super(context);
+    }
+
+    @Override
+    protected JavaFileObject preferredFileObject(JavaFileObject a, JavaFileObject b) {
+        if (b.getName().toLowerCase().endsWith(".sig")) {
+            //do not prefer sources over sig files (unless sources are newer):
+            boolean prevPreferSource = preferSource;
+            try {
+                preferSource = false;
+                return super.preferredFileObject(a, b);
+            } finally {
+                preferSource = prevPreferSource;
+            }
+        }
+        return super.preferredFileObject(a, b);
+    }
+
+}
diff --git a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassReader.java b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassReader.java
index 95c60275c..062412f3e 100644
--- a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassReader.java
+++ b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassReader.java
@@ -60,46 +60,6 @@ public void read(Symbol sym, int attrLen) {
                     bp = newbp;
                 }
             },
-            new NBAttributeReader(nbNames._org_netbeans_TypeSignature, Version.V49, CLASS_OR_MEMBER_ATTRIBUTE) {
-                protected void read(Symbol sym, int attrLen) {
-                    sym.type = readType(nextChar());
-                }
-            },
-            new NBAttributeReader(nbNames._org_netbeans_ParameterNames, Version.V49, CLASS_OR_MEMBER_ATTRIBUTE) {
-                protected void read(Symbol sym, int attrLen) {
-                    int newbp = bp + attrLen;
-                    List<Name> parameterNames = List.nil();
-                    int numParams = 0;
-                    if (sym.type != null) {
-                        List<Type> parameterTypes = sym.type.getParameterTypes();
-                        if (parameterTypes != null)
-                            numParams = parameterTypes.length();
-                    }
-                    for (int i = 0; i < numParams; i++) {
-                        if (bp < newbp - 1)
-                            parameterNames = parameterNames.prepend(readName(nextChar()));
-                    }
-                    parameterNames = parameterNames.reverse();
-                    while(parameterNames.length() < numParams)
-                        parameterNames = parameterNames.prepend(names.empty);
-                    ((MethodSymbol)sym).savedParameterNames = parameterNames;
-                }
-            },
-            new NBAttributeReader(nbNames._org_netbeans_SourceLevelAnnotations, Version.V49, CLASS_OR_MEMBER_ATTRIBUTE) {
-                protected void read(Symbol sym, int attrLen) {
-                    attachAnnotations(sym);
-                }
-            },
-            new NBAttributeReader(nbNames._org_netbeans_SourceLevelParameterAnnotations, Version.V49, CLASS_OR_MEMBER_ATTRIBUTE) {
-                protected void read(Symbol sym, int attrLen) {
-                    attachParameterAnnotations(sym);
-                }
-            },
-            new NBAttributeReader(nbNames._org_netbeans_SourceLevelTypeAnnotations, Version.V52, CLASS_OR_MEMBER_ATTRIBUTE) {
-                protected void read(Symbol sym, int attrLen) {
-                    attachTypeAnnotations(sym);
-                }
-            },
         };
 
         for (NBAttributeReader r: readers)
diff --git a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassWriter.java b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassWriter.java
index 84773bee7..984cabccb 100644
--- a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassWriter.java
+++ b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassWriter.java
@@ -58,128 +58,4 @@ protected NBClassWriter(Context context) {
         types = Types.instance(context);
     }
     
-    @Override
-    protected int writeExtraClassAttributes(ClassSymbol c) {
-        if (c.sourcefile != null) {
-            final Collection<? extends ClassSymbol> nip = nbMessager.removeNotInProfile(c.sourcefile.toUri());
-            if (nip != null) {
-                for (ClassSymbol s : nip) {
-                    pool.put(s.type);
-                }
-            }
-        }
-        return 0;
-    }
-
-    @Override
-    protected int writeExtraMemberAttributes(Symbol sym) {
-        int attrCount = 0;
-        if (sym.externalType(types).isErroneous()) {
-            int rsIdx = writeAttr(nbNames._org_netbeans_TypeSignature);
-            try {
-                preserveErrors = true;
-                databuf.appendChar(pool.put(typeSig(sym.type)));
-            } finally {
-                preserveErrors = false;
-            }
-            endAttr(rsIdx);
-            attrCount++;
-        }
-        return attrCount;
-    }
-
-    @Override
-    protected int writeExtraParameterAttributes(MethodSymbol m) {
-        boolean hasSourceLevel = false;
-        if (m.params != null) for (VarSymbol s : m.params) {
-            for (Attribute.Compound a : s.getRawAttributes()) {
-                if (types.getRetention(a) == RetentionPolicy.SOURCE) {
-                    hasSourceLevel = true;
-                    break;
-                }
-            }
-        }
-        int attrCount = 0;
-        if (hasSourceLevel) {
-            int attrIndex = writeAttr(nbNames._org_netbeans_SourceLevelParameterAnnotations);
-            databuf.appendByte(m.params.length());
-            for (VarSymbol s : m.params) {
-                ListBuffer<Attribute.Compound> buf = new ListBuffer<Attribute.Compound>();
-                for (Attribute.Compound a : s.getRawAttributes())
-                    if (types.getRetention(a) == RetentionPolicy.SOURCE)
-                        buf.append(a);
-                databuf.appendChar(buf.length());
-                for (Attribute.Compound a : buf)
-                    writeCompoundAttribute(a);
-            }
-            endAttr(attrIndex);
-            attrCount++;
-        }
-        if (m.code == null && m.params != null && m.params.nonEmpty()) {
-            int attrIndex = writeAttr(nbNames._org_netbeans_ParameterNames);
-            for (VarSymbol s : m.params)
-                databuf.appendChar(pool.put(s.name));
-            endAttr(attrIndex);
-            attrCount++;
-        }
-        return attrCount;
-    }
-
-    @Override
-    protected int writeExtraJavaAnnotations(List<Attribute.Compound> attrs) {
-        ListBuffer<Attribute.Compound> sourceLevel = new ListBuffer<Attribute.Compound>();
-        for (Attribute.Compound a : attrs) {
-            if (types.getRetention(a) == RetentionPolicy.SOURCE) {
-                sourceLevel.append(a);
-            }
-        }
-        int attrCount = 0;
-        if (sourceLevel.nonEmpty()) {
-            int attrIndex = writeAttr(nbNames._org_netbeans_SourceLevelAnnotations);
-            databuf.appendChar(sourceLevel.length());
-            for (Attribute.Compound a : sourceLevel)
-                writeCompoundAttribute(a);
-            endAttr(attrIndex);
-            attrCount++;
-        }
-        return attrCount;
-    }
-
-    @Override
-    protected int writeExtraTypeAnnotations(List<TypeCompound> attrs) {
-        ListBuffer<Attribute.TypeCompound> sourceLevel = new ListBuffer<Attribute.TypeCompound>();
-        for (Attribute.TypeCompound tc : attrs) {
-            if (tc.hasUnknownPosition()) {
-                boolean fixed = tc.tryFixPosition();
-
-                // Could we fix it?
-                if (!fixed) {
-                    // This happens for nested types like @A Outer. @B Inner.
-                    // For method parameters we get the annotation twice! Once with
-                    // a valid position, once unknown.
-                    // TODO: find a cleaner solution.
-                    continue;
-                }
-            }
-
-            if (tc.position.type.isLocal())
-                continue;
-            if (!tc.position.emitToClassfile()) {
-                continue;
-            }
-            if (types.getRetention(tc) == RetentionPolicy.SOURCE) {
-                sourceLevel.append(tc);
-            }
-        }
-        int attrCount = 0;
-        if (sourceLevel.nonEmpty()) {
-            int attrIndex = writeAttr(nbNames._org_netbeans_SourceLevelTypeAnnotations);
-            databuf.appendChar(sourceLevel.length());
-            for (Attribute.TypeCompound p : sourceLevel)
-                writeTypeAnnotation(p);
-            endAttr(attrIndex);
-            attrCount++;
-        }
-        return attrCount;
-    }
 }
diff --git a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBEnter.java b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBEnter.java
index 93018d14a..475fa4d3d 100644
--- a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBEnter.java
+++ b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBEnter.java
@@ -18,8 +18,11 @@
  */
 package org.netbeans.lib.nbjavac.services;
 
+import com.sun.tools.javac.code.Symtab;
 import com.sun.tools.javac.comp.Enter;
+import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.JCClassDecl;
+import com.sun.tools.javac.tree.TreeInfo;
 import com.sun.tools.javac.util.Context;
 import org.netbeans.lib.nbjavac.services.NBTreeMaker.IndexedClassDecl;
 
@@ -38,10 +41,12 @@ public Enter make(Context c) {
     }
 
     private final CancelService cancelService;
+    private final Symtab syms;
 
     public NBEnter(Context context) {
         super(context);
         cancelService = CancelService.instance(context);
+        syms = Symtab.instance(context);
     }
 
     @Override
@@ -51,6 +56,15 @@ public void visitClassDef(JCClassDecl tree) {
     }
 
     @Override
+    public void visitTopLevel(JCTree.JCCompilationUnit tree) {
+        if (TreeInfo.isModuleInfo(tree) && tree.modle == syms.noModule) {
+            //workaround: when source level == 8, then visitTopLevel crashes for module-info.java
+            return ;
+        }
+        super.visitTopLevel(tree);
+    }
+
+    //no @Override to ensure compatibility with ordinary javac:
     protected int getIndex(JCClassDecl clazz) {
         return clazz instanceof IndexedClassDecl ? ((IndexedClassDecl) clazz).index : -1;
     }
diff --git a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBJavaCompiler.java b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBJavaCompiler.java
new file mode 100644
index 000000000..8a9659549
--- /dev/null
+++ b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBJavaCompiler.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.lib.nbjavac.services;
+
+import com.sun.tools.javac.main.JavaCompiler;
+import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.List;
+import java.util.Collection;
+import java.util.Collections;
+
+/**
+ *
+ * @author lahvac
+ */
+public class NBJavaCompiler extends JavaCompiler {
+
+    public static void preRegister(Context context) {
+        context.put(compilerKey, new Context.Factory<JavaCompiler>() {
+            public JavaCompiler make(Context c) {
+                return new NBJavaCompiler(c);
+            }
+        });
+    }
+
+    private final CancelService cancelService;
+
+    public NBJavaCompiler(Context context) {
+        super(context);
+        cancelService = CancelService.instance(context);
+    }
+
+    @Override
+    public void processAnnotations(List<JCTree.JCCompilationUnit> roots, Collection<String> classnames) {
+        if (roots.isEmpty()) {
+            super.processAnnotations(roots, classnames);
+        } else {
+            setOrigin(roots.head.sourcefile.toUri().toString());
+            try {
+                super.processAnnotations(roots, classnames);
+            } finally {
+                setOrigin("");
+            }
+        }
+    }
+
+    private void setOrigin(String origin) {
+        fileManager.handleOption("apt-origin", Collections.singletonList(origin).iterator());
+    }
+}
diff --git a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBJavadocClassFinder.java b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBJavadocClassFinder.java
new file mode 100644
index 000000000..ad0816366
--- /dev/null
+++ b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBJavadocClassFinder.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.lib.nbjavac.services;
+
+import com.sun.tools.javac.code.ClassFinder;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javadoc.main.JavadocClassFinder;
+import javax.tools.JavaFileObject;
+
+/**
+ *
+ * @author lahvac
+ */
+public class NBJavadocClassFinder extends JavadocClassFinder {
+
+    public static void preRegister(Context context) {
+        context.put(classFinderKey, new Context.Factory<ClassFinder>() {
+            public ClassFinder make(Context c) {
+                return new NBJavadocClassFinder(c);
+            }
+        });
+    }
+
+    public NBJavadocClassFinder(Context context) {
+        super(context);
+    }
+
+    @Override
+    protected JavaFileObject preferredFileObject(JavaFileObject a, JavaFileObject b) {
+        if (b.getName().toLowerCase().endsWith(".sig")) {
+            //do not prefer sources over sig files (unless sources are newer):
+            boolean prevPreferSource = preferSource;
+            try {
+                preferSource = false;
+                return super.preferredFileObject(a, b);
+            } finally {
+                preferSource = prevPreferSource;
+            }
+        }
+        return super.preferredFileObject(a, b);
+    }
+
+}
diff --git a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBJavadocEnter.java b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBJavadocEnter.java
index 2321c89c3..fb92f4216 100644
--- a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBJavadocEnter.java
+++ b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBJavadocEnter.java
@@ -20,9 +20,12 @@
 package org.netbeans.lib.nbjavac.services;
 
 import com.sun.tools.javac.code.Symbol.ClassSymbol;
+import com.sun.tools.javac.code.Symtab;
 import com.sun.tools.javac.comp.Enter;
+import com.sun.tools.javac.tree.JCTree;
 import com.sun.tools.javac.tree.JCTree.JCClassDecl;
 import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
+import com.sun.tools.javac.tree.TreeInfo;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition;
 import com.sun.tools.javadoc.main.JavadocEnter;
@@ -48,11 +51,13 @@ public Enter make(Context c) {
 
     private final Messager messager;
     private final CancelService cancelService;
+    private final Symtab syms;
 
     protected NBJavadocEnter(Context context) {
         super(context);
         messager = Messager.instance0(context);
         cancelService = CancelService.instance(context);
+        syms = Symtab.instance(context);
     }
 
     public @Override void main(com.sun.tools.javac.util.List<JCCompilationUnit> trees) {
@@ -73,6 +78,15 @@ public void visitClassDef(JCClassDecl tree) {
     }
 
     @Override
+    public void visitTopLevel(JCTree.JCCompilationUnit tree) {
+        if (TreeInfo.isModuleInfo(tree) && tree.modle == syms.noModule) {
+            //workaround: when source level is == 8, then visitTopLevel crashes for module-info.java
+            return ;
+        }
+        super.visitTopLevel(tree);
+    }
+
+    //no @Override to ensure compatibility with ordinary javac:
     protected int getIndex(JCClassDecl clazz) {
         return clazz instanceof IndexedClassDecl ? ((IndexedClassDecl) clazz).index : -1;
     }
diff --git a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBJavadocMemberEnter.java b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBJavadocMemberEnter.java
index eddc66d6e..c15d91c65 100644
--- a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBJavadocMemberEnter.java
+++ b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBJavadocMemberEnter.java
@@ -21,7 +21,9 @@
 import com.sun.source.util.TreePath;
 import com.sun.tools.javac.api.JavacTrees;
 import com.sun.tools.javac.comp.MemberEnter;
+import com.sun.tools.javac.tree.JCTree.JCBlock;
 import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
+import com.sun.tools.javac.tree.JCTree.JCExpression;
 import com.sun.tools.javac.tree.JCTree.JCImport;
 import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
 import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
@@ -66,7 +68,13 @@ public void visitImport(JCImport tree) {
     @Override
     public void visitMethodDef(JCMethodDecl tree) {
         cancelService.abortIfCanceled();
-        super.visitMethodDef(tree);
+        JCBlock body = tree.body;
+        try {
+            super.visitMethodDef(tree);
+        } finally {
+            //reinstall body:
+            tree.body = body;
+        }
         if (trees instanceof NBJavacTrees && !env.enclClass.defs.contains(tree)) {
             TreePath path = trees.getPath(env.toplevel, env.enclClass);
             if (path != null) {
@@ -78,7 +86,13 @@ public void visitMethodDef(JCMethodDecl tree) {
     @Override
     public void visitVarDef(JCVariableDecl tree) {
         cancelService.abortIfCanceled();
-        super.visitVarDef(tree);
+        JCExpression init = tree.init;
+        try {
+            super.visitVarDef(tree);
+        } finally {
+            //reinstall init:
+            tree.init = init;
+        }
     }
 
 }
diff --git a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBParserFactory.java b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBParserFactory.java
index 9e09e6af3..98d858bfb 100644
--- a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBParserFactory.java
+++ b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBParserFactory.java
@@ -33,6 +33,7 @@
 import com.sun.tools.javac.tree.JCTree.JCMethodInvocation;
 import com.sun.tools.javac.tree.JCTree.JCModifiers;
 import com.sun.tools.javac.tree.JCTree.JCTypeParameter;
+import com.sun.tools.javac.tree.TreeInfo;
 import com.sun.tools.javac.tree.TreeScanner;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.List;
@@ -76,53 +77,6 @@ public JavacParser newParser(CharSequence input, boolean keepDocComments, boolea
         return new NBJavacParser(this, lexer, keepDocComments, keepLineMap, keepEndPos, parseModuleInfo, cancelService);
     }
 
-    public JavacParser newParser(CharSequence input, int startPos, final EndPosTable endPos) {
-        Scanner lexer = scannerFactory.newScanner(input, true);
-        lexer.seek(startPos);
-        if (endPos instanceof NBJavacParser.EndPosTableImpl) {
-            ((NBJavacParser.EndPosTableImpl)endPos).resetErrorEndPos();
-        }
-        return new NBJavacParser(this, lexer, true, false, true, false, cancelService) {
-            @Override protected AbstractEndPosTable newEndPosTable(boolean keepEndPositions) {
-                return new AbstractEndPosTable(this) {
-
-                    @Override
-                    public void storeEnd(JCTree tree, int endpos) {
-                        ((EndPosTableImpl)endPos).storeEnd(tree, endpos);
-                    }
-
-                    @Override
-                    protected <T extends JCTree> T to(T t) {
-                        storeEnd(t, token.endPos);
-                        return t;
-                    }
-
-                    @Override
-                    protected <T extends JCTree> T toP(T t) {
-                        storeEnd(t, S.prevToken().endPos);
-                        return t;
-                    }
-
-                    @Override
-                    public int getEndPos(JCTree tree) {
-                        return endPos.getEndPos(tree);
-                    }
-
-                    @Override
-                    public int replaceTree(JCTree oldtree, JCTree newtree) {
-                        return endPos.replaceTree(oldtree, newtree);
-                    }
-
-                    @Override
-                    public void setErrorEndPos(int errPos) {
-                        super.setErrorEndPos(errPos);
-                        ((EndPosTableImpl)endPos).setErrorEndPos(errPos);
-                    }
-                };
-            }
-        };
-    }
-
     public static class NBJavacParser extends JavacParser {
 
         private final Names names;
@@ -136,7 +90,13 @@ public NBJavacParser(NBParserFactory fac, Lexer S, boolean keepDocComments, bool
 
         @Override
         protected AbstractEndPosTable newEndPosTable(boolean keepEndPositions) {
-            return keepEndPositions ? new EndPosTableImpl(this) : super.newEndPosTable(keepEndPositions);
+            AbstractEndPosTable res = super.newEndPosTable(keepEndPositions);
+            
+            if (keepEndPositions) {
+                return new EndPosTableImpl(S, this, (SimpleEndPosTable) res);
+            }
+            
+            return res;
         }
 
         @Override
@@ -177,25 +137,59 @@ public JCCompilationUnit parseCompilationUnit() {
             assignAnonymousClassIndices(names, toplevel, null, -1);
             return toplevel;
         }
-        
-        public final class EndPosTableImpl extends SimpleEndPosTable {
+
+        @Override
+        public int getEndPos(JCTree jctree) {
+            return TreeInfo.getEndPos(jctree, endPosTable);
+        }
+
+        public final class EndPosTableImpl extends AbstractEndPosTable {
             
-            private EndPosTableImpl(JavacParser parser) {
+            private final Lexer lexer;
+            private final SimpleEndPosTable delegate;
+
+            private EndPosTableImpl(Lexer lexer, JavacParser parser, SimpleEndPosTable delegate) {
                 super(parser);
+                this.lexer = lexer;
+                this.delegate = delegate;
             }
             
-            private void resetErrorEndPos() {
-                errorEndPos = Position.NOPOS;
+            public void resetErrorEndPos() {
+                delegate.errorEndPos = Position.NOPOS;
+                errorEndPos = delegate.errorEndPos;
             }
             
             @Override public void storeEnd(JCTree tree, int endpos) {
                 if (endpos >= 0)
-                    super.storeEnd(tree, endpos);
+                    delegate.storeEnd(tree, endpos);
             }
 
             @Override
             public void setErrorEndPos(int errPos) {
-                super.setErrorEndPos(errPos);
+                delegate.setErrorEndPos(errPos);
+                errorEndPos = delegate.errorEndPos;
+            }
+
+            @Override
+            protected <T extends JCTree> T to(T t) {
+                storeEnd(t, parser.token().endPos);
+                return t;
+            }
+
+            @Override
+            protected <T extends JCTree> T toP(T t) {
+                storeEnd(t, lexer.prevToken().endPos);
+                return t;
+            }
+
+            @Override
+            public int getEndPos(JCTree jctree) {
+                return delegate.getEndPos(jctree);
+            }
+
+            @Override
+            public int replaceTree(JCTree jctree, JCTree jctree1) {
+                return delegate.replaceTree(jctree, jctree1);
             }
         }
     }
diff --git a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBResolve.java b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBResolve.java
index f9db91940..da2c41104 100644
--- a/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBResolve.java
+++ b/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBResolve.java
@@ -71,5 +71,8 @@ public boolean isAccessible(Env<AttrContext> env, TypeSymbol c, boolean checkInn
         if (accessibleOverride) return true;
         return super.isAccessible(env, c, checkInner);
     }
-    
+
+    public static boolean isStatic(Env<AttrContext> env) {
+        return Resolve.isStatic(env);
+    }
 }
diff --git a/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/AnonymousNumberingTest.java b/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/AnonymousNumberingTest.java
index e14583e0e..803ef2d0d 100644
--- a/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/AnonymousNumberingTest.java
+++ b/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/AnonymousNumberingTest.java
@@ -19,11 +19,13 @@
 
 package org.netbeans.lib.nbjavac.services;
 
+import com.sun.source.tree.CompilationUnitTree;
 import com.sun.tools.javac.api.JavacTaskImpl;
 import com.sun.tools.javac.code.Symtab;
 import com.sun.tools.javac.comp.Modules;
 import com.sun.tools.javac.util.Name;
 import java.io.IOException;
+import javax.lang.model.element.Element;
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.type.DeclaredType;
 import junit.framework.TestCase;
@@ -38,7 +40,7 @@ public AnonymousNumberingTest(String name) {
         super(name);
     }
 
-    public void testCorrectAnonymousIndicesForMethodInvocations() throws IOException {
+    public void testCorrectAnonymousIndicesForMethodInvocations() throws Exception {
         String code = "package test;\n" +
                       "public class Test {\n" +
                       "    public Test main(Object o) {\n" +
@@ -56,7 +58,8 @@ public void testCorrectAnonymousIndicesForMethodInvocations() throws IOException
 
         JavacTaskImpl ct = Utilities.createJavac(null, Utilities.fileObjectFor(code));
         
-        ct.analyze();
+        Iterable<? extends CompilationUnitTree> cuts = ct.parse();
+        Iterable<? extends Element> analyze = ct.analyze();
         
         Symtab symTab = Symtab.instance(ct.getContext());
         Modules modules = Modules.instance(ct.getContext());
diff --git a/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/NBClassWriterTest.java b/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/NBClassWriterTest.java
index 75c76223e..6dd9bdae7 100644
--- a/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/NBClassWriterTest.java
+++ b/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/NBClassWriterTest.java
@@ -21,7 +21,6 @@
 import com.sun.tools.javac.api.JavacTaskImpl;
 import com.sun.tools.javac.api.JavacTool;
 import com.sun.tools.javac.util.Context;
-import com.sun.tools.javadoc.main.JavadocClassFinder;
 import java.io.File;
 import java.io.IOException;
 import java.net.URI;
@@ -94,7 +93,6 @@ private void compile(String code) throws Exception {
         final JavacTaskImpl ct = (JavacTaskImpl) ((JavacTool)tool).getTask(null, std, null, Arrays.asList("-bootclasspath",  bootPath, "-source", "1.6", "-target", "1.6"), null, Arrays.asList(new MyFileObject(code)), context);
 
         NBClassReader.preRegister(ct.getContext());
-        JavadocClassFinder.preRegister(ct.getContext(), false);
         NBClassWriter.preRegister(ct.getContext());
 
         ct.call();
@@ -112,10 +110,9 @@ private void testEnclosedByPackage(String packageName, String... expectedClassNa
 
         Context context = new Context();
         NBMessager.preRegister(context, null, DEV_NULL, DEV_NULL, DEV_NULL);
-        JavacTaskImpl ct = (JavacTaskImpl)((JavacTool)tool).getTask(null, std, null, Arrays.asList("-bootclasspath",  bootPath), null, Arrays.<JavaFileObject>asList(), context);
+        JavacTaskImpl ct = (JavacTaskImpl)((JavacTool)tool).getTask(null, std, null, Arrays.asList("-bootclasspath",  bootPath, "-source", "1.8", "-target", "1.8"), null, Arrays.<JavaFileObject>asList(), context);
 
         NBClassReader.preRegister(ct.getContext());
-        JavadocClassFinder.preRegister(ct.getContext(), false);
         NBClassWriter.preRegister(ct.getContext());
         
         PackageElement pack = ct.getElements().getPackageElement(packageName);
diff --git a/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/Utilities.java b/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/Utilities.java
index 3a78f5cd3..ca52d7fc2 100644
--- a/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/Utilities.java
+++ b/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/Utilities.java
@@ -29,6 +29,8 @@
 import java.net.URI;
 import java.util.Arrays;
 import java.util.Collections;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticListener;
 import javax.tools.JavaCompiler;
 import javax.tools.JavaFileManager;
 import javax.tools.JavaFileObject;
@@ -51,13 +53,11 @@ public static JavacTaskImpl createJavac(JavaFileManager fm, JavaFileObject... so
         Messager.preRegister(context, null, DEV_NULL, DEV_NULL, DEV_NULL);
         JavacTaskImpl task = (JavacTaskImpl)JavacTool.create().getTask(null, 
                 fm,
-                null, Arrays.asList("-bootclasspath",  bootPath, "-source", version, "-Xjcov", "-XDshouldStopPolicy=GENERATE"), null, Arrays.asList(sources),
+                null, Arrays.asList("-bootclasspath",  bootPath, "-source", version, "-target", version, "-Xjcov", "-XDshouldStopPolicy=GENERATE"), null, Arrays.asList(sources),
                 context);
         NBParserFactory.preRegister(context);
         NBTreeMaker.preRegister(context);
-        NBJavadocEnter.preRegister(context);
-        PrintWriter w = new PrintWriter(System.out);
-        JavadocClassFinder.preRegister(context, true);
+        NBEnter.preRegister(context);
         return task;
     }
     
diff --git a/lib.nbjshell/nbproject/project.properties b/lib.nbjshell/nbproject/project.properties
index 484c87b31..d457ff77b 100644
--- a/lib.nbjshell/nbproject/project.properties
+++ b/lib.nbjshell/nbproject/project.properties
@@ -21,3 +21,4 @@ cp.extra=${tools.jar}
 sigtest.skip.check=true
 sigtest.gen.fail.on.error=false
 is.autoload=true
+requires.nb.javac=true
diff --git a/libs.javacapi/build.xml b/libs.javacapi/build.xml
index fb5228983..320351ce4 100644
--- a/libs.javacapi/build.xml
+++ b/libs.javacapi/build.xml
@@ -21,4 +21,15 @@
 -->
 <project name="libs.javacapi" default="netbeans" basedir=".">
     <import file="../nbbuild/templates/projectized.xml"/>
+    <target name="-check-nb-javac-exists">
+        <available property="nb-javac.exists" file="../nb-javac/make/netbeans/nb-javac/build.xml"/>
+    </target>
+    <target name="-release.files-build-javac" if="nb-javac.exists">
+        <ant dir="../nb-javac/make/netbeans/nb-javac" target="jar" inheritAll="false"/>
+        <copy file="../nb-javac/make/netbeans/nb-javac/dist/javac-api.jar" tofile="external/nb-javac-api.jar" overwrite="true"/>
+    </target>
+    <target name="-release.files-delegate" unless="nb-javac.exists">
+        <antcall target="projectized.-release.files" />
+    </target>
+    <target name="-release.files" depends="-check-nb-javac-exists,-release.files-build-javac,-release.files-delegate" />
 </project>
diff --git a/libs.javacapi/external/binaries-list b/libs.javacapi/external/binaries-list
index 3f4d18162..b64ae0816 100644
--- a/libs.javacapi/external/binaries-list
+++ b/libs.javacapi/external/binaries-list
@@ -14,4 +14,4 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-184D809687180CF321C724B8E8EA1C3945E8C208 nb-javac-api.jar
+184D809687180CF321C724B8E8EA1C3945E8C208 nb-javac-9-api.jar
diff --git a/libs.javacapi/external/nb-javac-api-license.txt b/libs.javacapi/external/nb-javac-9-api-license.txt
similarity index 99%
rename from libs.javacapi/external/nb-javac-api-license.txt
rename to libs.javacapi/external/nb-javac-9-api-license.txt
index a41f3091e..051f9df68 100644
--- a/libs.javacapi/external/nb-javac-api-license.txt
+++ b/libs.javacapi/external/nb-javac-9-api-license.txt
@@ -1,10 +1,11 @@
-Version: nb-7.2
 Name: Javac Compiler API
-License: GPL-2-CP
 Description: Javac Compiler API
-OSR: 6273
-Origin: Oracle (http://hg.openjdk.java.net/)
+Version: 9
+License: GPL-2-CP
+Origin: OpenJDK (http://hg.openjdk.java.net/)
 Source: http://hg.netbeans.org/main/nb-javac/
+Type: compile-time,optional
+Comment: Used at design time to compile against; optional at runtime.
 
 The GNU General Public License (GPL)
 Version 2, June 1991
diff --git a/libs.javacapi/manifest.mf b/libs.javacapi/manifest.mf
index 1017f6655..5177edfe6 100644
--- a/libs.javacapi/manifest.mf
+++ b/libs.javacapi/manifest.mf
@@ -4,4 +4,3 @@ OpenIDE-Module-Implementation-Version: 3
 OpenIDE-Module-Localizing-Bundle: org/netbeans/libs/javacapi/Bundle.properties
 OpenIDE-Module-Layer: org/netbeans/libs/javacapi/layer.xml
 OpenIDE-Module-Requires: org.openide.modules.ModuleFormat2
-OpenIDE-Module-Hide-Classpath-Packages: com.sun.javadoc.**, com.sun.source.**, javax.annotation.processing.**, javax.lang.model.**, javax.tools.**, com.sun.tools.javac.**
diff --git a/libs.javacapi/nbproject/project.properties b/libs.javacapi/nbproject/project.properties
index b31df1009..bc0609b60 100644
--- a/libs.javacapi/nbproject/project.properties
+++ b/libs.javacapi/nbproject/project.properties
@@ -22,6 +22,5 @@ javadoc.title=Javac API
 nbm.homepage=http://jackpot.netbeans.org/
 nbm.module.author=Petr Hrebejk
 spec.version.base=8.22.0
-release.external/nb-javac-api.jar=modules/ext/nb-javac-api.jar
 javadoc.arch=${basedir}/arch.xml
 module.javadoc.packages=com.sun.source.tree,com.sun.source.util
diff --git a/libs.javacapi/nbproject/project.xml b/libs.javacapi/nbproject/project.xml
index 21efad03f..1ac7783d0 100644
--- a/libs.javacapi/nbproject/project.xml
+++ b/libs.javacapi/nbproject/project.xml
@@ -26,6 +26,8 @@
             <code-name-base>org.netbeans.libs.javacapi</code-name-base>
             <module-dependencies/>
             <public-packages>
+                <!-- TODO: need to specify exports here, because fragments cannot add exports - should be fixed? -->
+                <package>org.netbeans.libs.javacapi</package>
                 <package>com.sun.javadoc</package>
                 <package>com.sun.source.doctree</package>
                 <package>com.sun.source.tree</package>
@@ -38,8 +40,8 @@
                 <package>javax.tools</package>
             </public-packages>
             <class-path-extension>
-                <runtime-relative-path>ext/nb-javac-api.jar</runtime-relative-path>
-                <binary-origin>external/nb-javac-api.jar</binary-origin>
+                <runtime-relative-path />
+                <binary-origin>external/nb-javac-9-api.jar</binary-origin>
             </class-path-extension>
         </data>
     </configuration>
diff --git a/libs.javacimpl/build.xml b/libs.javacimpl/build.xml
index 30feaddf9..678feb1e0 100644
--- a/libs.javacimpl/build.xml
+++ b/libs.javacimpl/build.xml
@@ -27,11 +27,9 @@
     <target name="-release.files-build-javac" if="nb-javac.exists">
         <ant dir="../nb-javac/make/netbeans/nb-javac" target="jar" inheritAll="false"/>
         <copy file="../nb-javac/make/netbeans/nb-javac/dist/javac-impl.jar" tofile="external/nb-javac-impl.jar" overwrite="true"/>
-        <property name="release.files.extra" value="modules/ext/nb-javac-impl.jar"/>
     </target>
     <target name="-release.files-delegate" unless="nb-javac.exists">
         <antcall target="projectized.-release.files" />
-        <property name="release.files.extra" value="modules/ext/nb-javac-impl.jar"/>
     </target>
     <target name="-release.files" depends="-check-nb-javac-exists,-release.files-build-javac,-release.files-delegate" />
 </project>
diff --git a/libs.javacimpl/external/binaries-list b/libs.javacimpl/external/binaries-list
index e835c0364..dfc235cf9 100644
--- a/libs.javacimpl/external/binaries-list
+++ b/libs.javacimpl/external/binaries-list
@@ -14,4 +14,4 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-EA8670918AF969E28B53ABA8574A661BA36A402A nb-javac-impl.jar
+EA8670918AF969E28B53ABA8574A661BA36A402A nb-javac-9-impl.jar
diff --git a/libs.javacimpl/external/nb-javac-impl-license.txt b/libs.javacimpl/external/nb-javac-9-impl-license.txt
similarity index 99%
rename from libs.javacimpl/external/nb-javac-impl-license.txt
rename to libs.javacimpl/external/nb-javac-9-impl-license.txt
index 7e128d77a..1bc66dbc8 100644
--- a/libs.javacimpl/external/nb-javac-impl-license.txt
+++ b/libs.javacimpl/external/nb-javac-9-impl-license.txt
@@ -1,10 +1,11 @@
-Version: nb-7.2
 Name: Javac Compiler Implementation
-License: GPL-2-CP
 Description: Javac Compiler Implementation
-OSR: 6273
-Origin: Oracle (http://hg.openjdk.java.net/)
+Version: 9
+License: GPL-2-CP
+Origin: OpenJDK (http://hg.openjdk.java.net/)
 Source: http://hg.netbeans.org/main/nb-javac/
+Type: compile-time,optional
+Comment: Used at compile and design time to compile against; optional at runtime.
 
 The GNU General Public License (GPL)
 Version 2, June 1991
diff --git a/libs.javacimpl/manifest.mf b/libs.javacimpl/manifest.mf
index 276717c82..b7e108783 100644
--- a/libs.javacimpl/manifest.mf
+++ b/libs.javacimpl/manifest.mf
@@ -3,5 +3,3 @@ OpenIDE-Module: org.netbeans.libs.javacimpl/1
 OpenIDE-Module-Implementation-Version: 25
 OpenIDE-Module-Localizing-Bundle: org/netbeans/libs/javacimpl/Bundle.properties
 OpenIDE-Module-Requires: org.openide.modules.ModuleFormat2
-OpenIDE-Module-Hide-Classpath-Packages: com.sun.tools.javac.**, com.sun.tools.javadoc.**, com.sun.tools.javap.**, com.sun.tools.classfile.**, com.sun.tools.doclint.**
-
diff --git a/libs.javacimpl/nbproject/project.properties b/libs.javacimpl/nbproject/project.properties
index 73b79d30b..d7c28a658 100644
--- a/libs.javacimpl/nbproject/project.properties
+++ b/libs.javacimpl/nbproject/project.properties
@@ -19,7 +19,6 @@ javac.source=1.6
 nbm.homepage=http://jackpot.netbeans.org/
 nbm.module.author=Petr Hrebejk
 spec.version.base=0.48.0
-release.external/nb-javac-impl.jar=modules/ext/nb-javac-impl.jar
 javadoc.arch=${basedir}/arch.xml
 
 
@@ -37,3 +36,4 @@ javadoc.arch=${basedir}/arch.xml
 # Hidden class found: com.sun.tools.javac.jvm.Code$State in method public int com.sun.tools.javac.jvm.Code.entryPoint(com.sun.tools.javac.jvm.Code$State,com.sun.tools.javac.code.Type) in class com.sun.tools.javac.jvm.Code
 sigtest.gen.fail.on.error=false
 
+requires.nb.javac=true
diff --git a/libs.javacimpl/nbproject/project.xml b/libs.javacimpl/nbproject/project.xml
index ccbd0ec15..b018ea323 100644
--- a/libs.javacimpl/nbproject/project.xml
+++ b/libs.javacimpl/nbproject/project.xml
@@ -34,33 +34,10 @@
                     </run-dependency>
                 </dependency>
             </module-dependencies>
-            <friend-packages>
-                <friend>org.netbeans.modules.jackpot.rules</friend>
-                <friend>org.netbeans.modules.java.hints</friend>
-                <friend>org.netbeans.modules.java.source</friend>
-                <friend>org.netbeans.modules.javadoc</friend>
-                <friend>org.netbeans.modules.java.module.graph</friend>
-                <friend>org.netbeans.lib.nbjshell</friend>
-                <friend>org.netbeans.libs.jshell</friend>
-                <friend>org.netbeans.libs.jshell.compile</friend>
-                <friend>org.netbeans.modules.jdk.jshell</friend>
-                <friend>org.netbeans.modules.jshell.support</friend>
-                <package>com.sun.tools.javac</package>
-                <package>com.sun.tools.javac.api</package>
-                <package>com.sun.tools.javac.code</package>
-                <package>com.sun.tools.javac.comp</package>
-                <package>com.sun.tools.javac.jvm</package>
-                <package>com.sun.tools.javac.main</package>
-                <package>com.sun.tools.javac.model</package>
-                <package>com.sun.tools.javac.parser</package>
-                <package>com.sun.tools.javac.processing</package>
-                <package>com.sun.tools.javac.tree</package>
-                <package>com.sun.tools.javac.util</package>
-                <package>com.sun.tools.javadoc</package>
-            </friend-packages>
+            <public-packages/>
             <class-path-extension>
-                <runtime-relative-path>ext/nb-javac-impl.jar</runtime-relative-path>
-                <binary-origin>external/nb-javac-impl.jar</binary-origin>
+                <runtime-relative-path />
+                <binary-origin>external/nb-javac-9-impl.jar</binary-origin>
             </class-path-extension>
         </data>
     </configuration>
diff --git a/libs.jshell.compile/nbproject/project.properties b/libs.jshell.compile/nbproject/project.properties
index d192e7705..01fcd9bc0 100644
--- a/libs.jshell.compile/nbproject/project.properties
+++ b/libs.jshell.compile/nbproject/project.properties
@@ -26,3 +26,4 @@ javadoc.arch=${basedir}/arch.xml
 module.javadoc.packages=
 sigtest.skip.check=true
 sigtest.gen.fail.on.error=false
+requires.nb.javac=true
diff --git a/libs.jshell.compile/nbproject/project.xml b/libs.jshell.compile/nbproject/project.xml
index 96862eb79..0b49f7723 100644
--- a/libs.jshell.compile/nbproject/project.xml
+++ b/libs.jshell.compile/nbproject/project.xml
@@ -25,23 +25,6 @@
         <data xmlns="http://www.netbeans.org/ns/nb-module-project/2">
             <code-name-base>org.netbeans.libs.jshell.compile</code-name-base>
             <module-dependencies>
-                <dependency>
-                    <code-name-base>org.netbeans.libs.javacapi</code-name-base>
-                    <build-prerequisite/>
-                    <compile-dependency/>
-                    <run-dependency>
-                        <specification-version>8.19</specification-version>
-                    </run-dependency>
-                </dependency>
-                <dependency>
-                    <code-name-base>org.netbeans.libs.javacimpl</code-name-base>
-                    <build-prerequisite/>
-                    <compile-dependency/>
-                    <run-dependency>
-                        <release-version>1</release-version>
-                        <specification-version>0.47</specification-version>
-                    </run-dependency>
-                </dependency>
                 <dependency>
                     <code-name-base>org.netbeans.lib.nbjshell</code-name-base>
                     <run-dependency>
diff --git a/maven.apisupport/nbproject/project.properties b/maven.apisupport/nbproject/project.properties
index 41c0e06df..5f7dca05b 100644
--- a/maven.apisupport/nbproject/project.properties
+++ b/maven.apisupport/nbproject/project.properties
@@ -20,3 +20,4 @@ javac.source=1.6
 javac.compilerargs=-Xlint -Xlint:-serial
 
 test.config.stableBTD.includes=**/*Test.class
+requires.nb.javac=true
diff --git a/maven.hints/nbproject/project.properties b/maven.hints/nbproject/project.properties
index 2aea11bf0..82150ad72 100644
--- a/maven.hints/nbproject/project.properties
+++ b/maven.hints/nbproject/project.properties
@@ -20,3 +20,4 @@ javac.source=1.6
 #javac.compilerargs=-Xlint -Xlint:-serial
 
 test.config.stableBTD.includes=**/*Test.class
+requires.nb.javac=true
diff --git a/maven.junit.ui/nbproject/project.properties b/maven.junit.ui/nbproject/project.properties
index 7f641b767..375b0888d 100644
--- a/maven.junit.ui/nbproject/project.properties
+++ b/maven.junit.ui/nbproject/project.properties
@@ -17,3 +17,4 @@
 is.eager=true
 javac.source=1.6
 javac.compilerargs=-Xlint -Xlint:-serial
+requires.nb.javac=true
diff --git a/maven.refactoring/nbproject/project.properties b/maven.refactoring/nbproject/project.properties
index c0af75f0c..315878a03 100644
--- a/maven.refactoring/nbproject/project.properties
+++ b/maven.refactoring/nbproject/project.properties
@@ -16,3 +16,4 @@
 # under the License.
 javac.source=1.6
 javac.compilerargs=-Xlint -Xlint:-serial
+requires.nb.javac=true
diff --git a/maven/src/org/netbeans/modules/maven/queries/UnitTestsCompilerOptionsQueryImpl.java b/maven/src/org/netbeans/modules/maven/queries/UnitTestsCompilerOptionsQueryImpl.java
index 00a65a404..2a424afaf 100644
--- a/maven/src/org/netbeans/modules/maven/queries/UnitTestsCompilerOptionsQueryImpl.java
+++ b/maven/src/org/netbeans/modules/maven/queries/UnitTestsCompilerOptionsQueryImpl.java
@@ -290,7 +290,7 @@ private static String getModuleName(@NonNull final FileObject moduleInfo) {
                         cc.toPhase(JavaSource.Phase.PARSED);
                         final CompilationUnitTree cu = cc.getCompilationUnit();
                         for (Tree decl : cu.getTypeDecls()) {
-                            if (decl.getKind() == Tree.Kind.MODULE) {
+                            if (decl.getKind().name().equals("MODULE")) {
                                 res[0] = ((ModuleTree)decl).getName().toString();
                                 break;
                             }
diff --git a/nbbuild/build.xml b/nbbuild/build.xml
index 8831d61e9..cb7eb5f8f 100644
--- a/nbbuild/build.xml
+++ b/nbbuild/build.xml
@@ -71,6 +71,7 @@
     <property name="have-downloadbinaries-task" value="true" />
     <downloadbinaries cache="${binaries.cache}" server="${binaries.server}">
         <manifest dir="${nb_all}">
+            <include name="nbbuild/external/binaries-list"/>
             <include name="libs.junit4/external/binaries-list"/>
             <include name="javahelp/external/binaries-list"/>
         </manifest>
@@ -124,7 +125,39 @@
     </downloadbinaries>
   </target>
 
-  <target name="init-module-list" depends="bootstrap,init-tasks">
+  <target name="-check-vanilla-javac" depends="bootstrap">
+    <condition property="vanilla.javac.exists">
+      <and>
+        <available file="${nb_all}/nbbuild/external/vanilla-javac-api.jar" />
+        <available file="${nb_all}/nbbuild/external/vanilla-javac-impl.jar" />
+      </and>
+    </condition>
+  </target>
+
+  <target name="prepare-vanilla-javac" depends="-check-vanilla-javac" unless="vanilla.javac.exists">
+    <delete dir="${nb_all}/nbbuild/build/langtools" />
+    <mkdir dir="${nb_all}/nbbuild/build/langtools" />
+    <unzip src="${nb_all}/nbbuild/external/langtools-9.zip" dest="${nb_all}/nbbuild/build/langtools">
+        <cutdirsmapper dirs="1"/>
+    </unzip>
+    <ant antfile="${nb_all}/nbbuild/build/langtools/make/build.xml" dir="${nb_all}/nbbuild/build/langtools/" target="generate-sources">
+        <property name="langtools.jdk.home" value="${java.home}" />
+    </ant>
+    <mkdir dir="${nb_all}/nbbuild/build/langtools/build/nb" />
+    <javac srcdir="${nb_all}/nbbuild/build/langtools/src/java.compiler/share/classes:${nb_all}/nbbuild/build/langtools/src/jdk.compiler/share/classes:${nb_all}/nbbuild/build/langtools/src/jdk.javadoc/share/classes:${nb_all}/nbbuild/build/langtools/src/jdk.jdeps/share/classes:${nb_all}/nbbuild/build/langtools/build/gensrc/jdk.compiler"
+           destdir="${nb_all}/nbbuild/build/langtools/build/nb"
+           excludes="**/module-info.java,com/sun/tools/javac/main/JavacToolProvider.java,com/sun/tools/jdeps/**,com/sun/tools/jdeprscan/**,com/sun/tools/javap/Main.java,jdk/javadoc/internal/tool/JavadocToolProvider.java,com/sun/tools/doclets/standard/Standard.java" />
+    <copy todir="${nb_all}/nbbuild/build/langtools/build/nb">
+        <fileset dir="${nb_all}/nbbuild/build/langtools/src/java.compiler/share/classes" includes="**/*.properties"/>
+        <fileset dir="${nb_all}/nbbuild/build/langtools/src/jdk.compiler/share/classes" includes="**/*.properties"/>
+        <fileset dir="${nb_all}/nbbuild/build/langtools/src/jdk.javadoc/share/classes" includes="**/*.properties"/>
+        <fileset dir="${nb_all}/nbbuild/build/langtools/src/jdk.jdeps/share/classes" includes="**/*.properties"/>
+    </copy>
+    <jar destfile="${nb_all}/nbbuild/external/vanilla-javac-api.jar" basedir="${nb_all}/nbbuild/build/langtools/build/nb" includes="javax/**,com/sun/source/**,com/sun/javadoc/**" />
+    <jar destfile="${nb_all}/nbbuild/external/vanilla-javac-impl.jar" basedir="${nb_all}/nbbuild/build/langtools/build/nb" excludes="javax/**,com/sun/source/**,com/sun/javadoc/**" />
+  </target>
+
+  <target name="init-module-list" depends="bootstrap,init-tasks,prepare-vanilla-javac">
     <!-- Define modules. -->
     <checkmoduleconfigs nbroot=".."/>
     <resolvelist name="allmodules" list="${nb.clusters.list}"/>
diff --git a/nbbuild/cluster.properties b/nbbuild/cluster.properties
index e9ca269bd..e0ff36b1d 100644
--- a/nbbuild/cluster.properties
+++ b/nbbuild/cluster.properties
@@ -621,6 +621,7 @@ nb.cluster.java=\
         java.source.ant,\
         java.source.base,\
         java.source.compat8,\
+        java.source.nbjavac,\
         java.source.queries,\
         java.source.queriesimpl,\
         java.sourceui,\
diff --git a/nbbuild/external/binaries-list b/nbbuild/external/binaries-list
index b6035a599..0bdc51654 100644
--- a/nbbuild/external/binaries-list
+++ b/nbbuild/external/binaries-list
@@ -16,3 +16,4 @@
 # under the License.
 A7674A6D78B7FEA58AF76B357DAE6EA5E3FDFBE9 apitest.jar
 16398550402B27F81CD0D508CEF54B3E47A4A6DA org.apache.rat:apache-rat:0.12
+AB396EE119BFAD809CC9F09950CC22E2BCE2FE35 langtools-9.zip
diff --git a/nbbuild/external/langtools-9-license.txt b/nbbuild/external/langtools-9-license.txt
new file mode 100644
index 000000000..d28fbb2ca
--- /dev/null
+++ b/nbbuild/external/langtools-9-license.txt
@@ -0,0 +1,434 @@
+Name: Javac Compiler
+Description: Javac Compiler
+Version: 9
+License: GPL-2-CP
+Origin: OpenJDK (http://hg.openjdk.java.net/)
+Source: http://hg.openjdk.java.net/jdk9/jdk9/langtools/archive/tip.zip
+Type: compile-time
+Comment: Used at compile to compile code that runs either against JDK 9+ or (optional) nb-javac library.
+
+The GNU General Public License (GPL)
+Version 2, June 1991
+
+ Copyright 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim
+ copies of this license document, but changing it is not
+ allowed.
+
+                      Preamble
+
+The licenses for most software are designed to take away
+your freedom to share and change it. By contrast, the GNU
+General Public License is intended to guarantee your freedom
+to share and change free software--to make sure the software
+is free for all its users. This General Public License
+applies to most of the Free Software Foundation's software
+and to any other program whose authors commit to using it.
+(Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can
+apply it to your programs, too.
+
+When we speak of free software, we are referring to freedom,
+not price. Our General Public Licenses are designed to make
+sure that you have the freedom to distribute copies of free
+software (and charge for this service if you wish), that you
+receive source code or can get it if you want it, that you
+can change the software or use pieces of it in new free
+programs; and that you know you can do these things.
+
+To protect your rights, we need to make restrictions that
+forbid anyone to deny you these rights or to ask you to
+surrender the rights. These restrictions translate to
+certain responsibilities for you if you distribute copies of
+the software, or if you modify it.
+
+For example, if you distribute copies of such a program,
+whether gratis or for a fee, you must give the recipients
+all the rights that you have. You must make sure that they,
+too, receive or can get the source code. And you must show
+them these terms so they know their rights.
+
+We protect your rights with two steps: (1) copyright the
+software, and (2) offer you this license which gives you
+legal permission to copy, distribute and/or modify the
+software.
+
+Also, for each author's protection and ours, we want to make
+certain that everyone understands that there is no warranty
+for this free software. If the software is modified by
+someone else and passed on, we want its recipients to know
+that what they have is not the original, so that any
+problems introduced by others will not reflect on the
+original authors' reputations.
+
+Finally, any free program is threatened constantly by
+software patents. We wish to avoid the danger that
+redistributors of a free program will individually obtain
+patent licenses, in effect making the program proprietary.
+To prevent this, we have made it clear that any patent must
+be licensed for everyone's free use or not licensed at all.
+
+The precise terms and conditions for copying, distribution
+and modification follow.
+
+TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND
+MODIFICATION
+
+0. This License applies to any program or other work which
+contains a notice placed by the copyright holder saying it
+may be distributed under the terms of this General Public
+License. The "Program", below, refers to any such program or
+work, and a "work based on the Program" means either the
+Program or any derivative work under copyright law: that is
+to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into
+another language. (Hereinafter, translation is included
+without limitation in the term "modification".) Each
+licensee is addressed as "you".
+
+Activities other than copying, distribution and modification
+are not covered by this License; they are outside its scope.
+The act of running the Program is not restricted, and the
+output from the Program is covered only if its contents
+constitute a work based on the Program (independent of
+having been made by running the Program). Whether that is
+true depends on what the Program does.
+
+1. You may copy and distribute verbatim copies of the
+Program's source code as you receive it, in any medium,
+provided that you conspicuously and appropriately publish on
+each copy an appropriate copyright notice and disclaimer of
+warranty; keep intact all the notices that refer to this
+License and to the absence of any warranty; and give any
+other recipients of the Program a copy of this License along
+with the Program.
+
+You may charge a fee for the physical act of transferring a
+copy, and you may at your option offer warranty protection
+in exchange for a fee.
+
+2. You may modify your copy or copies of the Program or any
+portion of it, thus forming a work based on the Program, and
+copy and distribute such modifications or work under the
+terms of Section 1 above, provided that you also meet all of
+these conditions:
+
+    a) You must cause the modified files to carry prominent
+    notices stating that you changed the files and the date
+    of any change.
+
+    b) You must cause any work that you distribute or
+    publish, that in whole or in part contains or is derived
+    from the Program or any part thereof, to be licensed as
+    a whole at no charge to all third parties under the
+    terms of this License.
+
+    c) If the modified program normally reads commands
+    interactively when run, you must cause it, when started
+    running for such interactive use in the most ordinary
+    way, to print or display an announcement including an
+    appropriate copyright notice and a notice that there is
+    no warranty (or else, saying that you provide a
+    warranty) and that users may redistribute the program
+    under these conditions, and telling the user how to view
+    a copy of this License. (Exception: if the Program
+    itself is interactive but does not normally print such
+    an announcement, your work based on the Program is not
+    required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the
+Program, and can be reasonably considered independent and
+separate works in themselves, then this License, and its
+terms, do not apply to those sections when you distribute
+them as separate works. But when you distribute the same
+sections as part of a whole which is a work based on the
+Program, the distribution of the whole must be on the terms
+of this License, whose permissions for other licensees
+extend to the entire whole, and thus to each and every part
+regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights
+or contest your rights to work written entirely by you;
+rather, the intent is to exercise the right to control the
+distribution of derivative or collective works based on the
+Program.
+
+In addition, mere aggregation of another work not based on
+the Program with the Program (or with a work based on the
+Program) on a volume of a storage or distribution medium
+does not bring the other work under the scope of this
+License.
+
+3. You may copy and distribute the Program (or a work based
+on it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you
+also do one of the following:
+
+    a) Accompany it with the complete corresponding
+    machine-readable source code, which must be distributed
+    under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least
+    three years, to give any third party, for a charge no
+    more than your cost of physically performing source
+    distribution, a complete machine-readable copy of the
+    corresponding source code, to be distributed under the
+    terms of Sections 1 and 2 above on a medium customarily
+    used for software interchange; or,
+
+    c) Accompany it with the information you received as to
+    the offer to distribute corresponding source code. (This
+    alternative is allowed only for noncommercial
+    distribution and only if you received the program in
+    object code or executable form with such an offer, in
+    accord with Subsection b above.)
+
+The source code for a work means the preferred form of the
+work for making modifications to it. For an executable work,
+complete source code means all the source code for all
+modules it contains, plus any associated interface
+definition files, plus the scripts used to control
+compilation and installation of the executable. However, as
+a special exception, the source code distributed need not
+include anything that is normally distributed (in either
+source or binary form) with the major components (compiler,
+kernel, and so on) of the operating system on which the
+executable runs, unless that component itself accompanies
+the executable.
+
+If distribution of executable or object code is made by
+offering access to copy from a designated place, then
+offering equivalent access to copy the source code from the
+same place counts as distribution of the source code, even
+though third parties are not compelled to copy the source
+along with the object code.
+
+4. You may not copy, modify, sublicense, or distribute the
+Program except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense or distribute
+the Program is void, and will automatically terminate your
+rights under this License. However, parties who have
+received copies, or rights, from you under this License will
+not have their licenses terminated so long as such parties
+remain in full compliance.
+
+5. You are not required to accept this License, since you
+have not signed it. However, nothing else grants you
+permission to modify or distribute the Program or its
+derivative works. These actions are prohibited by law if you
+do not accept this License. Therefore, by modifying or
+distributing the Program (or any work based on the Program),
+you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or
+modifying the Program or works based on it.
+
+6. Each time you redistribute the Program (or any work based
+on the Program), the recipient automatically receives a
+license from the original licensor to copy, distribute or
+modify the Program subject to these terms and conditions.
+You may not impose any further restrictions on the
+recipients' exercise of the rights granted herein. You are
+not responsible for enforcing compliance by third parties to
+this License.
+
+7. If, as a consequence of a court judgment or allegation of
+patent infringement or for any other reason (not limited to
+patent issues), conditions are imposed on you (whether by
+court order, agreement or otherwise) that contradict the
+conditions of this License, they do not excuse you from the
+conditions of this License. If you cannot distribute so as
+to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a
+consequence you may not distribute the Program at all. For
+example, if a patent license would not permit royalty-free
+redistribution of the Program by all those who receive
+copies directly or indirectly through you, then the only way
+you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or
+unenforceable under any particular circumstance, the balance
+of the section is intended to apply and the section as a
+whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to
+infringe any patents or other property right claims or to
+contest validity of any such claims; this section has the
+sole purpose of protecting the integrity of the free
+software distribution system, which is implemented by public
+license practices. Many people have made generous
+contributions to the wide range of software distributed
+through that system in reliance on consistent application of
+that system; it is up to the author/donor to decide if he or
+she is willing to distribute software through any other
+system and a licensee cannot impose that choice.
+
+This section is intended to make thoroughly clear what is
+believed to be a consequence of the rest of this License.
+
+8. If the distribution and/or use of the Program is
+restricted in certain countries either by patents or by
+copyrighted interfaces, the original copyright holder who
+places the Program under this License may add an explicit
+geographical distribution limitation excluding those
+countries, so that distribution is permitted only in or
+among countries not thus excluded. In such case, this
+License incorporates the limitation as if written in the
+body of this License.
+
+9. The Free Software Foundation may publish revised and/or
+new versions of the General Public License from time to
+time. Such new versions will be similar in spirit to the
+present version, but may differ in detail to address new
+problems or concerns.
+
+Each version is given a distinguishing version number. If
+the Program specifies a version number of this License which
+applies to it and "any later version", you have the option
+of following the terms and conditions either of that version
+or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number
+of this License, you may choose any version ever published
+by the Free Software Foundation.
+
+10. If you wish to incorporate parts of the Program into
+other free programs whose distribution conditions are
+different, write to the author to ask for permission. For
+software which is copyrighted by the Free Software
+Foundation, write to the Free Software Foundation; we
+sometimes make exceptions for this. Our decision will be
+guided by the two goals of preserving the free status of all
+derivatives of our free software and of promoting the
+sharing and reuse of software generally.
+
+NO WARRANTY
+
+11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS
+NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE
+COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM
+"AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR
+IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE
+OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE
+DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED
+TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY
+WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED
+ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
+SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF
+THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT
+LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR
+LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
+PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH
+HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+              END OF TERMS AND CONDITIONS
+
+       How to Apply These Terms to Your New Programs
+
+If you develop a new program, and you want it to be of the
+greatest possible use to the public, the best way to achieve
+this is to make it free software which everyone can
+redistribute and change under these terms.
+
+To do so, attach the following notices to the program. It is
+safest to attach them to the start of each source file to
+most effectively convey the exclusion of warranty; and each
+file should have at least the "copyright" line and a pointer
+to where the full notice is found.
+
+    One line to give the program's name and a brief idea of
+    what it does. Copyright (C) <year> <name of author>
+
+    This program is free software; you can redistribute it
+    and/or modify it under the terms of the GNU General
+    Public License as published by the Free Software
+    Foundation; either version 2 of the License, or (at your
+    option) any later version.
+
+    This program is distributed in the hope that it will be
+    useful, but WITHOUT ANY WARRANTY; without even the
+    implied warranty of MERCHANTABILITY or FITNESS FOR A
+    PARTICULAR PURPOSE. See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General
+    Public License along with this program; if not, write to
+    the Free Software Foundation, Inc., 59 Temple Place,
+    Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and
+paper mail.
+
+If the program is interactive, make it output a short notice
+like this when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of
+    author Gnomovision comes with ABSOLUTELY NO WARRANTY;
+    for details type `show w'. This is free software, and
+    you are welcome to redistribute it under certain
+    conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show
+the appropriate parts of the General Public License. Of
+course, the commands you use may be called something other
+than `show w' and `show c'; they could even be mouse-clicks
+or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a
+programmer) or your school, if any, to sign a "copyright
+disclaimer" for the program, if necessary. Here is a sample;
+alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in
+  the program `Gnomovision' (which makes passes at
+  compilers) written by James Hacker.
+
+  signature of Ty Coon, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating
+your program into proprietary programs. If your program is a
+subroutine library, you may consider it more useful to
+permit linking proprietary applications with the library. If
+this is what you want to do, use the GNU Library General
+Public License instead of this License.
+
+
+"CLASSPATH" EXCEPTION TO THE GPL VERSION 2
+
+
+Certain source files distributed by Sun Microsystems, Inc.
+are subject to the following clarification and special
+exception to the GPL, but only where Sun has expressly
+included in the particular source file's header the words
+"Sun designates this particular file as subject to the
+"Classpath" exception as provided by Sun in the LICENSE file
+that accompanied this code."
+
+Linking this library statically or dynamically with other
+modules is making a combined work based on this library.
+Thus, the terms and conditions of the GNU General Public
+License cover the whole combination.
+
+As a special exception, the copyright holders of this
+library give you permission to link this library with
+independent modules to produce an executable, regardless of
+the license terms of these independent modules, and to copy
+and distribute the resulting executable under terms of your
+choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license
+of that module. An independent module is a module which is
+not derived from or based on this library. If you modify
+this library, you may extend this exception to your version
+of the library, but you are not obligated to do so. If you
+do not wish to do so, delete this exception statement from
+your version.
diff --git a/nbbuild/jdk.xml b/nbbuild/jdk.xml
index 5f3935afb..146c26882 100644
--- a/nbbuild/jdk.xml
+++ b/nbbuild/jdk.xml
@@ -217,6 +217,16 @@
         <!-- Will be bogus on Mac OS X, but doesn't matter - Classes/classes.jar should have this anyway -->
         <property name="tools.jar" location="${nbjdk.home}/lib/tools.jar"/>
         <!--<echo level="info">Using JDK: ${nbjdk.home}</echo>-->
+        <condition property=".exe" value=".exe">
+            <os family="windows"/> <!-- #72467 -->
+        </condition>
+        <property name=".exe" value=""/>
+        <condition property="test.nbjdk.java" value="${test.nbjdk.home}/bin/java${.exe}" else="${nbjdk.home}/bin/java${.exe}">
+            <and>
+                <isset property="test.nbjdk.home" />
+                <available file="${test.nbjdk.home}/bin/java${.exe}" type="file"/>
+            </and>
+        </condition>
     </target>
     
 </project>
diff --git a/nbbuild/licenses/Apache-2.0+BSD-INRIA b/nbbuild/licenses/Apache-2.0+BSD-INRIA
new file mode 100644
index 000000000..0f80cdb0b
--- /dev/null
+++ b/nbbuild/licenses/Apache-2.0+BSD-INRIA
@@ -0,0 +1,231 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+*******************************************************************************
+* ASM: a very small and fast Java bytecode manipulation framework
+* Copyright (c) 2000-2011 INRIA, France Telecom
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+* 1. Redistributions of source code must retain the above copyright
+*    notice, this list of conditions and the following disclaimer.
+* 2. Redistributions in binary form must reproduce the above copyright
+*    notice, this list of conditions and the following disclaimer in the
+*    documentation and/or other materials provided with the distribution.
+* 3. Neither the name of the copyright holders nor the names of its
+*    contributors may be used to endorse or promote products derived from
+*    this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+* THE POSSIBILITY OF SUCH DAMAGE.
+*******************************************************************************
diff --git a/nbbuild/licenses/names.properties b/nbbuild/licenses/names.properties
index 2b83358dd..ccd1fe8a9 100644
--- a/nbbuild/licenses/names.properties
+++ b/nbbuild/licenses/names.properties
@@ -39,6 +39,7 @@ EPL-v10-h2=Eclipse Public License v1, h2 variant
 LGPL-2.1=LGPLv2.1 (https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html)
 INRIA=BSD license with INRIA headers
 CDDL-GPL-2-CP=Dual license consisting of the CDDL v1.1 and GPL v2 with Classpath exception
+Apache-2.0+BSD-INRIA=Apache Version 2.0 and BSD license with INRIA copyright
 MIT-jvyamlb=MIT license jvyamlb variant
 HTML5DOC=HTML5DOC license
 MIT-html5-parser=MIT license html5 parser variant
diff --git a/nbbuild/templates/common.xml b/nbbuild/templates/common.xml
index 7ff3e4c36..2872ddbdc 100644
--- a/nbbuild/templates/common.xml
+++ b/nbbuild/templates/common.xml
@@ -534,6 +534,7 @@
                     <pathelement path="${module.run.classpath}"/>
                     <pathelement path="${test.@{test.type}.run.cp.extra}"/>
                     <pathelement path="${test.@{test.type}.cp.extra}"/>
+                    <pathelement path="${test.extra.nb.javac.deps}"/>
                 </path>
                 <!-- path reference used in both compiler and executor -->
                 <propertyset id="test.@{test.type}.properties">
@@ -708,7 +709,7 @@
             <attribute name="test.type"/>
             <attribute name="disable.apple.ui" default="false"/>
             <sequential>
-                <junit showoutput="true" fork="true" failureproperty="tests.failed" errorproperty="tests.failed" filtertrace="${test.filter.trace}" tempdir="${build.test.@{test.type}.results.dir}" timeout="${test.timeout}">
+                <junit showoutput="true" fork="true" failureproperty="tests.failed" errorproperty="tests.failed" filtertrace="${test.filter.trace}" tempdir="${build.test.@{test.type}.results.dir}" timeout="${test.timeout}" jvm="${test.nbjdk.java}">
                     <batchtest todir="${build.test.@{test.type}.results.dir}">
                         <fileset dir="${build.test.@{test.type}.classes.dir}" includes="${test.includes}" excludes="${test.excludes}"/>
                     </batchtest>
@@ -738,7 +739,8 @@
                         outputdir="${build.test.@{test.type}.results.dir}"
                         workingDir="${build.test.@{test.type}.results.dir}"
                         suitename="${code.name.base}"
-			listener="org.testng.reporters.VerboseReporter"
+                        listener="org.testng.reporters.VerboseReporter"
+                        jvm="${test.nbjdk.java}"
                 >
                     <classfileset dir="${build.test.@{test.type}.classes.dir}" excludes="${test.excludes}" includes="${test.includes}"/>
                     <propertyset refid="test.@{test.type}.properties"/>
@@ -807,7 +809,7 @@
         <macrodef name="junit-impl">
             <attribute name="test.type"/>
             <sequential>
-                <junit showoutput="true" fork="true" failureproperty="tests.failed" errorproperty="tests.failed" filtertrace="${test.filter.trace}" tempdir="${build.test.@{test.type}.results.dir}" timeout="${test.timeout}">
+                <junit showoutput="true" fork="true" failureproperty="tests.failed" errorproperty="tests.failed" filtertrace="${test.filter.trace}" tempdir="${build.test.@{test.type}.results.dir}" timeout="${test.timeout}" jvm="${test.nbjdk.java}">
                     <batchtest todir="${build.test.@{test.type}.results.dir}">
                         <fileset dir="${test.@{test.type}.src.dir}" includes="${test.includes}"/>
                     </batchtest>
@@ -838,7 +840,8 @@
                          outputdir="${build.test.@{test.type}.results.dir}"
                          workingDir="${build.test.@{test.type}.results.dir}"
                          suitename="${code.name.base}"
-			 listener="org.testng.reporters.VerboseReporter"
+                         listener="org.testng.reporters.VerboseReporter"
+                         jvm="${test.nbjdk.java}"
                 >
                     <propertyset refid="test.@{test.type}.properties"/>
                     <classpath refid="test.@{test.type}.run.cp"/>
@@ -865,7 +868,8 @@
                          outputdir="${build.test.@{test.type}.results.dir}"
                          workingDir="${build.test.@{test.type}.results.dir}"
                          suitename="${code.name.base}"
-			 listener="org.testng.reporters.VerboseReporter"
+                         listener="org.testng.reporters.VerboseReporter"
+                         jvm="${test.nbjdk.java}"
                 >
                     <propertyset refid="test.@{test.type}.properties"/>
                     <classpath refid="test.@{test.type}.run.cp"/>
@@ -911,7 +915,7 @@
                 <condition property="test.methods.line" value="methods=${test.methods}" else="">
                     <isset property="test.methods"/>
                 </condition>
-                <java fork="true" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner">
+                <java fork="true" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner" jvm="${test.nbjdk.java}">
                     <jvmarg value="-agentlib:jdwp=transport=dt_socket,address=${jpda.address}"/>
                     <jvmarg line="${test.run.args}"/>
                     <classpath>
@@ -945,7 +949,7 @@
                 <!-- TestNG is running in forkMode="once"                  -->
                 <!-- therefore results while debugging single class/method -->
                 <!-- can be different from running all tests at once       -->
-                <java classname="org.testng.TestNG" fork="true">
+                <java classname="org.testng.TestNG" fork="true" jvm="${test.nbjdk.java}">
                     <jvmarg value="-agentlib:jdwp=transport=dt_socket,address=${jpda.address}"/>
                     <jvmarg line="${test.run.args}"/>
                     <jvmarg value="${test.bootclasspath.prepend.args}"/>
@@ -987,7 +991,8 @@
                          outputdir="${build.test.@{test.type}.results.dir}"
                          workingDir="${build.test.@{test.type}.results.dir}"
                          suitename="${code.name.base}"
-			 listener="org.testng.reporters.VerboseReporter"
+                         listener="org.testng.reporters.VerboseReporter"
+                         jvm="${test.nbjdk.java}"
                 >
                     <propertyset refid="test.@{test.type}.properties"/>
                     <classpath refid="test.@{test.type}.run.cp"/>
@@ -1049,7 +1054,7 @@
         <macrodef name="junit-impl">
             <attribute name="test.type"/>
             <sequential>
-                <junit showoutput="true" fork="true" failureproperty="tests.failed" errorproperty="tests.failed" filtertrace="${test.filter.trace}" tempdir="${build.test.@{test.type}.results.dir}" timeout="${test.timeout}">
+                <junit showoutput="true" fork="true" failureproperty="tests.failed" errorproperty="tests.failed" filtertrace="${test.filter.trace}" tempdir="${build.test.@{test.type}.results.dir}" timeout="${test.timeout}" jvm="${test.nbjdk.java}">
                     <test name="${test.class}" methods="${test.methods}" todir="${build.test.@{test.type}.results.dir}"/>
                     <classpath refid="test.@{test.type}.run.cp"/>
                     <syspropertyset refid="test.@{test.type}.properties"/>
@@ -1076,7 +1081,8 @@
                         outputdir="${build.test.@{test.type}.results.dir}"
                         workingDir="${build.test.@{test.type}.results.dir}"
                         suitename="${code.name.base}"
-			listener="org.testng.reporters.VerboseReporter"
+                        listener="org.testng.reporters.VerboseReporter"
+                        jvm="${test.nbjdk.java}"
                 >
                     <propertyset refid="test.@{test.type}.properties"/>
                     <classpath refid="test.@{test.type}.run.cp"/>
@@ -1196,7 +1202,7 @@
                 >
                     <classpath refid="test.@{test.type}.run.cp"/>
                 </nbprofiledirect>
-                <junit showoutput="true" fork="true" failureproperty="tests.failed" errorproperty="tests.failed" filtertrace="${test.filter.trace}" tempdir="${build.test.@{test.type}.results.dir}">
+                <junit showoutput="true" fork="true" failureproperty="tests.failed" errorproperty="tests.failed" filtertrace="${test.filter.trace}" tempdir="${build.test.@{test.type}.results.dir}" jvm="${test.nbjdk.java}">
                     <env key="${profiler.info.pathvar}" path="${profiler.info.agentpath}:${profiler.current.path}"/>
                     <jvmarg value="${profiler.info.jvmargs.agent}"/>
                     <jvmarg line="${profiler.info.jvmargs}"/>
diff --git a/nbbuild/templates/projectized.xml b/nbbuild/templates/projectized.xml
index 3590ddb36..f1849579a 100644
--- a/nbbuild/templates/projectized.xml
+++ b/nbbuild/templates/projectized.xml
@@ -170,30 +170,44 @@ If you are sure you want to build with JDK 9+ anyway, use: -Dpermit.jdk9.builds=
         <property name="locjhindexer.locales" value="${locales}"/>
         <property name="locmakenbm.locales" value="${locales}"/>
         <property name="locmakenbm.brands" value="${brandings}"/>
-        <pathconvert property="retouche.javac.api">
-            <fileset dir="${nb_all}">
-                <include name="libs.javacapi/external/*javac*.jar"/>
-            </fileset>
-        </pathconvert>
-        <pathconvert property="retouche.javac.impl">
-            <fileset dir="${nb_all}">
-                <include name="libs.javacimpl/external/*javac*.jar"/>
-            </fileset>
-            <fileset dir="${nbjdk.home}/../Classes" erroronmissingdir="false">
-                <include name="*.jar"/>
-            </fileset>
-        </pathconvert>
         <!-- When requires.nb.javac property is true, prepend javac-api and javac-impl on bootclasspath to allow override the default annotation
              processing API located in rt.jar. -->
-        <condition property="bootclasspath.prepend" value="${retouche.javac.api}${path.separator}${retouche.javac.impl}">
-            <istrue value="${requires.nb.javac}"/>
+        <property name="bootclasspath.prepend.nb" value="${nb_all}/nbbuild/external/vanilla-javac-api.jar:${nb_all}/nbbuild/external/nb-javac-impl.jar" />
+        <property name="bootclasspath.prepend.vanilla" value="${nb_all}/nbbuild/external/vanilla-javac-api.jar:${nb_all}/nbbuild/external/vanilla-javac-impl.jar" />
+        <condition property="bootclasspath.prepend" value="${bootclasspath.prepend.nb}">
+            <istrue value="${requires.nb.javac.impl}"/>
         </condition>
-        <condition property="run.bootclasspath.prepend" value="${bootclasspath.prepend}">
+        <condition property="bootclasspath.prepend" value="${bootclasspath.prepend.vanilla}">
             <istrue value="${requires.nb.javac}"/>
         </condition>
+        <condition property="run.bootclasspath.prepend" value="${bootclasspath.prepend.nb}">
+            <istrue value="${requires.nb.javac.impl}"/>
+        </condition>
+        <condition property="run.bootclasspath.prepend" value="${bootclasspath.prepend.nb}">
+            <and>
+                <istrue value="${requires.nb.javac}"/>
+                <not>
+                    <istrue value="${test.use.jdk.javac}"/>
+                </not>
+            </and>
+        </condition>
         <condition property="run.bootclasspath.prepend" value="${bootclasspath.prepend}">
-            <isset property="bootclasspath.prepend"/>
+            <and>
+                <isset property="bootclasspath.prepend"/>
+                <not>
+                    <istrue value="${test.use.jdk.javac}"/>
+                </not>
+            </and>
+        </condition>
+        <condition property="test.extra.nb.javac.deps" value="${java.source.nbjavac.dir}/modules/org-netbeans-modules-java-source-nbjavac.jar">
+            <and>
+                <istrue value="${requires.nb.javac}"/>
+                <not>
+                    <istrue value="${test.use.jdk.javac}"/>
+                </not>
+            </and>
         </condition>
+        <property name="test.extra.nb.javac.deps" value="" />
         <fail message="Delete standalone/suite-related metadata from netbeans.org modules">
             <condition>
                 <or>
diff --git a/o.n.bootstrap/src/org/netbeans/ModuleManager.java b/o.n.bootstrap/src/org/netbeans/ModuleManager.java
index b392c97f1..ce91d887d 100644
--- a/o.n.bootstrap/src/org/netbeans/ModuleManager.java
+++ b/o.n.bootstrap/src/org/netbeans/ModuleManager.java
@@ -882,7 +882,7 @@ public ClassLoader refineClassLoader(Module m, List parents) {
         return theHost.getClassLoader();
     }
     
-    private Collection<Module> getAttachedFragments(Module m) {
+    public Collection<Module> getAttachedFragments(Module m) {
         String cdn = m.getCodeNameBase();
         Collection<Module> frags = fragmentModules.get(cdn);
         return frags == null ? Collections.<Module>emptySet() : frags;
diff --git a/profiler.nbimpl/src/org/netbeans/modules/profiler/nbimpl/javac/ElementUtilitiesEx.java b/profiler.nbimpl/src/org/netbeans/modules/profiler/nbimpl/javac/ElementUtilitiesEx.java
index ac51ac207..06ea7517e 100644
--- a/profiler.nbimpl/src/org/netbeans/modules/profiler/nbimpl/javac/ElementUtilitiesEx.java
+++ b/profiler.nbimpl/src/org/netbeans/modules/profiler/nbimpl/javac/ElementUtilitiesEx.java
@@ -19,7 +19,7 @@
 package org.netbeans.modules.profiler.nbimpl.javac;
 
 import com.sun.source.tree.ClassTree;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.util.Collections;
 import java.util.EnumSet;
@@ -191,7 +191,7 @@ private static TypeElement getAnonymousFromSource(FileObject fo, final String cl
                 @Override
                 public void run(final CompilationController cc) throws Exception {
                     cc.toPhase(Phase.RESOLVED);
-                    new TreePathScanner<Void, Void>() {
+                    new ErrorAwareTreePathScanner<Void, Void>() {
 
                         @Override
                         public Void visitClass(ClassTree node, Void p) {
diff --git a/profiler.nbimpl/src/org/netbeans/modules/profiler/nbimpl/javac/JavacClassInfo.java b/profiler.nbimpl/src/org/netbeans/modules/profiler/nbimpl/javac/JavacClassInfo.java
index fe4e8f8fa..0998b64a1 100644
--- a/profiler.nbimpl/src/org/netbeans/modules/profiler/nbimpl/javac/JavacClassInfo.java
+++ b/profiler.nbimpl/src/org/netbeans/modules/profiler/nbimpl/javac/JavacClassInfo.java
@@ -19,7 +19,7 @@
 package org.netbeans.modules.profiler.nbimpl.javac;
 
 import com.sun.source.tree.ClassTree;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.lang.ref.Reference;
 import java.lang.ref.SoftReference;
@@ -348,7 +348,7 @@ private void addAnonymousInnerClasses(final CompilationController cc, final Set<
 
         cc.toPhase(JavaSource.Phase.RESOLVED);
 
-        TreePathScanner<Void, Void> scanner = new TreePathScanner<Void, Void>() {
+        ErrorAwareTreePathScanner<Void, Void> scanner = new ErrorAwareTreePathScanner<Void, Void>() {
 
             @Override
             public Void visitClass(ClassTree node, Void v) {
diff --git a/profiler.nbimpl/src/org/netbeans/modules/profiler/nbimpl/providers/JavaProfilerSourceImpl.java b/profiler.nbimpl/src/org/netbeans/modules/profiler/nbimpl/providers/JavaProfilerSourceImpl.java
index e0dfb6d84..21524a96c 100644
--- a/profiler.nbimpl/src/org/netbeans/modules/profiler/nbimpl/providers/JavaProfilerSourceImpl.java
+++ b/profiler.nbimpl/src/org/netbeans/modules/profiler/nbimpl/providers/JavaProfilerSourceImpl.java
@@ -26,7 +26,7 @@
 import com.sun.source.tree.Scope;
 import com.sun.source.tree.Tree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.io.IOException;
 import java.util.ArrayList;
@@ -194,7 +194,7 @@ public void run(final CompilationController cc)
                         return;
                     }
 
-                    TreePathScanner<Void, Void> scanner = new TreePathScanner<Void, Void>() {
+                    ErrorAwareTreePathScanner<Void, Void> scanner = new ErrorAwareTreePathScanner<Void, Void>() {
 
                         public Void visitMethod(MethodTree node, Void p) {
                             Void retValue;
@@ -241,7 +241,7 @@ public void run(final CompilationController cc)
                         return;
                     }
 
-                    TreePathScanner<Void, Void> scanner = new TreePathScanner<Void, Void>() {
+                    ErrorAwareTreePathScanner<Void, Void> scanner = new ErrorAwareTreePathScanner<Void, Void>() {
 
                         @Override
                         public Void visitClass(ClassTree node, Void param) {
@@ -295,7 +295,7 @@ public void cancel() {
                 public void run(final CompilationController controller) throws Exception {
                     controller.toPhase(Phase.ELEMENTS_RESOLVED);
 
-                    TreePathScanner<Void, Void> scanner = new TreePathScanner<Void, Void>() {
+                    ErrorAwareTreePathScanner<Void, Void> scanner = new ErrorAwareTreePathScanner<Void, Void>() {
 
                         @Override
                         public Void visitAnnotation(AnnotationTree annTree, Void p) {
@@ -632,7 +632,7 @@ public void cancel() {
                     public void run(final CompilationController cc) throws Exception {
                         cc.toPhase(Phase.ELEMENTS_RESOLVED);
 
-                        TreePathScanner<Void, Void> scanner = new TreePathScanner<Void, Void>() {
+                        ErrorAwareTreePathScanner<Void, Void> scanner = new ErrorAwareTreePathScanner<Void, Void>() {
                             @Override
                             public Void visitMethod(MethodTree node, Void p) {
                                 Element e = cc.getTrees().getElement(getCurrentPath());
diff --git a/profiler.projectsupport/nbproject/project.properties b/profiler.projectsupport/nbproject/project.properties
index 352701bad..1918eaab5 100644
--- a/profiler.projectsupport/nbproject/project.properties
+++ b/profiler.projectsupport/nbproject/project.properties
@@ -17,3 +17,4 @@
 is.autoload=true
 javac.compilerargs=-Xlint -Xlint:-serial
 javac.source=1.6
+requires.nb.javac=true
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/api/JavaRefactoringUtils.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/api/JavaRefactoringUtils.java
index 701652586..49ce5a053 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/api/JavaRefactoringUtils.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/api/JavaRefactoringUtils.java
@@ -21,7 +21,7 @@
 import com.sun.source.tree.MemberSelectTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -297,7 +297,7 @@ public static ClasspathInfo getClasspathInfoFor(FileObject ... files) {
         return scanner.usages;
     }
 
-    private static final class InvocationScanner extends TreePathScanner <Tree, ElementHandle> implements CancellableTask <CompilationController> {
+    private static final class InvocationScanner extends ErrorAwareTreePathScanner <Tree, ElementHandle> implements CancellableTask <CompilationController> {
         private CompilationController cc;
         private final ElementHandle toFind;
         InvocationScanner (ElementHandle toFind) {
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/callhierarchy/CallHierarchyTasks.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/callhierarchy/CallHierarchyTasks.java
index 6b20bd32d..3c4027fb0 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/callhierarchy/CallHierarchyTasks.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/callhierarchy/CallHierarchyTasks.java
@@ -22,7 +22,7 @@
 import com.sun.source.tree.*;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.awt.EventQueue;
 import java.io.IOException;
 import java.lang.annotation.Annotation;
@@ -530,7 +530,7 @@ public void run(CompilationController javac) throws Exception {
         
     }
     
-    private static final class CalleeScanner extends TreePathScanner<Void, Void> {
+    private static final class CalleeScanner extends ErrorAwareTreePathScanner<Void, Void> {
         private final CompilationInfo   javac;
         /** map of all executables and their occurrences in the method body */
         private Map<Element, OccurrencesDesc> refs = new HashMap<Element, OccurrencesDesc>();
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/ChangeParametersPlugin.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/ChangeParametersPlugin.java
index 671bf7df6..a0f78b225 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/ChangeParametersPlugin.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/ChangeParametersPlugin.java
@@ -21,7 +21,7 @@
 import com.sun.source.tree.TypeParameterTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.IOException;
 import java.text.MessageFormat;
 import java.util.*;
@@ -506,7 +506,7 @@ Problem duplicateLocalName(Problem p, ParameterInfo[] paramTable, int index, Exe
             String name = paramTable[index].getName();
             int originalIndex = paramTable[index].getOriginalIndex();
             final VariableElement parameterElement = originalIndex == -1 ? null : method.getParameters().get(originalIndex);
-            TreeScanner<Boolean, String> scanner = new TreeScanner<Boolean, String>() {
+            ErrorAwareTreeScanner<Boolean, String> scanner = new ErrorAwareTreeScanner<Boolean, String>() {
 
                 @Override
                 public Boolean visitVariable(VariableTree vt, String p) {
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/ChangeParamsTransformer.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/ChangeParamsTransformer.java
index 89f1cdf8d..19a5e846c 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/ChangeParamsTransformer.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/ChangeParamsTransformer.java
@@ -41,7 +41,7 @@
 import com.sun.source.tree.*;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import java.io.IOException;
 import java.util.*;
@@ -788,7 +788,7 @@ private BlockTree translateBody(BlockTree blockTree,  final List<? extends Varia
         do {
             original2Translated.clear();
             if(renameParams) {
-                TreeScanner<Void, Void> idScan = new TreeScanner<Void, Void>() {
+                ErrorAwareTreeScanner<Void, Void> idScan = new ErrorAwareTreeScanner<Void, Void>() {
                     @Override
                     public Void visitIdentifier(IdentifierTree node, Void p) {
                         String name = node.getName().toString();
@@ -808,7 +808,7 @@ public Void visitIdentifier(IdentifierTree node, Void p) {
                 blockTree = (BlockTree) workingCopy.getTreeUtilities().translate(blockTree, original2Translated);
             }
             original2Translated.clear();
-            TreeScanner<Boolean, ExecutableElement> methodScanner = new TreeScanner<Boolean, ExecutableElement>() {
+            ErrorAwareTreeScanner<Boolean, ExecutableElement> methodScanner = new ErrorAwareTreeScanner<Boolean, ExecutableElement>() {
                 @Override
                 public Boolean visitMethodInvocation(MethodInvocationTree node, ExecutableElement p) {
                     boolean changed = false;
@@ -847,7 +847,7 @@ private ExpressionTree translateExpression(ExpressionTree expressionTree, final
         boolean changed = false;
         do {
             original2Translated.clear();
-            TreeScanner<Void, Void> idScan = new TreeScanner<Void, Void>() {
+            ErrorAwareTreeScanner<Void, Void> idScan = new ErrorAwareTreeScanner<Void, Void>() {
                 @Override
                 public Void visitIdentifier(IdentifierTree node, Void p) {
                     String name = node.getName().toString();
@@ -866,7 +866,7 @@ public Void visitIdentifier(IdentifierTree node, Void p) {
             expressionTree = (ExpressionTree) workingCopy.getTreeUtilities().translate(expressionTree, original2Translated);
             
             original2Translated.clear();
-            TreeScanner<Boolean, ExecutableElement> methodScanner = new TreeScanner<Boolean, ExecutableElement>() {
+            ErrorAwareTreeScanner<Boolean, ExecutableElement> methodScanner = new ErrorAwareTreeScanner<Boolean, ExecutableElement>() {
                 @Override
                 public Boolean visitMethodInvocation(MethodInvocationTree node, ExecutableElement p) {
                     boolean changed = false;
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/ExtractSuperclassRefactoringPlugin.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/ExtractSuperclassRefactoringPlugin.java
index 12feeb250..f09cec19a 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/ExtractSuperclassRefactoringPlugin.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/ExtractSuperclassRefactoringPlugin.java
@@ -20,7 +20,7 @@
 
 import com.sun.source.tree.*;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import java.io.IOException;
 import java.util.*;
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindUsagesVisitor.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindUsagesVisitor.java
index e19228733..051530f1b 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindUsagesVisitor.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindUsagesVisitor.java
@@ -21,7 +21,7 @@
 import com.sun.source.tree.*;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.io.IOException;
 import java.util.*;
@@ -51,7 +51,7 @@
  *
  * @author Jan Becicka
  */
-public class FindUsagesVisitor extends TreePathScanner<Tree, Element> {
+public class FindUsagesVisitor extends ErrorAwareTreePathScanner<Tree, Element> {
 
     private Collection<TreePath> usages = new ArrayList<>();
     private List<WhereUsedElement> elements = new ArrayList<>();
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindVisitor.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindVisitor.java
index 7ad5efffd..43c080db9 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindVisitor.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindVisitor.java
@@ -21,7 +21,7 @@
 
 import com.sun.source.tree.Tree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -36,7 +36,7 @@
  *
  * @author Jan Becicka
  */
-public class FindVisitor extends TreePathScanner<Tree, Element> {
+public class FindVisitor extends ErrorAwareTreePathScanner<Tree, Element> {
 
     private Collection<TreePath> usages = new ArrayList<TreePath>();
     
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/InlineMethodTransformer.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/InlineMethodTransformer.java
index 349b55b62..df11b173e 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/InlineMethodTransformer.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/InlineMethodTransformer.java
@@ -33,6 +33,8 @@
 import org.netbeans.api.java.source.GeneratorUtilities;
 import org.netbeans.api.java.source.TreePathHandle;
 import org.netbeans.api.java.source.TreeUtilities;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import org.netbeans.modules.refactoring.api.Problem;
 import org.netbeans.modules.refactoring.java.api.JavaRefactoringUtils;
 import org.netbeans.modules.refactoring.java.spi.RefactoringVisitor;
@@ -221,7 +223,7 @@ public Tree visitMethodInvocation(MethodInvocationTree node, Element methodEleme
             body = (BlockTree) treeUtilities.translate(body, original2TranslatedBody);
             
             final Boolean[] multiplereturn = {null};
-            new TreeScanner<Void, Void>() {
+            new ErrorAwareTreeScanner<Void, Void>() {
 
                 @Override
                 public Void scan(Tree node, Void p) {
@@ -409,7 +411,7 @@ private Tree fixReferences(Tree tree, TreePath treePath, final ExecutableElement
         final ElementUtilities elementUtilities = workingCopy.getElementUtilities();
         final TypeElement bodyEnclosingTypeElement = elementUtilities.enclosingTypeElement(method);
 
-        TreePathScanner<Void, ExecutableElement> idScan = new TreePathScanner<Void, ExecutableElement>() {
+        ErrorAwareTreePathScanner<Void, ExecutableElement> idScan = new ErrorAwareTreePathScanner<Void, ExecutableElement>() {
             @Override
             public Void visitIdentifier(IdentifierTree node, ExecutableElement p) {
                 TreePath currentPath = getCurrentPath();
@@ -538,7 +540,7 @@ private void scanForNameClash(final TreePath methodInvocationPath, final Tree bo
         final CompilationUnitTree compilationUnitTree = workingCopy.getTrees().getPath(resolved).getCompilationUnit();
         final LinkedList<Pair<Element, String>> renames = new LinkedList<>();
         // Scan the body and look for name clashes
-        TreeScanner<Void, ExecutableElement> nameClashScanner = new TreeScanner<Void, ExecutableElement>() {
+        ErrorAwareTreeScanner<Void, ExecutableElement> nameClashScanner = new ErrorAwareTreeScanner<Void, ExecutableElement>() {
             @Override
             public Void visitVariable(VariableTree node, ExecutableElement p) {
                 TreePath path = trees.getPath(compilationUnitTree, node);
@@ -591,7 +593,7 @@ private void checkParameter(Tree node) {
             
         };
         nameClashScanner.scan(body, (ExecutableElement) p);
-        TreeScanner<Void, Pair<Element, String>> idScan = new TreeScanner<Void, Pair<Element, String>>() {
+        ErrorAwareTreeScanner<Void, Pair<Element, String>> idScan = new ErrorAwareTreeScanner<Void, Pair<Element, String>>() {
             @Override
             public Void visitIdentifier(IdentifierTree node, Pair<Element, String> p) {
                 TreePath path = trees.getPath(compilationUnitTree, node);
@@ -631,7 +633,7 @@ private void replaceParametersWithArguments(final HashMap<Tree, Tree> original2T
         final CompilationUnitTree compilationUnitTree = workingCopy.getTrees().getPath(resolved).getCompilationUnit();
         final LinkedList<Pair<Element, String>> renames = new LinkedList<>();
         
-        TreeScanner<Void, Pair<VariableElement, ExpressionTree>> idScan = new TreeScanner<Void, Pair<VariableElement, ExpressionTree>>() {
+        ErrorAwareTreeScanner<Void, Pair<VariableElement, ExpressionTree>> idScan = new ErrorAwareTreeScanner<Void, Pair<VariableElement, ExpressionTree>>() {
             @Override
             public Void visitIdentifier(IdentifierTree node, Pair<VariableElement, ExpressionTree> p) {
                 TreePath currentPath = trees.getPath(compilationUnitTree, node);
@@ -689,7 +691,7 @@ public Void visitIdentifier(IdentifierTree node, Pair<VariableElement, Expressio
             }
         }
 
-        TreeScanner<Void, Pair<Element, String>> renameScan = new TreeScanner<Void, Pair<Element, String>>() {
+        ErrorAwareTreeScanner<Void, Pair<Element, String>> renameScan = new ErrorAwareTreeScanner<Void, Pair<Element, String>>() {
             @Override
             public Void visitIdentifier(IdentifierTree node, Pair<Element, String> p) {
                 TreePath path = trees.getPath(compilationUnitTree, node);
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/InlineRefactoringPlugin.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/InlineRefactoringPlugin.java
index 19629da3d..6bc3f8ace 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/InlineRefactoringPlugin.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/InlineRefactoringPlugin.java
@@ -20,7 +20,7 @@
 
 import com.sun.source.tree.*;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import java.io.IOException;
 import java.util.*;
@@ -250,7 +250,7 @@ protected Problem preCheck(CompilationController javac) throws IOException {
                 if (initializer.getKind().equals(Tree.Kind.METHOD_INVOCATION)) {
                     skipFirstMethodInvocation++;
                 }
-                TreeScanner<Boolean, Boolean> scanner = new UnsafeTreeScanner(skipFirstMethodInvocation);
+                ErrorAwareTreeScanner<Boolean, Boolean> scanner = new UnsafeTreeScanner(skipFirstMethodInvocation);
                 Boolean isChanged = scanner.scan(initializer, false);
                 if (isChanged != null && isChanged) {
                     preCheckProblem = createProblem(preCheckProblem, false, WRN_InlineChange()); //NOI18N
@@ -542,7 +542,7 @@ private Element asElement(TreePath treePath) {
         }
     }
 
-    private static class UnsafeTreeScanner extends TreeScanner<Boolean, Boolean> {
+    private static class UnsafeTreeScanner extends ErrorAwareTreeScanner<Boolean, Boolean> {
 
         private int skipFirstMethodInvocation;
 
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/IntroduceParameterPlugin.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/IntroduceParameterPlugin.java
index 8e542e322..140b02903 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/IntroduceParameterPlugin.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/IntroduceParameterPlugin.java
@@ -21,7 +21,7 @@
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.*;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.IOException;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -92,7 +92,7 @@ Problem duplicateLocalName(Problem p, ParameterInfo[] paramTable, int index, Exe
                 String name = paramTable[index].getName();
                 int originalIndex = paramTable[index].getOriginalIndex();
                 final VariableElement parameterElement = originalIndex == -1 ? null : method.getParameters().get(originalIndex);
-                TreeScanner<Boolean, String> scanner = new TreeScanner<Boolean, String>() {
+                ErrorAwareTreeScanner<Boolean, String> scanner = new ErrorAwareTreeScanner<Boolean, String>() {
                
                     @Override
                     public Boolean visitVariable(VariableTree vt, String p) {
@@ -330,7 +330,7 @@ public void run(WorkingCopy workingCopy) throws Exception {
     private Set<TreePath> computeDuplicates(final WorkingCopy workingCopy, TreePath resolved, TreePath meth) {
         Set<TreePath> ret = SourceUtils.computeDuplicates(workingCopy, resolved, meth, new AtomicBoolean());
 //        final Set<TreePath> ret = new HashSet<TreePath>();
-//        TreePathScanner<Void, Element> scanner = new TreePathScanner<Void, Element>() {
+//        ErrorAwareTreePathScanner<Void, Element> scanner = new ErrorAwareTreePathScanner<Void, Element>() {
 //
 //            @Override
 //            public Void visitIdentifier(IdentifierTree node, Element p) {
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/InvertBooleanRefactoringPlugin.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/InvertBooleanRefactoringPlugin.java
index e5fd53b08..a8e855d1a 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/InvertBooleanRefactoringPlugin.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/InvertBooleanRefactoringPlugin.java
@@ -22,7 +22,7 @@
 import com.sun.source.tree.*;
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -259,7 +259,7 @@ public void run(final WorkingCopy parameter) throws Exception {
                         format.setRightBrace("}$");
                         final String mthFormat = format.format(MTH_INIT);
 
-                        new TreePathScanner<Void, Void>() {
+                        new ErrorAwareTreePathScanner<Void, Void>() {
                             @Override public Void visitReturn(ReturnTree node, Void p) {
                                 TransformationSupport.create(mthFormat).setCancel(cancel).transformTreePath(parameter, getCurrentPath());
                                 return super.visitReturn(node, p);
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/LocalVarScanner.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/LocalVarScanner.java
index 6b747bbff..ce9d8aeda 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/LocalVarScanner.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/LocalVarScanner.java
@@ -32,7 +32,7 @@
 import com.sun.source.tree.TryTree;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.tree.WhileLoopTree;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import javax.lang.model.element.Element;
 import javax.lang.model.element.ElementKind;
 import org.netbeans.api.java.source.CompilationInfo;
@@ -41,7 +41,7 @@
  *
  * @author Jan Becicka
  */
-public class LocalVarScanner extends TreePathScanner<Boolean, Element> {
+public class LocalVarScanner extends ErrorAwareTreePathScanner<Boolean, Element> {
 
     private CompilationInfo info;
     private String newName;
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/MoveClassTransformer.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/MoveClassTransformer.java
index a9e53a0e2..a295abf19 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/MoveClassTransformer.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/MoveClassTransformer.java
@@ -20,7 +20,7 @@
 
 import com.sun.source.tree.*;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.File;
 import java.io.IOException;
 import java.net.URISyntaxException;
@@ -172,7 +172,7 @@ public Tree visitClass(ClassTree node, Element p) {
                     ClassTree classTree = (ClassTree) workingCopy.getTrees().getTree(resolved);
                     ClassTree origTree = get.importComments(classTree, workingCopy.getTrees().getPath(resolved).getCompilationUnit());
                     final Map<Tree, Tree> org2trans = new HashMap<Tree, Tree>();
-                    TreeScanner<Object, Element> scanner= new TreeScanner<Object, Element>() {
+                    ErrorAwareTreeScanner<Object, Element> scanner= new ErrorAwareTreeScanner<Object, Element>() {
 
                         @Override
                         public Object visitIdentifier(IdentifierTree node, Element p) {
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/MoveMembersTransformer.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/MoveMembersTransformer.java
index a129e2a7e..3965f1528 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/MoveMembersTransformer.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/MoveMembersTransformer.java
@@ -23,7 +23,7 @@
 import com.sun.source.tree.*;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import java.util.*;
 import java.util.logging.Level;
@@ -377,7 +377,7 @@ public boolean accept(Element e, TypeMirror type) { // Type will always be null
                 arguments.remove(removedIndex);
             }
             TypeMirror sourceType = workingCopy.getTrees().getTypeMirror(enclosingClassPath);
-            TreeScanner<Boolean, TypeMirror> needsArgumentScanner = new TreeScanner<Boolean, TypeMirror>() {
+            ErrorAwareTreeScanner<Boolean, TypeMirror> needsArgumentScanner = new ErrorAwareTreeScanner<Boolean, TypeMirror>() {
                 // Logic is a copy from #insertIfMatch
 
                 @Override
@@ -549,7 +549,7 @@ private void insertIfMatch(TreePath currentPath, ClassTree node, final Element t
                     final TreePath bodyPath = new TreePath(resolvedPath, body);
                     final Trees trees = workingCopy.getTrees();
                     final Map<ExpressionTree, ExpressionTree> fqns = new HashMap<ExpressionTree, ExpressionTree>();
-                    TreeScanner<Void, Void> fqnScan = new TreeScanner<Void, Void>() {
+                    ErrorAwareTreeScanner<Void, Void> fqnScan = new ErrorAwareTreeScanner<Void, Void>() {
 
                         @Override
                         public Void visitIdentifier(IdentifierTree node, Void p) {
@@ -573,7 +573,7 @@ public Void visitIdentifier(IdentifierTree node, Void p) {
                     TreePath sourceClass = JavaRefactoringUtils.findEnclosingClass(workingCopy, resolvedPath, true, true, true, true, true);
                     TypeMirror sourceType = workingCopy.getTrees().getTypeMirror(sourceClass);
                     final String parameterName = getParameterName(sourceType, workingCopy.getTrees().getScope(bodyPath), workingCopy);
-                    TreeScanner<Boolean, TypeMirror> idScan = new TreeScanner<Boolean, TypeMirror>() {
+                    ErrorAwareTreeScanner<Boolean, TypeMirror> idScan = new ErrorAwareTreeScanner<Boolean, TypeMirror>() {
 
                         @Override
                         public Boolean visitMemberSelect(MemberSelectTree node, TypeMirror source) {
@@ -646,7 +646,7 @@ public Boolean reduce(Boolean r1, Boolean r2) {
                     boolean addParameter = idScan.scan(body, sourceType) == Boolean.TRUE;
 
                     if (removedParameter != null) {
-                        TreeScanner<Void, Pair<Element, ExpressionTree>> idScan2 = new TreeScanner<Void, Pair<Element, ExpressionTree>>() {
+                        ErrorAwareTreeScanner<Void, Pair<Element, ExpressionTree>> idScan2 = new ErrorAwareTreeScanner<Void, Pair<Element, ExpressionTree>>() {
 
                             @Override
                             public Void visitIdentifier(IdentifierTree node, Pair<Element, ExpressionTree> p) {
@@ -950,7 +950,7 @@ private ModifiersTree changeModifiers(ModifiersTree modifiersTree, boolean usage
         final Map<Tree, Tree> original2Translated = new HashMap<Tree, Tree>();
         
         // TODO Change this to something like that is used for method body; importFqns
-        TreeScanner<Void, Void> idScan = new TreeScanner<Void, Void>() {
+        ErrorAwareTreeScanner<Void, Void> idScan = new ErrorAwareTreeScanner<Void, Void>() {
             @Override
             public Void visitIdentifier(IdentifierTree node, Void p) {
                 TreePath currentPath = new TreePath(resolvedPath, node);
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/PullUpTransformer.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/PullUpTransformer.java
index e2fc5069e..5af5c2af0 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/PullUpTransformer.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/PullUpTransformer.java
@@ -20,7 +20,7 @@
 
 import com.sun.source.tree.*;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import java.util.EnumSet;
 import java.util.HashMap;
@@ -318,7 +318,7 @@ static ModifiersTree removeAnnotations(WorkingCopy workingCopy, TreeMaker make,M
         final Types types = workingCopy.getTypes();
 
         final Map<IdentifierTree, Tree> original2Translated = new HashMap<IdentifierTree, Tree>();
-        TreeScanner<Void, Void> scanner = new TreeScanner<Void, Void>() {
+        ErrorAwareTreeScanner<Void, Void> scanner = new ErrorAwareTreeScanner<Void, Void>() {
 
             @Override
             public Void visitIdentifier(IdentifierTree node, Void p) {
@@ -359,7 +359,7 @@ public Void visitIdentifier(IdentifierTree node, Void p) {
     private BlockTree updateSuperThisReferences(BlockTree body, final TreePath mpath) {
         final Map<ExpressionTree, ExpressionTree> original2Translated = new HashMap<ExpressionTree, ExpressionTree>();
         final Trees trees = workingCopy.getTrees();
-        TreeScanner<Boolean, Void> idScan = new TreeScanner<Boolean, Void>() {
+        ErrorAwareTreeScanner<Boolean, Void> idScan = new ErrorAwareTreeScanner<Boolean, Void>() {
             @Override
             public Boolean visitMemberSelect(MemberSelectTree node, Void nothing) {
                 String isThis = node.getExpression().toString();
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/PushDownTransformer.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/PushDownTransformer.java
index 5becaef00..89c261ace 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/PushDownTransformer.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/PushDownTransformer.java
@@ -21,7 +21,7 @@
 
 import com.sun.source.tree.*;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.util.ArrayList;
 import java.util.Deque;
@@ -376,7 +376,7 @@ void fixVisibility(final Element el) {
             return;
         }
         
-        new TreePathScanner() {
+        new ErrorAwareTreePathScanner() {
 
             @Override
             public Object visitIdentifier(IdentifierTree node, Object p) {
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/RenameRefactoringPlugin.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/RenameRefactoringPlugin.java
index fa4ae503c..d0e7123a3 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/RenameRefactoringPlugin.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/RenameRefactoringPlugin.java
@@ -23,7 +23,7 @@
 import com.sun.source.tree.Tree;
 import com.sun.source.util.DocTrees;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.IOException;
 import java.text.MessageFormat;
 import java.util.*;
@@ -187,7 +187,7 @@ private String clashes(TreePath path, final String newName, CompilationInfo info
                 parent = parent.getParentPath();
             }
             final String[] result = new String[1];
-            new TreeScanner<Void, Void>() {
+            new ErrorAwareTreeScanner<Void, Void>() {
                 
                 @Override
                 public Void visitLabeledStatement(LabeledStatementTree tree, Void p) {
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/RenameTransformer.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/RenameTransformer.java
index 58426ac67..d502eec2e 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/RenameTransformer.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/RenameTransformer.java
@@ -26,7 +26,7 @@
 import com.sun.source.util.DocTreePath;
 import com.sun.source.util.DocTrees;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -606,7 +606,7 @@ private void rewriteAllInComment(final String text, final int offset, final Stri
     }
 
     private boolean duplicateDeclaration() {
-        TreeScanner<Boolean, String> duplicateIds = new TreeScanner<Boolean, String>() {
+        ErrorAwareTreeScanner<Boolean, String> duplicateIds = new ErrorAwareTreeScanner<Boolean, String>() {
             @Override public Boolean visitClass(ClassTree node, String p) {
                 if(node.getSimpleName().contentEquals(p)) {
                     return Boolean.TRUE;
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/spi/RefactoringVisitor.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/spi/RefactoringVisitor.java
index b18c02452..52a109ff4 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/spi/RefactoringVisitor.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/spi/RefactoringVisitor.java
@@ -57,7 +57,7 @@
 import com.sun.source.util.DocTreePath;
 import com.sun.source.util.DocTreePathScanner;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import javax.lang.model.element.Element;
 import org.netbeans.api.annotations.common.CheckForNull;
@@ -73,7 +73,7 @@
  *
  * @author Jan Becicka
  */
-public class RefactoringVisitor extends TreePathScanner<Tree, Element> implements DocTreeVisitor<DocTree, Element> {
+public class RefactoringVisitor extends ErrorAwareTreePathScanner<Tree, Element> implements DocTreeVisitor<DocTree, Element> {
     /**
      * 
      */
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/InstantRefactoringUIImpl.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/InstantRefactoringUIImpl.java
index 3ec7594e4..bd9056908 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/InstantRefactoringUIImpl.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/InstantRefactoringUIImpl.java
@@ -30,7 +30,7 @@
 import com.sun.source.util.DocTreePath;
 import com.sun.source.util.DocTrees;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -430,7 +430,7 @@ public AbstractRefactoring getRefactoring() {
                         }
                     }
                     final Name label = ((LabeledStatementTree)labeledStatement.getLeaf()).getLabel();
-                    new TreePathScanner <Void, Void>() {
+                    new ErrorAwareTreePathScanner <Void, Void>() {
                         @Override
                         public Void visitBreak(BreakTree node, Void p) {
                             if (node.getLabel() != null && label.contentEquals(node.getLabel())) {
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/MoveMembersPanel.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/MoveMembersPanel.java
index efa47fadd..1f51162e8 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/MoveMembersPanel.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/MoveMembersPanel.java
@@ -21,7 +21,7 @@
 import com.sun.source.tree.*;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.awt.*;
 import java.awt.event.*;
@@ -1088,7 +1088,7 @@ private Boolean isSelected(Element e, CompilationInfo info) {
         }
     }
 
-    private static class PositionVisitor extends TreePathScanner<Void, Map<Element, Long>> {
+    private static class PositionVisitor extends ErrorAwareTreePathScanner<Void, Map<Element, Long>> {
 
         private final Trees trees;
         private final SourcePositions sourcePositions;
diff --git a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/RenamePanel.java b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/RenamePanel.java
index 70aa0a918..7deb97f5a 100644
--- a/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/RenamePanel.java
+++ b/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/RenamePanel.java
@@ -19,7 +19,7 @@
 package org.netbeans.modules.refactoring.java.ui;
 import com.sun.source.tree.ClassTree;
 import com.sun.source.tree.Tree;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.awt.Component;
 import java.awt.event.ItemEvent;
 import java.io.IOException;
@@ -190,7 +190,7 @@ public void foundLocation(FileObject fo, LocationResult location) {
         initialized = true;
     }
 
-    private class TestClassMethodsVisitor extends TreePathScanner<Void, Void> {
+    private class TestClassMethodsVisitor extends ErrorAwareTreePathScanner<Void, Void> {
 
 	private CompilationInfo info;
 	private List<ExecutableElement> testClassMethods;
diff --git a/refactoring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/RefactoringTestBase.java b/refactoring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/RefactoringTestBase.java
index e239034e6..062889d36 100644
--- a/refactoring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/RefactoringTestBase.java
+++ b/refactoring.java/test/unit/src/org/netbeans/modules/refactoring/java/test/RefactoringTestBase.java
@@ -321,7 +321,7 @@ public String getSourceLevel(FileObject javaFile) {
         Main.initializeURLFactory();
         org.netbeans.api.project.ui.OpenProjects.getDefault().getOpenProjects();
         
-        org.netbeans.modules.java.source.TreeLoader.DISABLE_CONFINEMENT_TEST = true;
+//        org.netbeans.modules.java.source.TreeLoader.DISABLE_CONFINEMENT_TEST = true;
         
         prepareTest();
         org.netbeans.api.project.ui.OpenProjects.getDefault().open(new Project[] {prj = ProjectManager.getDefault().findProject(src.getParent())}, false);
diff --git a/spellchecker.bindings.java/nbproject/project.properties b/spellchecker.bindings.java/nbproject/project.properties
index c30688029..e13a23ab5 100644
--- a/spellchecker.bindings.java/nbproject/project.properties
+++ b/spellchecker.bindings.java/nbproject/project.properties
@@ -38,3 +38,4 @@ test.unit.run.cp.extra=\
     ${netbeans.dest.dir}/ide8/modules/ext/jmi.jar:\
 
 test.config.stableBTD.includes=**/*Test.class
+requires.nb.javac=true
diff --git a/spellchecker.bindings.java/src/org/netbeans/modules/spellchecker/bindings/java/JavaSemanticTokenList.java b/spellchecker.bindings.java/src/org/netbeans/modules/spellchecker/bindings/java/JavaSemanticTokenList.java
index 09862b081..bff189ff4 100644
--- a/spellchecker.bindings.java/src/org/netbeans/modules/spellchecker/bindings/java/JavaSemanticTokenList.java
+++ b/spellchecker.bindings.java/src/org/netbeans/modules/spellchecker/bindings/java/JavaSemanticTokenList.java
@@ -21,7 +21,7 @@
 import com.sun.source.tree.ClassTree;
 import com.sun.source.tree.MethodTree;
 import com.sun.source.tree.VariableTree;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
@@ -159,7 +159,7 @@ public void run(CompilationInfo parameter) throws Exception {
             l.set(pos, parameter.getDocument());
         }
         
-        private static final class ScannerImpl extends TreeScanner<Void, List<Position[]>> {
+        private static final class ScannerImpl extends ErrorAwareTreeScanner<Void, List<Position[]>> {
             private Document doc;
             private CompilationInfo info;
 
diff --git a/spi.java.hints/external/binaries-list b/spi.java.hints/external/binaries-list
new file mode 100644
index 000000000..8e5c10cfc
--- /dev/null
+++ b/spi.java.hints/external/binaries-list
@@ -0,0 +1,17 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+51218A01A882C04D0ABA8C028179CCE488BBCB58 net.bytebuddy:byte-buddy:1.7.9
diff --git a/spi.java.hints/external/byte-buddy-1.7.9-license.txt b/spi.java.hints/external/byte-buddy-1.7.9-license.txt
new file mode 100644
index 000000000..5e7835628
--- /dev/null
+++ b/spi.java.hints/external/byte-buddy-1.7.9-license.txt
@@ -0,0 +1,238 @@
+Name: Byte Buddy
+Version: 1.7.9
+Description: Code Generation Library
+License: Apache-2.0+BSD-INRIA
+Origin: Byte Buddy
+URL: https://github.com/raphw/byte-buddy
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+
+*******************************************************************************
+* ASM: a very small and fast Java bytecode manipulation framework
+* Copyright (c) 2000-2011 INRIA, France Telecom
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions
+* are met:
+* 1. Redistributions of source code must retain the above copyright
+*    notice, this list of conditions and the following disclaimer.
+* 2. Redistributions in binary form must reproduce the above copyright
+*    notice, this list of conditions and the following disclaimer in the
+*    documentation and/or other materials provided with the distribution.
+* 3. Neither the name of the copyright holders nor the names of its
+*    contributors may be used to endorse or promote products derived from
+*    this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+* THE POSSIBILITY OF SUCH DAMAGE.
+*******************************************************************************
diff --git a/spi.java.hints/nbproject/project.properties b/spi.java.hints/nbproject/project.properties
index 0692391ec..5abf6e1df 100644
--- a/spi.java.hints/nbproject/project.properties
+++ b/spi.java.hints/nbproject/project.properties
@@ -21,3 +21,4 @@ spec.version.base=1.30.0
 requires.nb.javac=true
 javadoc.arch=${basedir}/arch.xml
 javadoc.apichanges=${basedir}/apichanges.xml
+release.external/byte-buddy-1.7.9.jar=modules/ext/byte-buddy-1.7.9.jar
diff --git a/spi.java.hints/nbproject/project.xml b/spi.java.hints/nbproject/project.xml
index ec8dab248..9cf7dba6d 100644
--- a/spi.java.hints/nbproject/project.xml
+++ b/spi.java.hints/nbproject/project.xml
@@ -341,7 +341,9 @@
                     <code-name-base>org.openide.loaders</code-name-base>
                     <build-prerequisite/>
                     <compile-dependency/>
-                    <run-dependency><specification-version>7.61</specification-version></run-dependency>
+                    <run-dependency>
+                        <specification-version>7.61</specification-version>
+                    </run-dependency>
                 </dependency>
                 <dependency>
                     <code-name-base>org.openide.modules</code-name-base>
@@ -368,7 +370,7 @@
                     </run-dependency>
                 </dependency>
                 <dependency>
-                    <code-name-base>org.openide.util.ui</code-name-base>
+                    <code-name-base>org.openide.util</code-name-base>
                     <build-prerequisite/>
                     <compile-dependency/>
                     <run-dependency>
@@ -376,19 +378,19 @@
                     </run-dependency>
                 </dependency>
                 <dependency>
-                    <code-name-base>org.openide.util</code-name-base>
+                    <code-name-base>org.openide.util.lookup</code-name-base>
                     <build-prerequisite/>
                     <compile-dependency/>
                     <run-dependency>
-                        <specification-version>9.3</specification-version>
+                        <specification-version>8.0</specification-version>
                     </run-dependency>
                 </dependency>
                 <dependency>
-                    <code-name-base>org.openide.util.lookup</code-name-base>
+                    <code-name-base>org.openide.util.ui</code-name-base>
                     <build-prerequisite/>
                     <compile-dependency/>
                     <run-dependency>
-                        <specification-version>8.0</specification-version>
+                        <specification-version>9.3</specification-version>
                     </run-dependency>
                 </dependency>
                 <dependency>
@@ -511,6 +513,10 @@
                 <package>org.netbeans.spi.java.hints.matching</package>
                 <package>org.netbeans.spi.java.hints.support</package>
             </public-packages>
+            <class-path-extension>
+                <runtime-relative-path>ext/byte-buddy-1.7.9.jar</runtime-relative-path>
+                <binary-origin>external/byte-buddy-1.7.9.jar</binary-origin>
+            </class-path-extension>
         </data>
     </configuration>
 </project>
diff --git a/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/Hacks.java b/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/Hacks.java
index a315d01f6..bf8ccf904 100644
--- a/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/Hacks.java
+++ b/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/Hacks.java
@@ -25,7 +25,7 @@
 import com.sun.source.tree.Scope;
 import com.sun.source.tree.Tree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.tools.javac.api.JavacTaskImpl;
 import com.sun.tools.javac.code.Symbol.ClassSymbol;
 import com.sun.tools.javac.comp.AttrContext;
@@ -36,13 +36,18 @@
 import com.sun.tools.javac.tree.JCTree.JCErroneous;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.Log;
+
 import java.io.File;
 import java.io.IOException;
+import java.util.Collections;
+
 import javax.lang.model.element.Element;
 import javax.lang.model.element.TypeElement;
 import javax.lang.model.element.VariableElement;
 import javax.lang.model.type.TypeMirror;
 import javax.tools.JavaFileObject;
+
+import com.sun.tools.javac.parser.ParserFactory;
 import org.netbeans.api.annotations.common.CheckForNull;
 import org.netbeans.api.annotations.common.NonNull;
 import org.netbeans.api.java.source.CompilationInfo;
@@ -83,26 +88,21 @@ public static Scope constructScope(CompilationInfo info, String... importedClass
         Log.instance(context).nerrors = 0;
 
         JavaFileObject jfo = FileObjects.memoryFileObject("$$", "$", new File("/tmp/t.java").toURI(), System.currentTimeMillis(), clazz.toString());
-        boolean oldSkipAPs = jc.skipAnnotationProcessing;
 
         try {
-            jc.skipAnnotationProcessing = true;
-
-            Iterable<? extends CompilationUnitTree> parsed = jti.parse(jfo);
-            CompilationUnitTree cut = parsed.iterator().next();
+            CompilationUnitTree cut = ParserFactory.instance(context).newParser(jfo.getCharContent(true), true, true, true).parseCompilationUnit();
 
-            jti.analyze(jti.enter(parsed));
+            jti.analyze(jti.enter(Collections.singletonList(cut)));
 
             return new ScannerImpl().scan(cut, info);
         } catch (IOException ex) {
             Exceptions.printStackTrace(ex);
             return null;
         } finally {
-            jc.skipAnnotationProcessing = oldSkipAPs;
         }
     }
 
-    private static final class ScannerImpl extends TreePathScanner<Scope, CompilationInfo> {
+    private static final class ScannerImpl extends ErrorAwareTreePathScanner<Scope, CompilationInfo> {
 
         @Override
         public Scope visitBlock(BlockTree node, CompilationInfo p) {
diff --git a/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/JackpotTrees.java b/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/JackpotTrees.java
index 3133887f5..fdbee7e97 100644
--- a/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/JackpotTrees.java
+++ b/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/JackpotTrees.java
@@ -20,6 +20,7 @@
 package org.netbeans.modules.java.hints.spiimpl;
 
 import com.sun.source.tree.IdentifierTree;
+import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.TreeVisitor;
 import com.sun.tools.javac.code.Symbol.VarSymbol;
 import com.sun.tools.javac.code.Symtab;
@@ -28,12 +29,29 @@
 import com.sun.tools.javac.tree.JCTree.JCBlock;
 import com.sun.tools.javac.tree.JCTree.JCCase;
 import com.sun.tools.javac.tree.JCTree.JCCatch;
+import com.sun.tools.javac.tree.JCTree.JCErroneous;
+import com.sun.tools.javac.tree.JCTree.JCIdent;
 import com.sun.tools.javac.tree.JCTree.JCModifiers;
 import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
+import com.sun.tools.javac.tree.JCTree.Visitor;
 import com.sun.tools.javac.tree.TreeMaker;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.List;
 import com.sun.tools.javac.util.Name;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import net.bytebuddy.ByteBuddy;
+import net.bytebuddy.description.modifier.Visibility;
+import net.bytebuddy.implementation.FieldAccessor;
+import net.bytebuddy.implementation.FixedValue;
+import net.bytebuddy.implementation.MethodCall;
+import net.bytebuddy.matcher.ElementMatchers;
 
 
 /**
@@ -41,6 +59,65 @@
  * @author lahvac
  */
 public class JackpotTrees {
+
+    private static final Map<Class<?>, Class<?>> baseClass2Impl = new HashMap<>();
+    public static <T> T createInstance(Context ctx, Class<T> clazz, Name ident, JCIdent jcIdent, Class<?>[] requiredConstructor, Object[] params) {
+        try {
+            Class<?> fake = baseClass2Impl.get(clazz);
+
+            if (fake == null) {
+                Method visitIdent = Visitor.class.getDeclaredMethod("visitIdent", JCIdent.class);
+                Method visitIdentifier = TreeVisitor.class.getDeclaredMethod("visitIdentifier", IdentifierTree.class, Object.class);
+                Method toString = Object.class.getDeclaredMethod("toString");
+                fake = new ByteBuddy()
+                        .subclass(clazz)
+                        .implement(IdentifierTree.class)
+                        .defineField("ident", Name.class, Visibility.PUBLIC)
+                        .defineField("jcIdent", JCIdent.class, Visibility.PUBLIC)
+                        .method(ElementMatchers.named("getName")).intercept(FieldAccessor.ofField("ident"))
+                        .method(ElementMatchers.named("getKind")).intercept(FixedValue.value(Kind.IDENTIFIER))
+                        .method(ElementMatchers.named("accept").and(ElementMatchers.takesArguments(Visitor.class))).intercept(MethodCall.invoke(visitIdent).onArgument(0).withField("jcIdent"))
+                        .method(ElementMatchers.named("accept").and(ElementMatchers.takesArgument(0, TreeVisitor.class))).intercept(MethodCall.invoke(visitIdentifier).onArgument(0).withThis().withArgument(1))
+                        .method(ElementMatchers.named("toString")).intercept(MethodCall.invoke(toString).onField("ident"))
+                        .make()
+                        .load(JackpotTrees.class.getClassLoader())
+                        .getLoaded();
+                baseClass2Impl.put(clazz, fake);
+            }
+
+            NEXT: for (Constructor c : fake.getDeclaredConstructors()) {
+                if (c.getParameterCount() < requiredConstructor.length)
+                    continue;
+                for (int e = 0; e < requiredConstructor.length; e++) {
+                    if (!c.getParameterTypes()[e].equals(requiredConstructor[e])) {
+                        continue NEXT;
+                    }
+                }
+                java.util.List<Object> instances = new ArrayList<>();
+                instances.addAll(Arrays.asList(params));
+                for (int i = instances.size(); i < c.getParameterCount(); i++) {
+                    instances.add(null);
+                }
+
+                JCTree tree = (JCTree) c.newInstance(instances.toArray(new Object[0]));
+
+                Field identField = fake.getDeclaredField("ident");
+
+                identField.set(tree, ident);
+
+                Field jcIdentField = fake.getDeclaredField("jcIdent");
+
+                jcIdentField.set(tree, jcIdent);
+
+                return clazz.cast(tree);
+            }
+
+            throw new IllegalStateException();
+        } catch (IllegalAccessException | IllegalArgumentException | IllegalStateException | InstantiationException | NoSuchFieldException | NoSuchMethodException | SecurityException | InvocationTargetException ex) {
+            throw new IllegalStateException(ex);
+        }
+    }
+
     public static class AnnotationWildcard extends JCAnnotation implements IdentifierTree {
 
         private final Name ident;
diff --git a/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/Utilities.java b/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/Utilities.java
index 819152a85..ca5c2714e 100644
--- a/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/Utilities.java
+++ b/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/Utilities.java
@@ -44,8 +44,8 @@
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.source.util.Trees;
 import com.sun.tools.javac.api.JavacScope;
 import com.sun.tools.javac.api.JavacTaskImpl;
@@ -59,6 +59,7 @@
 import com.sun.tools.javac.comp.AttrContext;
 import com.sun.tools.javac.comp.Enter;
 import com.sun.tools.javac.comp.Env;
+import com.sun.tools.javac.comp.Modules;
 import com.sun.tools.javac.comp.Todo;
 import com.sun.tools.javac.main.JavaCompiler;
 import com.sun.tools.javac.parser.JavacParser;
@@ -93,6 +94,7 @@
 import java.io.IOException;
 import java.lang.ref.Reference;
 import java.lang.ref.WeakReference;
+import java.lang.reflect.Field;
 import java.net.URI;
 import java.nio.CharBuffer;
 import java.util.Arrays;
@@ -109,6 +111,8 @@
 import java.util.Map.Entry;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import javax.lang.model.element.AnnotationMirror;
 import javax.lang.model.element.AnnotationValue;
 import javax.lang.model.element.AnnotationValueVisitor;
@@ -441,7 +445,7 @@ private static Tree parseAndAttribute(CompilationInfo info, JavacTaskImpl jti, S
                     CompilationUnitTree cut = ((JavacScope) scope).getEnv().toplevel;
                     final boolean[] found = new boolean[1];
 
-                    new TreePathScanner<Void, Void>() {
+                    new ErrorAwareTreePathScanner<Void, Void>() {
                         @Override public Void visitMemberSelect(MemberSelectTree node, Void p) {
                             Element currentElement = trees.getElement(getCurrentPath());
 
@@ -546,7 +550,7 @@ private static boolean isErrorTree(Tree t) {
     }
     
     private static boolean containsError(Tree t) {
-        return new TreeScanner<Boolean, Void>() {
+        return new ErrorAwareTreeScanner<Boolean, Void>() {
             @Override
             public Boolean scan(Tree node, Void p) {
                 if (node != null && isErrorTree(node)) {
@@ -635,10 +639,10 @@ public void report(JCDiagnostic diag) {
         };
         NBResolve resolve = NBResolve.instance(jti.getContext());
         resolve.disableAccessibilityChecks();
-        Enter enter = Enter.instance(jti.getContext());
-        enter.shadowTypeEnvs(true);
-        ArgumentAttr argumentAttr = ArgumentAttr.instance(jti.getContext());
-        ArgumentAttr.LocalCacheContext cacheContext = argumentAttr.withLocalCacheContext();
+//        Enter enter = Enter.instance(jti.getContext());
+//        enter.shadowTypeEnvs(true);
+//        ArgumentAttr argumentAttr = ArgumentAttr.instance(jti.getContext());
+//        ArgumentAttr.LocalCacheContext cacheContext = argumentAttr.withLocalCacheContext();
         try {
             Attr attr = Attr.instance(jti.getContext());
             Env<AttrContext> env = ((JavacScope) scope).getEnv();
@@ -646,11 +650,11 @@ public void report(JCDiagnostic diag) {
                 return attr.attribExpr((JCTree) tree,env, Type.noType);
             return attr.attribStat((JCTree) tree,env);
         } finally {
-            cacheContext.leave();
+//            cacheContext.leave();
             log.useSource(prev);
             log.popDiagnosticHandler(discardHandler);
             resolve.restoreAccessbilityChecks();
-            enter.shadowTypeEnvs(false);
+//            enter.shadowTypeEnvs(false);
         }
     }
 
@@ -732,6 +736,7 @@ public static Scope constructScope(CompilationInfo info, Map<String, TypeMirror>
         JavacTaskImpl jti = JavaSourceAccessor.getINSTANCE().getJavacTask(info);
         Context context = jti.getContext();
         JavaCompiler compiler = JavaCompiler.instance(context);
+        Modules modules = Modules.instance(context);
         Log log = Log.instance(context);
         NBResolve resolve = NBResolve.instance(context);
         Annotate annotate = Annotate.instance(context);
@@ -739,18 +744,24 @@ public static Scope constructScope(CompilationInfo info, Map<String, TypeMirror>
 
         JavaFileObject jfo = FileObjects.memoryFileObject("$", "$", new File("/tmp/$" + count + ".java").toURI(), System.currentTimeMillis(), clazz.toString());
 
-        boolean oldSkipAPs = compiler.skipAnnotationProcessing;
-
         try {
-            compiler.skipAnnotationProcessing = true;
             resolve.disableAccessibilityChecks();
             if (compiler.isEnterDone()) {
                 annotate.blockAnnotations();
-                compiler.resetEnterDone();
+//                try {
+//                    Field f = compiler.getClass().getDeclaredField("enterDone");
+//                    f.setAccessible(true);
+//                    f.set(compiler, false);
+//                } catch (Throwable t) {
+//                    Logger.getLogger(Utilities.class.getName()).log(Level.FINE, null, t);
+//                }
+                //was:
+//                compiler.resetEnterDone();
             }
             
             JCCompilationUnit cut = compiler.parse(jfo);
-            compiler.enterTrees(compiler.initModules(com.sun.tools.javac.util.List.of(cut)));
+            modules.enter(com.sun.tools.javac.util.List.of(cut), null);
+            compiler.enterTrees(com.sun.tools.javac.util.List.of(cut));
 
             Todo todo = compiler.todo;
             ListBuffer<Env<AttrContext>> defer = new ListBuffer<Env<AttrContext>>();
@@ -774,11 +785,10 @@ public static Scope constructScope(CompilationInfo info, Map<String, TypeMirror>
         } finally {
             resolve.restoreAccessbilityChecks();
             log.popDiagnosticHandler(discardHandler);
-            compiler.skipAnnotationProcessing = oldSkipAPs;
         }
     }
 
-    private static final class ScannerImpl extends TreePathScanner<Scope, CompilationInfo> {
+    private static final class ScannerImpl extends ErrorAwareTreePathScanner<Scope, CompilationInfo> {
 
         @Override
         public Scope visitBlock(BlockTree node, CompilationInfo p) {
@@ -1075,7 +1085,7 @@ public void propertyChange(PropertyChangeEvent evt) {
         }
     }
     
-    private static final class GeneralizePattern extends TreePathScanner<Void, Void> {
+    private static final class GeneralizePattern extends ErrorAwareTreePathScanner<Void, Void> {
 
         public final Map<Tree, Tree> tree2Variable = new HashMap<Tree, Tree>();
         private final Map<Element, String> element2Variable = new HashMap<Element, String>();
@@ -1214,7 +1224,7 @@ public void setPackage(ExpressionTree packageNameTree) {}
     }
 
     public static long patternValue(Tree pattern) {
-        class VisitorImpl extends TreeScanner<Void, Void> {
+        class VisitorImpl extends ErrorAwareTreeScanner<Void, Void> {
             private int value;
             @Override
             public Void scan(Tree node, Void p) {
diff --git a/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/pm/NFABasedBulkSearch.java b/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/pm/NFABasedBulkSearch.java
index f198a6190..034c8d8a8 100644
--- a/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/pm/NFABasedBulkSearch.java
+++ b/spi.java.hints/src/org/netbeans/modules/java/hints/spiimpl/pm/NFABasedBulkSearch.java
@@ -32,7 +32,6 @@
 import com.sun.source.tree.Tree.Kind;
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
diff --git a/spi.java.hints/src/org/netbeans/spi/java/hints/JavaFixUtilities.java b/spi.java.hints/src/org/netbeans/spi/java/hints/JavaFixUtilities.java
index b7f54a470..a177e3846 100644
--- a/spi.java.hints/src/org/netbeans/spi/java/hints/JavaFixUtilities.java
+++ b/spi.java.hints/src/org/netbeans/spi/java/hints/JavaFixUtilities.java
@@ -57,8 +57,8 @@
 import com.sun.source.tree.WhileLoopTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -522,7 +522,7 @@ protected void performRewrite(TransformationContext ctx) {
 
             final Set<Tree> originalTrees = Collections.newSetFromMap(new IdentityHashMap<Tree, Boolean>());
             
-            new TreeScanner<Void, Void>() {
+            new ErrorAwareTreeScanner<Void, Void>() {
                 @Override public Void scan(Tree tree, Void p) {
                     originalTrees.add(tree);
                     return super.scan(tree, p);
@@ -580,7 +580,7 @@ public boolean equals(Object obj) {
 
     private static final Set<Kind> NUMBER_LITERAL_KINDS = EnumSet.of(Kind.FLOAT_LITERAL, Kind.DOUBLE_LITERAL, Kind.INT_LITERAL, Kind.LONG_LITERAL);
 
-    private static class ReplaceParameters extends TreePathScanner<Number, Void> {
+    private static class ReplaceParameters extends ErrorAwareTreePathScanner<Number, Void> {
 
         private final CompilationInfo info;
         private final TreeMaker make;
diff --git a/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/TestBase.java b/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/TestBase.java
index 260ae44cf..e57c86a0c 100644
--- a/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/TestBase.java
+++ b/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/TestBase.java
@@ -28,10 +28,10 @@
 import org.netbeans.api.java.source.JavaSource;
 import org.netbeans.api.java.source.JavaSource.Phase;
 import org.netbeans.api.java.source.SourceUtilsTestUtil;
+import org.netbeans.api.java.source.SourceUtilsTestUtil2;
 import org.netbeans.api.java.source.TestUtilities;
 import org.netbeans.api.lexer.Language;
 import org.netbeans.junit.NbTestCase;
-import org.netbeans.modules.java.source.TreeLoader;
 import org.openide.cookies.EditorCookie;
 import org.openide.filesystems.FileObject;
 import org.openide.filesystems.FileUtil;
@@ -51,7 +51,7 @@ public TestBase(String name) {
     protected void setUp() throws Exception {
         super.setUp();
         SourceUtilsTestUtil.prepareTest(new String[0], new Object[0]);
-        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
+        SourceUtilsTestUtil2.disableConfinementTest();
         clearWorkDir();
 
         FileUtil.refreshFor(File.listRoots());
diff --git a/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/UtilitiesTest.java b/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/UtilitiesTest.java
index 74e31a4f2..edd29558d 100644
--- a/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/UtilitiesTest.java
+++ b/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/UtilitiesTest.java
@@ -30,7 +30,7 @@
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreeScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreeScanner;
 import com.sun.tools.javac.tree.JCTree;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -623,7 +623,7 @@ private void assertDiagnostics(Collection<Diagnostic<? extends JavaFileObject>>
     private void assertPositions(Tree t, final SourcePositions sp, final String code, String... golden) {
         final List<String> actual = new ArrayList<String>(golden.length);
 
-        new TreeScanner<Void, Void>() {
+        new ErrorAwareTreeScanner<Void, Void>() {
             @Override
             public Void scan(Tree node, Void p) {
                 if (node != null) {
diff --git a/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/pm/BulkSearchTestPerformer.java b/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/pm/BulkSearchTestPerformer.java
index b7754c2b1..ac281117e 100644
--- a/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/pm/BulkSearchTestPerformer.java
+++ b/spi.java.hints/test/unit/src/org/netbeans/modules/java/hints/spiimpl/pm/BulkSearchTestPerformer.java
@@ -51,12 +51,12 @@
 import org.netbeans.api.java.source.TreePathHandle;
 import org.netbeans.api.lexer.Language;
 import org.netbeans.junit.NbTestCase;
-import org.netbeans.modules.java.source.TreeLoader;
 import org.openide.cookies.EditorCookie;
 import org.openide.filesystems.FileObject;
 import org.openide.filesystems.FileUtil;
 import org.openide.loaders.DataObject;
 import static org.junit.Assert.*;
+import org.netbeans.api.java.source.SourceUtilsTestUtil2;
 import org.netbeans.junit.RandomlyFails;
 
 /**
@@ -73,7 +73,7 @@ public BulkSearchTestPerformer(String name) {
     protected void setUp() throws Exception {
         super.setUp();
         SourceUtilsTestUtil.prepareTest(new String[] {"org/netbeans/modules/java/editor/resources/layer.xml"}, new Object[0]);
-        TreeLoader.DISABLE_CONFINEMENT_TEST = true;
+        SourceUtilsTestUtil2.disableConfinementTest();
     }
 
 //    public static TestSuite suite() {
diff --git a/spi.java.hints/test/unit/src/org/netbeans/spi/java/hints/matching/CopyFinderTest.java b/spi.java.hints/test/unit/src/org/netbeans/spi/java/hints/matching/CopyFinderTest.java
index e7185bf19..683b47a46 100644
--- a/spi.java.hints/test/unit/src/org/netbeans/spi/java/hints/matching/CopyFinderTest.java
+++ b/spi.java.hints/test/unit/src/org/netbeans/spi/java/hints/matching/CopyFinderTest.java
@@ -24,7 +24,7 @@
 import com.sun.source.tree.VariableTree;
 import com.sun.source.util.SourcePositions;
 import com.sun.source.util.TreePath;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import java.io.File;
 import java.util.Arrays;
 import java.util.Collection;
@@ -1565,7 +1565,7 @@ private void performRemappingTest(String code, String remappableVariables, Optio
 
         for (final String name : remappableVariables.split(",")) {
             if (name.isEmpty()) continue;
-            new TreePathScanner<Object, Object>() {
+            new ErrorAwareTreePathScanner<Object, Object>() {
                 @Override
                 public Object visitVariable(VariableTree node, Object p) {
                     if (node.getName().contentEquals(name)) {
diff --git a/testng.ui/nbproject/project.properties b/testng.ui/nbproject/project.properties
index 7f641b767..375b0888d 100644
--- a/testng.ui/nbproject/project.properties
+++ b/testng.ui/nbproject/project.properties
@@ -17,3 +17,4 @@
 is.eager=true
 javac.source=1.6
 javac.compilerargs=-Xlint -Xlint:-serial
+requires.nb.javac=true
diff --git a/updatecenters/src/org/netbeans/modules/updatecenters/resources/Bundle.properties b/updatecenters/src/org/netbeans/modules/updatecenters/resources/Bundle.properties
index 7f6e4b5de..557f7d304 100644
--- a/updatecenters/src/org/netbeans/modules/updatecenters/resources/Bundle.properties
+++ b/updatecenters/src/org/netbeans/modules/updatecenters/resources/Bundle.properties
@@ -29,6 +29,6 @@ Services/AutoupdateType/pluginportal-update-provider.instance=Plugin Portal
 #NOI18N
 URL_LatestBuild=http://bits.netbeans.org/dev/nbms-and-javadoc/lastSuccessfulBuild/artifact/nbbuild/nbms/updates.xml.gz
 #NOI18N
-URL_Default_N=http://updates.netbeans.org/netbeans/updates/dev/uc/final/main/catalog.xml.gz?{$netbeans.hash.code}
+URL_Default_N=http://lahoda.info/netbeans/nb-javac-auc/updates.xml?{$netbeans.hash.code}
 #NOI18N
 URL_PluginPortal=http://plugins.netbeans.org/nbpluginportal/updates/8.2/catalog.xml.gz
diff --git a/websvc.saas.codegen.java/nbproject/project.properties b/websvc.saas.codegen.java/nbproject/project.properties
index 6de45e155..7fb219817 100644
--- a/websvc.saas.codegen.java/nbproject/project.properties
+++ b/websvc.saas.codegen.java/nbproject/project.properties
@@ -17,3 +17,4 @@
 is.autoload=true
 javac.source=1.6
 javac.compilerargs=-Xlint -Xlint:-serial
+requires.nb.javac=true
diff --git a/whitelist/src/org/netbeans/api/whitelist/support/WhiteListSupport.java b/whitelist/src/org/netbeans/api/whitelist/support/WhiteListSupport.java
index da93a6812..65387c586 100644
--- a/whitelist/src/org/netbeans/api/whitelist/support/WhiteListSupport.java
+++ b/whitelist/src/org/netbeans/api/whitelist/support/WhiteListSupport.java
@@ -26,7 +26,7 @@
 import com.sun.source.tree.MethodTree;
 import com.sun.source.tree.NewClassTree;
 import com.sun.source.tree.Tree;
-import com.sun.source.util.TreePathScanner;
+import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner;
 import com.sun.source.util.Trees;
 import java.util.ArrayDeque;
 import java.util.HashMap;
@@ -92,7 +92,7 @@ private WhiteListSupport() {}
     }
 
     //<editor-fold defaultstate="collapsed" desc="Private implementation">
-    private static class WhiteListScanner extends TreePathScanner<Void, Map<Tree,WhiteListQuery.Result>> {
+    private static class WhiteListScanner extends ErrorAwareTreePathScanner<Void, Map<Tree,WhiteListQuery.Result>> {
 
         private final Trees trees;
         private final Callable<Boolean> cancel;
diff --git a/xml.jaxb/nbproject/project.properties b/xml.jaxb/nbproject/project.properties
index 1dcd75dd4..8f48df164 100644
--- a/xml.jaxb/nbproject/project.properties
+++ b/xml.jaxb/nbproject/project.properties
@@ -28,3 +28,4 @@ disable.qa-functional.tests=true
 
 test.config.stableBTD.includes=**/*Test.class
 test.config.stableBTD.excludes=org/netbeans/test/**/*
+requires.nb.javac=true
diff --git a/xml.tools.java/nbproject/project.properties b/xml.tools.java/nbproject/project.properties
index a25463a58..450b8b08b 100644
--- a/xml.tools.java/nbproject/project.properties
+++ b/xml.tools.java/nbproject/project.properties
@@ -17,3 +17,4 @@
 javac.compilerargs=-Xlint -Xlint:-serial
 disable.qa-functional.tests=true
 javac.source=1.5
+requires.nb.javac=true


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists