You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by ma...@apache.org on 2021/07/17 20:16:47 UTC
[netbeans] branch master updated: [NETBEANS-5832] Fixing
compilation of static initializer for vanilla indexing.
This is an automated email from the ASF dual-hosted git repository.
matthiasblaesing pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new e871c23 [NETBEANS-5832] Fixing compilation of static initializer for vanilla indexing.
new 8c041d6 Merge pull request #3054 from jlahoda/NETBEANS-5832
e871c23 is described below
commit e871c233d7b587c88d11126e914d63c98c5dfe47
Author: Jan Lahoda <jl...@netbeans.org>
AuthorDate: Thu Jul 15 07:11:25 2021 +0200
[NETBEANS-5832] Fixing compilation of static initializer for vanilla indexing.
---
.../java/source/indexing/VanillaCompileWorker.java | 2 +-
.../source/indexing/VanillaCompileWorkerTest.java | 45 ++++++++++++++++++++++
2 files changed, 46 insertions(+), 1 deletion(-)
diff --git a/java/java.source.base/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorker.java b/java/java.source.base/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorker.java
index b5e7aec..75375bd 100644
--- a/java/java.source.base/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorker.java
+++ b/java/java.source.base/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorker.java
@@ -712,7 +712,7 @@ final class VanillaCompileWorker extends CompileWorker {
csym.members_field.remove(member);
}
}
- if (errorClass || def.hasTag(JCTree.Tag.ERRONEOUS) || def.hasTag(JCTree.Tag.BLOCK)) {
+ if (errorClass || def.hasTag(JCTree.Tag.ERRONEOUS)) {
clazz.defs = com.sun.tools.javac.util.List.filter(clazz.defs, def);
}
}
diff --git a/java/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorkerTest.java b/java/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorkerTest.java
index 276c07f..e3dfc17 100644
--- a/java/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorkerTest.java
+++ b/java/java.source.base/test/unit/src/org/netbeans/modules/java/source/indexing/VanillaCompileWorkerTest.java
@@ -1876,6 +1876,51 @@ public class VanillaCompileWorkerTest extends CompileWorkerTestBase {
assertEquals(expected, file2Fixed);
}
+ public void testStaticInit() throws Exception {
+ Map<String, String> file2Fixed = new HashMap<>();
+ VanillaCompileWorker.fixedListener = (file, cut) -> {
+ try {
+ FileObject source = URLMapper.findFileObject(file.toUri().toURL());
+ file2Fixed.put(FileUtil.getRelativePath(getRoot(), source), cut.toString());
+ } catch (MalformedURLException ex) {
+ throw new IllegalStateException(ex);
+ }
+ };
+ ParsingOutput result = runIndexing(Arrays.asList(compileTuple("test/Test.java",
+ "package test;\n" +
+ "public class Test {\n" +
+ " static {\n" +
+ " System.err.println();\n" +
+ " }\n" +
+ "}\n")),
+ Arrays.asList());
+
+ assertFalse(result.lowMemory);
+ assertTrue(result.success);
+
+ Set<String> createdFiles = new HashSet<String>();
+
+ for (File created : result.createdFiles) {
+ createdFiles.add(getWorkDir().toURI().relativize(created.toURI()).getPath());
+ }
+
+ assertEquals(new HashSet<String>(Arrays.asList("cache/s1/java/15/classes/test/Test.sig")),
+ createdFiles);
+ Map<String, String> expected = Collections.singletonMap("test/Test.java",
+ "package test;\n" +
+ "\n" +
+ "public class Test {\n" +
+ " \n" +
+ " public Test() {\n" +
+ " super();\n" +
+ " }\n" +
+ " static {\n" +
+ " System.err.println();\n" +
+ " }\n" +
+ "}");
+ assertEquals(expected, file2Fixed);
+ }
+
public static void noop() {}
@Override
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists