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.
I've set this bug to P1, because IMO this must be solved in NB 4.0, and code freeze is just done. However, I've found this bug in daily build 200411072021, so please check the current code base. I've set my default platform to JDK 1.4.2 while my project uses JDK 1.5.0-b60. I've forced a stack trace to appear with the following code: try { Object o = null; o.toString(); } catch (NullPointerException npe) { npe.printStackTrace(); } When clicking on a line in stack trace output, the source for JDK 1.4.2 is shown instead of the source for JDK 1.5 - so completely useless. It seems, that the source root is taken from the default platform instead of the platform defined in the project properties.
I'm not able to reproduce your problem on latest 4.0 build. When Running project with your code I get only message like this: java.lang.NullPointerException at javaapplication8.Main.main(Main.java:25) BUILD SUCCESSFUL (total time: 0 seconds) There is no code to any JDK sources. Then I tried to run project that prints out platform properties and it printed exactly those properties belonging to assigned platform, I tried JDKs 1.3, 1.4, 1.5. Please describe exactly what you did and how did you setup your project. Please check platform sources in Java Platform Manager. Lowering prio so far.
Created attachment 18917 [details] screen dump, comment follows
I've checked - Platform for JDK 1.5 has been correctly initialized (jdk 1.5 sources). As You can see from the image attched before, there are two JComponent sources open - the first is from JDK 1.5 (opened manually), the second has been opened using the stack trace and is JDK 1.4.2. As You can see, the red bar is at a completely useless position. BTW: It would be a good idea, if the JDK version (path) of the stack trace links could be made viewable (e.g. right-click). The same would be useful for the file tabs in the editor (if two files with the same name are open at the same time, just belonging to different packages or sub-projects, it's sometimes confusing). This information could also help for this isssue.
I tried to reproduce but again no success. Please provide step by step setup of your projects and platforms. What kind of project do you use (j2seproject, freeform)?
Seems that I finally got it. Will provide steps to reproduce.
Seems to be really problem. 1) Open attached project 2) Assign to this project some platform 3) Execute the project, click on the error lines in output 4) Assign another platform 5) Execute the project, click on the error lines in output It will jump to the same files as in 3) just different lines (that make no sense in the new context). It doesn't open sources for the new platform. Please evaluate.
Created attachment 18923 [details] zipped project
I reproduce that on JDK 1.5.0_01 and 1.4.2_06.
In today's trunk this works fine. Must be problem of release40 branch.
I will look at that.
The fact that it works in trunk is coincidence. There are two problems: #1) there is missing listener in GlobPathRegistry. Adding it is simple fix and it would help a bit, but would not resolve this issue in all cases. In case when all opened projects are using the same JDK then everything will work. If two projects are using different JDK then random JDK source will be opened. Workaround exist for this problem: restart IDE after platform switch. #2) this is simply feature which is not implemented and has to be fixed for 4.1: JDK needs to be remembered for executed process. At the moment output window fallbacks on the GlobPathRegistry and tries to find JDK sources there. If all projects has the same JDK then it works, if not then random JDK is choosen because GlobPathRegistry will contain them all. So, the question is whether we want to improve it a bit for 4.0 or no - case #1).
Created attachment 18943 [details] patch for first case
Created attachment 18947 [details] replacement of previous patch (includes unit test)
There was a bug in first patch - ignore it. Case #1 fixed in trunk: src/org/netbeans/api/java/classpath/GlobalPathRegistry.java; new revision: 1.10; previous revision: 1.9 test/unit/src/org/netbeans/api/java/classpath/ClassPathTest.java; new revision: 1.6; previous revision: 1.5 test/unit/src/org/netbeans/api/java/classpath/GlobalPathRegistryTest.java;
Waiver approved for 4.0.
Fixed: src/org/netbeans/modules/java/project/JavaAntLogger.java; new revision: 1.7; previous revision: 1.6