This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
In a freefrom project with multiple package folders I have a Java class in folder A refering to a class in folder B. The project is configured to use all folders on its classpath. While code completion and import (shift+alt+i) works, the editor shows all lines with referenced classes from the other folder as errors. The tooltip says "cannot find symbol".
Created attachment 17835 [details] Shows the problem on project "NPI.ejb" via screenshot
Probably a configuration problem in your project, not an IDE bug. Please attach your project.xml together with a description of the structure of your sources on disk, and your log file. (Or, better yet, create a trivial self-contained test project that demonstrates the problem.) I don't know what "The project is configured to use all folders on its classpath." is supposed to mean exactly, but if compilation unit A (with one source root) refers to c.u. B, then B must have at least one configured output directory or JAR (<built-to>) which is listed in A's classpath (<classpath mode="compile">) in order for the IDE to know that there is such a relationship. This roughly corresponds to (in Ant) <javac srcdir="b-src" destdir="build/b-classes"/> <javac srcdir="a-src" destdir="build/a-classes"> <classpath> <pathelement location="build/b-classes"/> </> </> In such a case, A can refer to B but B cannot refer to A. Alternatively, both package roots may be listed together in a single c.u. if they are mutually interdependent. For example <javac destdir="build/all-classes"> <sourcepath> <pathelement location="a-src"/> <pathelement location="b-src"/> </> </> In this case, classes in either A or B can refer to one another without constraint. In most situations you want the first scenario (one-way dependency) since it enforces better modularity, but depends on the details of your project's setup. The GUI will only let you configure the first scenario; the second scenario can be supported by direct editing of project.xml.
With "The project is configured to use all folders on its classpath" I meant the following settings in the projects properties in the "classpath" panel: I switched "use seperate classpath" off and added explicitly the source folders to the list of clathpath elements. After tis it seemed to me, that code completion works (which didn't before), but may be this was just by accident and was indeed caused by delayed parsing? Your description of the two project types is quite clear and it looks like I have something like the second type in mind. Both folders are compiled together and also packaged in a single jar (which has not happend so far), so I excpected that the IDE is able to "merge" the folders, as NB3.6 does with mounted filesystems. I will try to create a minimal project to reproduce this.
Adding source folders to the list of classpath elements will probably not work. Classpath entries are expected to contain class files, not sources. Perhaps code completion works accidentally in this setup, but I believe the background Java parser is not written to accommodate that. As I mentioned, to support multiple folders in one compilation unit you need to edit project.xml directly; the GUI will not permit you to set up this configuration. I should also mention that this scenario (several <package-root>s in one <compilation-unit>) is rarely tested, so you may encounter specific bugs which should be filed separately. (Typically in java/code or editor - ant/code only if the project type is not correctly reporting the situation to the other IDE components which do the real work such as handling code completion or background parsing.)
Okay, here is minimal freeform project to show the problem: Two folders "srcA" and "srcB". In srcA is a class a.A refering to a class b.B in srcB. Find attached a screenshot and the project.xml. I have no idea how to change the project.xml by hand to solve this. As you can see, the two <package-root> elements are already present in one <comilation-unit>, the IDE did that when I switched off the "Seperate Classpath for Each Source Folder" in the projects property sheet.
Created attachment 17882 [details] Screenshot of sample project
Created attachment 17883 [details] project.xml for sample project
"As I mentioned, to support multiple folders in one compilation unit you need to edit project.xml directly; the GUI will not permit you to set up this configuration." - some basics are configurable in UI and that's what Marco did - turning off "use seperate classpath" checkbox. I tried it and it really does not work. I will check where is the problem. Marco, thanx for the test case. In the meantime I was able to reproduce it too.
Marco, could you please zip and attach the whole project? When I wrote that it does not work for me it was caused by my imports. And when I created project which I would say is equal to your one it works fine for me - nothing is underlined. Thanx.
David, I just restarted the IDE and to my total surprise everythings works like expected, without any error line and with working code completion. I changed back (to "on") the "seperate classpath" option and code completion stopped to work, but no error was highlighted. After a restart of the IDE, the error was also shown. Maybe there is no "real" bug, but an issue, with the update of internal data? Do you want to see the zipped project anyway?
"Do you want to see the zipped project anyway? " - no, my one works fine too. :-) "Maybe there is no "real" bug, but an issue, with the update of internal data?" - then it is a bug. I will keep this issue opened for me to return to it later this week and try to reproduce it. If I'm not successful nor you provide more info in the meantime I will close it as WORKSFORME.
I'm not able to reproduce it. Feel free to reopen if you are.
closed