[NETBEANS-6881][NETBEANS-6880][NETBEANS-6921] Additional fixes for the multi-file launcher:#6912
Conversation
lahodaj
commented
Jan 3, 2024
- checking for null return result for getClassPath(COMPILE)
- filtering out directories that belong to a project from the multi-file launcher source path
- more thoroughly prevent creating of the multi-file launcher source ClassPath for files under projects
|
Thank you for the update - however, that behavior seem still to be buggy. I have an tmp folder with Payara (Jakarta EE server) expanded inside it. The moment I create a "test.java" file in tmp, the payara6 folder is marked as "error". To get a clean state I tested in a new folder: Download Link for Payara I did nothing (at least not consciously) to indicate to NetBeans, that it should touch the Two things make me nervous:
Both cases need to be fixed at some point, but at least they are projects and thus there is a reason for indexing. If a single java file is enough to trigger indexing the whole subfolder structure, this cries problem. |
|
@matthiasblaesing, I wonder what is your proposal on how things should work (or if it is just "exactly the same way as before"). More specifically, JEP 458: is part of JDK 22. I personally don't need a support for it at all, and but for various reasons there's a need to support it in the VS Code extension. This JEP is basically "any groups of files anywhere on a disk may be used as a project by running one of them". Given how project-oriented NetBeans is, it is not really clear how to approach it. And, to get some features work reliably or at all, we need the index. There are various ways to approach this, including:
I guess I am fine with any approach inside the NetBeans/Swing UI. I don't think I would like to turn down the behavior for the VS Code extension, but it should be possible to have different behaviors. (Moreover, given the "Workspace" concept, the issue does not really exist in VS Code.) Thanks! |
|
I'm not sure what is the "right" answer. I think that IDE support will always be hard for this kind of project (sorry about the word-play). The interesting bit I read there is, that the launcher must ignore all java files, that are not referenced by the file being run:
So what can you expect from the IDE in such a I only worked with VSCode shortly and my understanding is, that what you called "Workspace" is a "directory" opened for working with it. This sounds an awful lot like the "Lightweight C/C++-Project" for LSP based native support and would also match option 5 you listed. I think at some point we'll need an "ephemeral project" manager to remove such projects, but a stop gap?! |
|
just a thought: NetBeans can store file properties for java files (as used for jvm/program args). I am wondering if it would be a better default, to have the multi-file mode disabled by default (no scanning), and only enable it when a flag on the (main) file is set? (VSCode can turn this on by default if it wants to) This could be even an editor hint at some point in future which sets the flag. (the hint could do some "probing" before suggesting to enable scanning for the folder the file is in) edit: so essentially the main file can become the "project" in a way, but it isn't one by default |
|
just to be sure I tested this PR and it doesn't influence #6921, which is another regression caused by the multi-file launcher PR. |
|
Just catching up on release related tasks, and so not looked fully in depth at the changes. However, we have a policy in place that master should always be in a releasable state. The number of release critical issues here is a concern. Unless there is an obvious fix here, then either the feature addition needs reverting, or it needs switching off (by default) before we freeze and branch. |
|
FWIW, I'll make an editor hint, to explicitly enable the scanning. I'll try to work on that today. I'll also need to investigate the #6921 - I thought that was already solved, but apparently not. Sorry for trouble. |
|
So, I've tweaked the behavior by:
Please let me know what you think. |
|
Thank you. First quick test seems to indicate, that this improves the situation a lot. However I saw two issues while "playing" with this. One issue I see in the log is this: the other thing is this: The |
|
ran a few quick tests and can confirm that as long the hint is not activated by the user, NB behaves pretty much like it used to. however my first "load test" already broke it when I added a java file to my home folder and activated the hint. NB scanned for a few minutes till it ran out of memory (default dev build seems to use 8GB max on my system with 32GB) and I was not able to cancel the scanning anymore at this point so i had to kill the process. I get the feeling that it will be fairly difficult to find a satisfying solution since the location of the java file will fairly often not be the equivalent of a src/ folder. I essentially can't put a java file anywhere near my NetBeansProjects folder ;) We don't have to rush anything now of course, we can disable the feature for a release in NB until we figure something out. edit as a side note: edit2:
|
|
So, regarding the indexing when the root (home directory) is registered - is there a reason to believe that's significantly different from when one makes the home directory a source root in a J2SE project? The multi-file handling is not really changing the way things are indexed, it just registers directories for indexing, as does J2SE project. (There's a bit of a difference due to the exclusions, which may load other projects, but that hopefully should not have that big impact.) I am afraid I don't get the part related to srcpath. If there's a Java file without a package clause in the home directory, what else could be on the srcpath than the home directory? Individual files cannot be on a source path (and, inside NB, all entries in a path must be directories, that applies also to classpath, etc.) We'd need to exclude from the sourcepath, not add to it. Which is technically doable, it just seems extremely difficult. There's a way to provide VM options (like classpath), in the NB GUI see the Properties window. It does not support I've pushed an updated that removes the hint, and the only way to enable registering of the roots now remains the branding. |
There is probably no difference but this is a scenario which is very unlikely to happen, no? A user, e.g student can put a maven project into
Ok I wasn't aware of this - this means most of the things I mentioned in the posts above wouldn't be possible anyway. The way I understand the JEP and also the way JDK 22 behaves right now is that the java launcher is only touching files on-demand. If the source refers to The fact that NB is scanning everything in It is a eager vs lazy loading situation. The java launcher does this lazily, NB tried to do it eagerly.
thanks a lot Jan! I think this is the right decision and gives us more time to think about solutions - and also gain more experience with usecases of the JEP 458 itself in the meantime. |
Well, in the previous round, the user would need to switch to Favorites, open the Java file and confirm the hint. It surely does not look that easy. I mean - it is easy if you know exactly what to do, but by following the usual model in the IDE, it is no longer so easy (as normal model in the IDE does not include Favorites all that much, I suspect). And if one knows what to do, the path through projects is +/- of the same complexity, it is just atypical.
I was thinking of that, but it is far, far more complicated than it seems. Feel free to investigate, though.
To be honest, as long as the behavior inside NB is acceptable (i.e. based on the feedback here, the same as in NB 20), I don't think I'll be looking too much into improving the capabilities there. Feel free to look into that, though. |
There was a problem hiding this comment.
Tested yesterday and found that the two situation I tested #6881 and #6880 are now fixed. I also tried opening the nb-javac project and this now works again without burning my CPU away. The same is true for the JDK checkout where I tried to open java.base.
The code looks sane to me, I'm not an expert in this area though.
This should be squashed before merge.
3e99943 to
92be119
Compare
…e multi-file launcher: - checking for null return result for getClassPath(COMPILE) - filtering out directories that belong to a project from the multi-file launcher source path - more thoroughly prevent creating of the multi-file launcher source ClassPath for files under projects - never touch read-only filesystems (i.e. typically jars/zip) - do not register the source CP into GlobalPathRegistry by default in the IDE - the behavior can either be overriden using a localization bundle
92be119 to
1852427
Compare
