Netbeans code completion/fix can see some JDK classes but not others
- Dominant language
- Java
- Stars
- 3.1k
- Forks
- 935
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 17
Description
### Apache NetBeans version
Apache NetBeans 23
### What happened
Project is ant/classpath-based (i.e. no modulepath), and this occurs on both Oracle jdk 21.0.5, and Amazon Corretto 21.0.1. M1 based mac on sequoia. I have wiped out my netbeans cache directory and my netbeans config directory (~/Library/Application Support/Netbeans/23) with no effect. I also made sure to tell the mac not to steal the ctrl+space key combo.
As an example, code completion works fine for ArrayList and HashSet, but it can not, under any circumstances find anything in the java.sql package. e.g. type `PreparedS` and then it `ctrl-space` and it just says "No suggestions" or type `PreparedStatement p = null;` and hit `option-enter` or `ctrl-enter` and I get suggestions to create a class called PreparedSatement, but nothing offering to import it. If I go to manually type in `import java.sql.PrepredStatement` it starts giving me suggestions for package and eventually class names. And once the import is in the file, Netbeans will suggest it in subsequent editing.
However, if I start to type in `ArrayList`I sometimes get code completion suggestions, and code fix seems to figure it out.
While this is going on, I see things like this in the log. Although their appearance in the log does not correspond exactly to my attempts to use this feature.
```
INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=CLASS; sigs=com.sun.tools.javac.code.Types$HashCodeVisitor ]
INFO [org.netbeans.api.java.source.ElementHandle]: Resolved type is null for kind = INTERFACE
INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=INTERFACE; sigs=jdk.internal.module.ModuleHashes$HashSupplier ]
INFO [org.netbeans.api.java.source.ElementHandle]: Resolved type is null for kind = CLASS
INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=CLASS; sigs=com.sun.jmx.remote.security.HashedPasswordManager ]
INFO [org.netbeans.api.java.source.ElementHandle]: Resolved type is null for kind = CLASS
INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=CLASS; sigs=jdk.internal.classfile.impl.AbstractPoolEntry ]
INFO [org.netbeans.api.java.source.ElementHandle]: Resolved type is null for kind = CLASS
INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=CLASS; sigs=jdk.internal.module.SystemModuleFinders ]
INFO [org.netbeans.api.java.source.ElementHandle]: Resolved type is null for kind = CLASS
INFO [org.netbeans.api.java.source.ElementHandle]: Cannot resolve: ElementHandle[kind=CLASS; sigs=com.sun.tools.javac.util.Names ]
INFO [org.netbeans.api.java.source.ElementHandle]: Resolved type is null for kind = CLASS
```
### Language / Project Type / NetBeans Component
Java Ant Project, classpath based
### How to reproduce
As an example, code completion works fine for ArrayList and HashSet, can not, under any circumstances find anything in the java.sql package. e.g. type `PreparedS` and then it `ctrl-space` and it just says "No suggestions" or type `PreparedStatement p = null;` and hit `option-enter` or `ctrl-enter` and I get suggestions to create a class called PreparedSatement, but nothing offering to import it. If I go to manually type in `import java.sql.PrepredStatement` it starts giving me suggestions for package and eventually class names. And once the import is in the file, Netbeans will suggest it in subsequent editing.
However, if I start to type in `ArrayList`I sometimes get code completion suggestions, and code fix seems to figure it out.
### Did this work correctly in an earlier version?
No / Don't know
### Operating System
macos 15.0.1 on an M1
### JDK
Oracle JDK 21.0.5, also Amazon Corretto 21.0.1
### Apache NetBeans packaging
Apache NetBeans provided installer
### Anything else
Occurs most, if not all, of the time.
### Are you willing to submit a pull request?
No
Contributor guide
Research direction
Start with the Java Ant classpath project and reproduce completion and code-fix behavior for java.sql.PreparedStatement versus ArrayList. Then trace the code-completion and ElementHandle paths associated with the reported log messages. Done means java.sql classes are suggested and offered for import consistently without the unresolved-element behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- developer-experience, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100