This is an automated email from the ASF dual-hosted git repository.

neilcsmith pushed a commit to branch delivery
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/delivery by this push:
     new 36a9b160de [NETBEANS-6599] Do not throw a CompletionFailure for empty 
java.lang package outside of java.base.
     new 8dd9867e1a Merge pull request #6629 from lahodaj/NETBEANS-6599
36a9b160de is described below

commit 36a9b160decfad0ff6d9cfa1b9b6f950dbcf16d4
Author: Jan Lahoda <jan.lah...@oracle.com>
AuthorDate: Thu Oct 26 22:47:11 2023 +0200

    [NETBEANS-6599] Do not throw a CompletionFailure for empty java.lang 
package outside of java.base.
---
 .../src/org/netbeans/lib/nbjavac/services/NBClassFinder.java     | 5 +++++
 .../src/org/netbeans/lib/nbjavac/services/NBClassFinderTest.java | 9 +++++++++
 2 files changed, 14 insertions(+)

diff --git 
a/java/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassFinder.java 
b/java/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassFinder.java
index 11f67b3769..7e91e79cbb 100644
--- a/java/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassFinder.java
+++ b/java/lib.nbjavac/src/org/netbeans/lib/nbjavac/services/NBClassFinder.java
@@ -24,6 +24,8 @@ import com.sun.tools.javac.code.Kinds.Kind;
 import com.sun.tools.javac.code.Symbol;
 import com.sun.tools.javac.code.Symbol.Completer;
 import com.sun.tools.javac.code.Symbol.CompletionFailure;
+import com.sun.tools.javac.code.Symbol.PackageSymbol;
+import com.sun.tools.javac.code.Symtab;
 import com.sun.tools.javac.util.Context;
 import com.sun.tools.javac.util.JCDiagnostic;
 import com.sun.tools.javac.util.JCDiagnostic.DiagnosticInfo;
@@ -54,6 +56,7 @@ public class NBClassFinder extends ClassFinder {
 
     private final Context context;
     private final Names names;
+    private final Symtab syms;
     private final JCDiagnostic.Factory diagFactory;
     private final Log log;
 
@@ -61,6 +64,7 @@ public class NBClassFinder extends ClassFinder {
         super(context);
         this.context = context;
         this.names = Names.instance(context);
+        this.syms = Symtab.instance(context);
         this.diagFactory = JCDiagnostic.Factory.instance(context);
         this.log = Log.instance(context);
     }
@@ -95,6 +99,7 @@ public class NBClassFinder extends ClassFinder {
                     delegate.complete(sym);
                     if (sym.kind == Kind.PCK &&
                         sym.flatName() == names.java_lang &&
+                        ((PackageSymbol) sym).modle == syms.java_base &&
                         sym.members().isEmpty()) {
                         sym.flags_field |= Flags.EXISTS;
                         try {
diff --git 
a/java/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/NBClassFinderTest.java
 
b/java/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/NBClassFinderTest.java
index 9e3df9b140..1181762d0e 100644
--- 
a/java/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/NBClassFinderTest.java
+++ 
b/java/lib.nbjavac/test/unit/src/org/netbeans/lib/nbjavac/services/NBClassFinderTest.java
@@ -69,6 +69,15 @@ public class NBClassFinderTest extends NbTestCase {
         assertEquals(expectedErrors, actualErrors);
     }
 
+    public void testEmptyClassPath2() throws Exception {
+        String code = "package java.lang.nb.test; public class Test { String 
t(String s) { return s.toString(); } }";
+        List<String> expectedErrors;
+        expectedErrors = Arrays.asList("");
+        List<String> actualErrors;
+        actualErrors = compile(code, "-XDrawDiagnostics", "-XDide", 
"-Xlint:-options");
+        assertEquals(expectedErrors, actualErrors);
+    }
+
     private static class MyFileObject extends SimpleJavaFileObject {
         private String text;
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

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

Reply via email to