Open herkrath opened 6 months ago
I think I have identified the trigger: Besides our main multi-module project, I had another project open, being the Lucene demo (https://github.com/apache/lucene/tree/main/lucene/demo). The above error (and similar ones) happened always when the Lucene demo was open during "Find Usages" of certain methods of the main project. "Find Usages" worked fine always when the Lucene demo got closed. Note that there are no dependencies from or to the Lucene demo. It is fully reproducible with NB 21 and 22rc1 and multiple iterations opening and closing again.
As I guess that NetBeans is using Lucene during "Find Usages" as well, I could imagine that things may get messed up by different class versions in the class path?! However, this shouldn't normally happen and the errors seem javac-related too.
Anyway, as I got a workaround now and this is a very special case, up to you if you want to close this issue or investigate further. I hope that this ticket helps other persons running into the Lucene issue as well.
If it's simply about having a dependency to Lucene in the class path though, we will run into the same issue soon again, as we are including Lucene into our project (but I can open a new ticket then too).
thanks for testing with the release candidate.
As I guess that NetBeans is using Lucene during "Find Usages" as well
right, opened projects are added to the "context" so that you can navigate to them if they are a dependency (instead of landing in jars/sources of the jars). If its not a dependency however, it should not affect anything though. So this might be a clue (unless its a race condition again and project count is affecting the timing).
I have a feeling it's to do with the JPMS / module-info usage in the demo. Try changing the scope of your search to not be the default all open projects. Does this help? Also try deleting the cache folder and letting it regenerate.
changing the scope of your search to not be the default all open projects. Does this help?
Yes, no exception. But I would call this a workaround.
try deleting the cache folder and letting it regenerate.
Well, I have to do so like once a week due to other issues, and it also started to happen with 22rc1 immediately, right after the cache got rebuilt too. So no, this doesn't help.
I have a feeling it's to do with the JPMS / module-info usage in the demo.
You seem to be very right. After I have renamed module-info.java to module-info.off, rebuilt the demo and rebuilt the NB cache, the error doesn't occur anymore. Why do you think so? Just because of module-info or Lucene being inside module-info?
I'm pretty sure that Lucene involvement is a red herring. I'm seeing this and related issues with module based projects without that involved.
That it happens directly after opening 22rc1 doesn't surprise me. It's like the initial cache is getting polluted somewhere. I have a feeling that project opening order may have something to do with it. Does a run with a clean cache and no projects work if you open in the order they are depended on?
You are right, Lucene involvement is a red herring. I created a most simple JPMS project (and had the Lucene demo closed all the time). What happened is (in NB 21):
java.lang.AssertionError: Method parameter without PARAMETER flag
once, again from com.sun.tools.javac...
. Further "Find Usages" operations on the same method were working fine.StackOverflowError
when the JPMS project was open, while working fine when it was closed.
Interestingly, I got the StackOverflowError
with NB 21 now. Saw it only with NB 22 before.Now, how shall we proceed? Shall I try to replicate the issue with simple projects only, such that I can post them here? Or is there a similar issue ticket already?
For sure this is no NB 22 regression.
Now, how shall we proceed? Shall I try to replicate the issue with simple projects only, such that I can post them here? Or is there a similar issue ticket already?
@herkrath I took a look and I don't think there is a similar ticket involving stack overflow. If you can create a small reproducer - I am sure it would help, however it likely won't be easy to come up with one.
Apache NetBeans version
Apache NetBeans 22 release candidate
What happened
Most likely due to https://github.com/apache/netbeans/pull/7153, a StackOverflowError happens when I select "Find Usages" on certain methods of our rather large Java project. As a result, no usages are found, even though there are many. It happens so many times that NetBeans is nearly unusable. As I like NB so much, I often fall back to the text-based "Find...", but that is not a decent replacement obviously.
Note that it is not really worse as compared to before https://github.com/apache/netbeans/pull/7153. Before, the same
NullPointerException: Cannot invoke "com.sun.tools.javac.code.Type.getThrownTypes() because "tree.meth.type" is null
error occurred as in https://github.com/apache/netbeans/issues/3725 but during "Find Usages". https://github.com/apache/netbeans/issues/3725 was supposed to be fixed by https://github.com/apache/netbeans/pull/7153.It started about 2 years ago (I am always using the most recent NB version) but got worse and worse over time. Not sure if that was due to NB, changes in our code or both.
Language / Project Type / NetBeans Component
Java multi-module Maven project
How to reproduce
I created this issue as a heads-up to show probable consequences of https://github.com/apache/netbeans/pull/7153. I cannot send our code as it's proprietary and too large.
I will try to identify the culprit (I think it's about generics) and write simple classes to reproduce next.
Did this work correctly in an earlier version?
No / Don't know
Operating System
Windows 11
JDK
Oracle JDK 11.0.22 for the project, Amazon Corretto OpenJDK 17.0.10 for NetBeans
Apache NetBeans packaging
Apache NetBeans binary zip
Anything else
The exception details are:
With NetBeans 21, it was:
Are you willing to submit a pull request?
No