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.

Bug 51545 - Wrong JDK sources assigned to project
Summary: Wrong JDK sources assigned to project
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Project (show other bugs)
Version: 4.x
Hardware: PC Windows ME/2000
: P2 blocker (vote)
Assignee: David Konecny
URL:
Keywords: RELNOTE
Depends on: 57926
Blocks:
  Show dependency tree
 
Reported: 2004-11-16 09:02 UTC by Peter Nabbefeld
Modified: 2005-01-05 13:58 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
screen dump, comment follows (59.27 KB, image/png)
2004-11-16 09:42 UTC, Peter Nabbefeld
Details
zipped project (8.69 KB, application/octet-stream)
2004-11-16 13:50 UTC, Milan Kubec
Details
patch for first case (1.79 KB, patch)
2004-11-18 09:59 UTC, David Konecny
Details | Diff
replacement of previous patch (includes unit test) (6.70 KB, patch)
2004-11-18 11:09 UTC, David Konecny
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Nabbefeld 2004-11-16 09:02:45 UTC
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.
Comment 1 Milan Kubec 2004-11-16 09:27:08 UTC
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.
Comment 2 Peter Nabbefeld 2004-11-16 09:42:19 UTC
Created attachment 18917 [details]
screen dump, comment follows
Comment 3 Peter Nabbefeld 2004-11-16 09:50:39 UTC
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.
Comment 4 Milan Kubec 2004-11-16 13:34:34 UTC
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)?
Comment 5 Milan Kubec 2004-11-16 13:38:42 UTC
Seems that I finally got it. Will provide steps to reproduce.
Comment 6 Milan Kubec 2004-11-16 13:50:07 UTC
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.
Comment 7 Milan Kubec 2004-11-16 13:50:57 UTC
Created attachment 18923 [details]
zipped project
Comment 8 Milan Kubec 2004-11-16 13:51:49 UTC
I reproduce that on JDK 1.5.0_01 and 1.4.2_06.
Comment 9 David Konecny 2004-11-16 14:56:08 UTC
In today's trunk this works fine. Must be problem of release40 branch.
Comment 10 David Konecny 2004-11-16 14:58:14 UTC
I will look at that.
Comment 11 David Konecny 2004-11-17 09:29:37 UTC
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).
Comment 12 David Konecny 2004-11-18 09:59:57 UTC
Created attachment 18943 [details]
patch for first case
Comment 13 David Konecny 2004-11-18 11:09:02 UTC
Created attachment 18947 [details]
replacement of previous patch (includes unit test)
Comment 14 David Konecny 2004-11-18 11:10:34 UTC
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;
Comment 15 Jan Chalupa 2004-11-22 18:53:28 UTC
Waiver approved for 4.0.
Comment 16 David Konecny 2005-01-05 13:58:06 UTC
Fixed:
src/org/netbeans/modules/java/project/JavaAntLogger.java;
new revision: 1.7; previous revision: 1.6