You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've updated from Netbeans 28 to 31 and now I when I use 'find usages' on a (static) method it returns nothing, even when I can see the method is being used in the same class. Searching in the changelog I suspect the submit with hash: 8bd3ab8 might not be working properly, though when closing everything I might be able to use find usages again.
Language / Project Type / NetBeans Component
No response
How to reproduce
After a couple of 'find usage' commands it won't find anything anymore on a static method. Clearing the cache won't help, but after closing every window in Netbeans, closing Netbeans, clearing the cache and starting Netbeans again it works again - briefly.
Did this work correctly in an earlier version?
Apache NetBeans 28
Operating System
Windows 11
JDK
21
Apache NetBeans packaging
Apache NetBeans binary zip
Anything else
My colleague who runs Netbeans 31 on CachyOS experiences the same.
you can remove or replace the artifacts "EnerGQCommon" and "EventRecording" as these are other netbeans projects that I share with other projects. For a while I thought the problem was a wrong java version as the "maven.compiler.release" field was set to 26 instead of the 21 I have installed on my system. It really seems to be occurring when multiple 'usage' tabs are opened
a few more questions:
is the project using the java module system?
You mentioned static methods, does it work fine for everything else or was that a coincidence?
Does anything appear in the log right when you run the find usages action?
6. my guess is that it is likely an indexing issue #4642, #4285
esp since you mentioned that restarting the IDE fixes it. Restart causes the code scanner to refresh in case something changed.
Closing the usages tabs and restarting the IDE fixes it, without closing these tabs the problem remained
7. Can you also confirm whether restricting the search to the current project works ok? Checking if it's the same issue I can reproduce.
Restricting the search to the current project worked! And setting it back to open projects made it reoccur.
-edit- That said, I have a few non-maven projects which can't easily be converted to maven because these depend on some finicky frameworks.
I could reproduce it. Even after IDE restart but had no time to investigate. So i zipped the config and cache to analyze it later. Today I extracted it and it was still reproducible.
Find usages with file scope did work, open-project scope didn't. Problem was that both code paths were the exact same so I used an agent to instrument values on the whole path. 5 runs later the divergence point was found - like in a git bisection I suppose, just with log files and application state.
Fix is a one-liner. Bug age is pre-apache. Haven't really tracked it beyond that. -> #9801
Specific scopes were not the root cause btw, in my reproducer the only scope which worked was current-file. (larger scopes made it more likely though)
generated summary:
Details
Find Usages misses results with the “Open Projects” scope
Symptom
Find Usages in a Maven project returned no results with the Open Projects scope, while Current File seemed to work.
Root cause
SourcePath.FR, the wrapper behind ClasspathInfo’s source path, kept a source root in the search path only if JavaIndex.hasSourceCache(root, true) returned true. This check required both of the following:
The root’s usages index had to be visible through the persistent-only lookup in ClassIndexManager. This lookup ignored transientInstances, where lazily created indices are stored.
The index had to be in State.INITIALIZED. That state is reached only when the background indexer processes the root in the current session and calls CacheAttributesTransaction.commit().
In a fresh session, the on-disk index may already be up to date. The indexer then short-circuits with “New or modified files: 0,” so it does not process the root or promote its index from NEW to INITIALIZED. As a result, the root fails the SourcePath.FR check—even though ClassIndex.createQueriesForRoots, the actual query builder, would query it. The query builder calls ClassIndexManager.getUsagesQuery(root, true), which can see transient indices.
The source root was therefore silently removed from the search path, leaving sources-only scopes with nothing to query.
Why the scopes behaved differently
The issue was caused by the index’s state in the current session, not by the scope itself.
Good state
Bad state
Where the index lives
ClassIndexManager.instances (persistent)
transientInstances (created lazily when the project loads)
Index state
INITIALIZED
NEW
How it happens
The background indexer processes the root—for example, because the index database is missing or rebuilt, a file was edited or created, or a build ran.
The session starts with an up-to-date on-disk index. The indexer reports “New or modified files: 0” and skips processing, so no CacheAttributesTransaction.commit() promotes the index.
Result with the old filter
The root passes the filter.
The root fails the filter and is silently dropped from the search path.
Current File need only the refactored file’s own root, so they appeared to work when that root happened to be in the good state. Open Projects includes roots from other open projects, making it more likely that one of them is in the bad state—and causing that scope to fail first.
In a bad-state session, all scopes are affected. To reproduce this, start the IDE, make no changes to the project, and run Find Usages with Current Project; it also returns no results.
Fix
In SourcePath.FR.getRoots(), use the weaker hasSourceCache(root, false) check. It recognizes usages queries for transiently created indices and does not require State.INITIALIZED, so the filter is consistent with the indices the query builder actually uses.
Activity
mbien commentedon Oct 9, 2026
do you have a project where this can be reproduced?
ezanstraenergq commentedon Oct 9, 2026
It is a maven project and unfortunately I can't share it (it is proprietary); I can give you a slightly edited pom though:
you can remove or replace the artifacts "EnerGQCommon" and "EventRecording" as these are other netbeans projects that I share with other projects. For a while I thought the problem was a wrong java version as the "maven.compiler.release" field was set to 26 instead of the 21 I have installed on my system. It really seems to be occurring when multiple 'usage' tabs are opened
mbien commentedon Oct 9, 2026
a few more questions:
is the project using the java module system?
You mentioned static methods, does it work fine for everything else or was that a coincidence?
Does anything appear in the log right when you run the find usages action?
mbien commentedon Oct 9, 2026
my guess is that it is likely an indexing issue #4642, #4285
esp since you mentioned that restarting the IDE fixes it. Restart causes the code scanner to refresh in case something changed.
neilcsmith-net commentedon Oct 9, 2026
Can you also confirm whether restricting the search to the current project works ok? Checking if it's the same issue I can reproduce.
ezanstraenergq commentedon Oct 12, 2026
Closing the usages tabs and restarting the IDE fixes it, without closing these tabs the problem remained
ezanstraenergq commentedon Oct 12, 2026
Restricting the search to the current project worked! And setting it back to open projects made it reoccur.
-edit- That said, I have a few non-maven projects which can't easily be converted to maven because these depend on some finicky frameworks.
mbien commentedon Nov 13, 2026
I could reproduce it. Even after IDE restart but had no time to investigate. So i zipped the config and cache to analyze it later. Today I extracted it and it was still reproducible.
Find usages with file scope did work, open-project scope didn't. Problem was that both code paths were the exact same so I used an agent to instrument values on the whole path. 5 runs later the divergence point was found - like in a git bisection I suppose, just with log files and application state.
Fix is a one-liner. Bug age is pre-apache. Haven't really tracked it beyond that. -> #9801
Specific scopes were not the root cause btw, in my reproducer the only scope which worked was current-file. (larger scopes made it more likely though)
generated summary:
Details
Find Usages misses results with the “Open Projects” scope
Symptom
Find Usages in a Maven project returned no results with the Open Projects scope, while Current File seemed to work.
Root cause
SourcePath.FR, the wrapper behindClasspathInfo’s source path, kept a source root in the search path only ifJavaIndex.hasSourceCache(root, true)returnedtrue. This check required both of the following:ClassIndexManager. This lookup ignoredtransientInstances, where lazily created indices are stored.State.INITIALIZED. That state is reached only when the background indexer processes the root in the current session and callsCacheAttributesTransaction.commit().In a fresh session, the on-disk index may already be up to date. The indexer then short-circuits with “New or modified files: 0,” so it does not process the root or promote its index from
NEWtoINITIALIZED. As a result, the root fails theSourcePath.FRcheck—even thoughClassIndex.createQueriesForRoots, the actual query builder, would query it. The query builder callsClassIndexManager.getUsagesQuery(root, true), which can see transient indices.The source root was therefore silently removed from the search path, leaving sources-only scopes with nothing to query.
Why the scopes behaved differently
The issue was caused by the index’s state in the current session, not by the scope itself.
ClassIndexManager.instances(persistent)transientInstances(created lazily when the project loads)INITIALIZEDNEWCacheAttributesTransaction.commit()promotes the index.Current File need only the refactored file’s own root, so they appeared to work when that root happened to be in the good state. Open Projects includes roots from other open projects, making it more likely that one of them is in the bad state—and causing that scope to fail first.
In a bad-state session, all scopes are affected. To reproduce this, start the IDE, make no changes to the project, and run Find Usages with Current Project; it also returns no results.
Fix
In
SourcePath.FR.getRoots(), use the weakerhasSourceCache(root, false)check. It recognizes usages queries for transiently created indices and does not requireState.INITIALIZED, so the filter is consistent with the indices the query builder actually uses.