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 2018/02/20 08:36:55 UTC

[GitHub] geertjanw closed pull request #428: Fixing a few problems that happen during indexing using JDK's javac.

geertjanw closed pull request #428: Fixing a few problems that happen during indexing using JDK's javac.
URL: https://github.com/apache/incubator-netbeans/pull/428
 
 
   

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/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
index 9853a5c55..e7e26ffd5 100644
--- 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
@@ -71,7 +71,6 @@
 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;
@@ -414,11 +413,17 @@ public Void visitMethod(MethodTree node, Void p) {
                 } else {
                     mt = (Type.MethodType) msym.type;
                 }
+                clearMethodType(mt);
+                if (msym.erasure_field != null && msym.erasure_field.hasTag(TypeTag.METHOD))
+                    clearMethodType((Type.MethodType) msym.erasure_field);
+                clearAnnotations(decl.sym.getMetadata());
+                return super.visitMethod(node, p);
+            }
+
+            private void clearMethodType(Type.MethodType mt) {
                 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
@@ -431,6 +436,7 @@ public Void visitClass(ClassTree node, Void p) {
                 ct.interfaces_field = error2Object(ct.interfaces_field);
                 ct.typarams_field = error2Object(ct.typarams_field);
                 ct.supertype_field = error2Object(ct.supertype_field);
+                clearAnnotations(clazz.sym.getMetadata());
                 super.visitClass(node, p);
                 for (JCTree def : clazz.defs) {
                     if (def.hasTag(JCTree.Tag.ERRONEOUS)) {
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
index 2ef999369..753247788 100644
--- 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
@@ -86,7 +86,7 @@ public void testRepair1() throws Exception {
     }
 
     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() { } }")),
+        ParsingOutput result = runIndexing(Arrays.asList(compileTuple("test/Test4.java", "package test; @Undef public class Test4 { @Undef public void test1() { } @Deprecated @Undef public void test2() { } }")),
                                            Arrays.asList());
 
         assertFalse(result.lowMemory);
@@ -173,6 +173,24 @@ public void testRepairWildcard() throws Exception {
         //TODO: check file content!!!
     }
 
+    public void testErasureField() throws Exception {
+        ParsingOutput result = runIndexing(Arrays.asList(compileTuple("test/Test4.java", "package test; public class Test4<T> { void test(Test4<Undef> t2, Undef t1) { } static void t(Test4 raw) { raw.test(null, null); } }")),
+                                           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");
 


 

----------------------------------------------------------------
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