You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by jl...@apache.org on 2017/10/04 19:41:19 UTC

[07/13] incubator-netbeans git commit: Work in progress: an experiment on using javac from JDK for source code modeling.

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/usages/ClassNamesForFileOraculumImpl.java
----------------------------------------------------------------------
diff --git a/java.source.base/src/org/netbeans/modules/java/source/usages/ClassNamesForFileOraculumImpl.java b/java.source.base/src/org/netbeans/modules/java/source/usages/ClassNamesForFileOraculumImpl.java
deleted file mode 100644
index 97eb34a..0000000
--- a/java.source.base/src/org/netbeans/modules/java/source/usages/ClassNamesForFileOraculumImpl.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * 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.usages;
-
-import com.sun.tools.javac.api.ClassNamesForFileOraculum;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import javax.tools.JavaFileObject;
-
-/**
- *
- * @author Jan Lahoda
- */
-public class ClassNamesForFileOraculumImpl implements ClassNamesForFileOraculum {
-
-    private final Map<JavaFileObject, List<String>> misplacedSource2FQNs;
-
-    public ClassNamesForFileOraculumImpl(Map<JavaFileObject, List<String>> misplacedSource2FQNs) {
-        this.misplacedSource2FQNs = misplacedSource2FQNs;
-    }
-    
-    public String[] divineClassName(JavaFileObject jfo) {
-        if (misplacedSource2FQNs.isEmpty()) {
-            return null;
-        }
-        
-        List<String> result = misplacedSource2FQNs.get(jfo);
-        
-        if (result != null) {
-            return result.toArray(new String[result.size()]);
-        }
-        
-        return null;
-    }
-
-    public JavaFileObject[] divineSources(String fqn) {
-        if (fqn == null || fqn.length() == 0 || misplacedSource2FQNs.isEmpty()) {
-            return null;
-        }
-
-        fqn += "."; //fqn should always be a package name
-
-        List<JavaFileObject> jfos = new LinkedList<JavaFileObject>();
-        for (Map.Entry<JavaFileObject, List<String>> entry : misplacedSource2FQNs.entrySet()) {
-            for (String s : entry.getValue()) {
-                if (s.startsWith(fqn)) {
-                    if (s.indexOf('.', fqn.length()) == -1) {
-                        jfos.add(entry.getKey());
-                        break;
-                    }
-                }
-            }
-        }
-        
-        return jfos.size() > 0 ? jfos.toArray(new JavaFileObject[jfos.size()]) : null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/src/org/netbeans/modules/java/source/usages/SourceAnalyzerFactory.java
----------------------------------------------------------------------
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 5c24026..f2e05d4 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 @@ public final class SourceAnalyzerFactory {
         }
     }
         
-    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 final class SourceAnalyzerFactory {
                 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;

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/APIIsSelfContainedTest.java
----------------------------------------------------------------------
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 bc87669..6e6ea24 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 @@ public class APIIsSelfContainedTest extends NbTestCase {
         
         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")),
         };
     }
     

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/CommentCollectorTest.java
----------------------------------------------------------------------
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 dd65e03..0cb7cf3 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 class CommentCollectorTest extends NbTestCase {
                 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 class CommentCollectorTest extends NbTestCase {
                 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 class CommentCollectorTest extends NbTestCase {
 
                 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 class CommentCollectorTest extends NbTestCase {
                 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 class CommentCollectorTest extends NbTestCase {
                 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 class CommentCollectorTest extends NbTestCase {
                 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 class CommentCollectorTest extends NbTestCase {
                 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 class CommentCollectorTest extends NbTestCase {
                 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 class CommentCollectorTest extends NbTestCase {
                 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 @@ public class CommentCollectorTest extends NbTestCase {
         }
     }
 
-    private static class CommentPrinter extends TreeScanner<Void, Void> {
+    private static class CommentPrinter extends ErrorAwareTreeScanner<Void, Void> {
         private CommentHandlerService service;
 
         CommentPrinter(CommentHandlerService service) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/ElementHandleTest.java
----------------------------------------------------------------------
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 51fe5c4..4dcbfc4 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.element.VariableElement;
 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 class ElementHandleTest extends NbTestCase {
                     }
                 }
                 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 class ElementHandleTest extends NbTestCase {
                 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 class ElementHandleTest extends NbTestCase {
                 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 class ElementHandleTest extends NbTestCase {
                 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 class ElementHandleTest extends NbTestCase {
                 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 class ElementHandleTest extends NbTestCase {
                 }
                 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 class ElementHandleTest extends NbTestCase {
                 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 class ElementHandleTest extends NbTestCase {
                 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 class ElementHandleTest extends NbTestCase {
 
             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);

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/JavaSourceTest.java
----------------------------------------------------------------------
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 bbe0bcd..58a09a1 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 javax.tools.Diagnostic;
 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 class JavaSourceTest extends NbTestCase {
         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 class JavaSourceTest extends NbTestCase {
         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 class JavaSourceTest extends NbTestCase {
         }
     }
 
-    private static class ScannerImpl extends TreePathScanner<Void, Void> {
+    private static class ScannerImpl extends ErrorAwareTreePathScanner<Void, Void> {
 
         private CompilationInfo info;
 
@@ -2054,7 +2110,7 @@ public class JavaSourceTest extends NbTestCase {
         }
     }
 
-    private static class TransformImpl extends TreeScanner<Void, Object> {
+    private static class TransformImpl extends ErrorAwareTreeScanner<Void, Object> {
 
         private WorkingCopy copy;
 

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/SourceUtilsTestUtil2.java
----------------------------------------------------------------------
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 5b7c957..3c947bc 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 @@ package org.netbeans.api.java.source;
 
 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 @@ public final class 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
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/TreeUtilitiesTest.java
----------------------------------------------------------------------
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 38b2dea..144e672 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
@@ -29,7 +29,7 @@ import com.sun.source.tree.Tree.Kind;
 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.net.URL;
 import java.util.ArrayList;
@@ -490,7 +490,7 @@ public class TreeUtilitiesTest extends NbTestCase {
 
         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 +511,22 @@ public class TreeUtilitiesTest extends NbTestCase {
         }, 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));

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/TypeMirrorHandleTest.java
----------------------------------------------------------------------
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 586bcab..686130a 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 class TypeMirrorHandleTest extends NbTestCase {
 
             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());

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/AnnotationTest.java
----------------------------------------------------------------------
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 a5b66a0..f9ca8a7 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 @@ package org.netbeans.api.java.source.gen;
 
 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 class AnnotationTest extends GeneratorTestBase {
             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 class AnnotationTest extends GeneratorTestBase {
             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 class AnnotationTest extends GeneratorTestBase {
 
                 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 class AnnotationTest extends GeneratorTestBase {
                 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"));

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ArraysTest.java
----------------------------------------------------------------------
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 69f2f68..b75bc9a 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.Tree;
 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 class ArraysTest extends GeneratorTestMDRCompat {
     }
 
     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) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/BlockTest.java
----------------------------------------------------------------------
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 84129aa..a26d341 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 @@ package org.netbeans.api.java.source.gen;
 
 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 class BlockTest extends GeneratorTestMDRCompat {
             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")) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/CommentsTest.java
----------------------------------------------------------------------
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 6fe7aa3..03e8c93 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 @@ package org.netbeans.api.java.source.gen;
 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 class CommentsTest extends GeneratorTestBase {
                 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 class CommentsTest extends GeneratorTestBase {
                 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 class CommentsTest extends GeneratorTestBase {
                 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 class CommentsTest extends GeneratorTestBase {
                 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());

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/CompilationUnitTest.java
----------------------------------------------------------------------
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 5f63928..0b1079b 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 class CompilationUnitTest extends GeneratorTestMDRCompat {
             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 class CompilationUnitTest extends GeneratorTestMDRCompat {
             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()));

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ConstructorTest.java
----------------------------------------------------------------------
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 7987161..e012614 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 @@ package org.netbeans.api.java.source.gen;
 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 class ConstructorTest extends GeneratorTestBase {
                 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 class ConstructorTest extends GeneratorTestBase {
                 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) {

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/DoctreeTest.java
----------------------------------------------------------------------
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 f0101aa..d22b82c 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.ExpressionTree;
 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 class DoctreeTest extends GeneratorTestBase {
             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 class DoctreeTest extends GeneratorTestBase {
             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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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 class DoctreeTest extends GeneratorTestBase {
                 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());

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/EnumTest.java
----------------------------------------------------------------------
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 688c218..f8294f6 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.util.List;
 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 class EnumTest extends GeneratorTestBase {
                 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 class EnumTest extends GeneratorTestBase {
                 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)),

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ForLoopTest.java
----------------------------------------------------------------------
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 47587a5..443f5b3 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 class ForLoopTest extends GeneratorTestMDRCompat {
             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"))

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/GuardedBlockTest.java
----------------------------------------------------------------------
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 66f18eb..9c3458e 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.MethodTree;
 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 class GuardedBlockTest extends GeneratorTestMDRCompat {
                 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 class GuardedBlockTest extends GeneratorTestMDRCompat {
                 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());

http://git-wip-us.apache.org/repos/asf/incubator-netbeans/blob/ffc0de5a/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/LambdaTest.java
----------------------------------------------------------------------
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 d3b756a..47c3480 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.Tree;
 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 class LambdaTest extends GeneratorTestMDRCompat {
                 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 class LambdaTest extends GeneratorTestMDRCompat {
                 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 class LambdaTest extends GeneratorTestMDRCompat {
             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 class LambdaTest extends GeneratorTestMDRCompat {
             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 class LambdaTest extends GeneratorTestMDRCompat {
             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 class LambdaTest extends GeneratorTestMDRCompat {
             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 class LambdaTest extends GeneratorTestMDRCompat {
             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 class LambdaTest extends GeneratorTestMDRCompat {
             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 class LambdaTest extends GeneratorTestMDRCompat {
             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 class LambdaTest extends GeneratorTestMDRCompat {
             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 class LambdaTest extends GeneratorTestMDRCompat {
             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 class LambdaTest extends GeneratorTestMDRCompat {
             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 class LambdaTest extends GeneratorTestMDRCompat {
             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 class LambdaTest extends GeneratorTestMDRCompat {
             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 class LambdaTest extends GeneratorTestMDRCompat {
             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 class LambdaTest extends GeneratorTestMDRCompat {
             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 class LambdaTest extends GeneratorTestMDRCompat {
             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 class LambdaTest extends GeneratorTestMDRCompat {
             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 class LambdaTest extends GeneratorTestMDRCompat {
             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 class LambdaTest extends GeneratorTestMDRCompat {
             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 class LambdaTest extends GeneratorTestMDRCompat {
             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) {