Bug 54582 - IJavaProject#findType uses old classpath
Summary: IJavaProject#findType uses old classpath
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1.2   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.0 M9   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-03-12 03:18 EST by Gunnar Wagenknecht CLA
Modified: 2004-05-12 09:31 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gunnar Wagenknecht CLA 2004-03-12 03:18:24 EST
I'm having a problem with the classpath of a project. We have our own
project nature attached to projects and created several classpath containers
plus a managed IVMInstall entry based on the standard JDK
(StandardVMInstallType).

We use JDT API to find a specific typ (IType) in the build path
[IJavaProject#findType(String)].

Now the problem: when I close and reopen a project in workspace, we listen
for resource changes and update our model if a project is opened. In this
case, the IType cannot be found.

During debugging I discovered, that the classpath is incomplete. It only
contains IPackageFragmentRoots from the JRE container and from some other
containers (managed by us). The entries of one specific container are
missing.

When I expand this container in the Package Explorer, then it correctly
resolves and shows the missing entries. But I can refresh my model several
times, the entries are still missing.

If I call IJavaProject#getResolvedClasspath(false) before
IJavaProject#findType I get the complete classpath and the container is
correctly resolved. But the type is still not found.

Now the part I don't understand. If I right click the project in the Package
Explorer and select "Properties" to bring up the "Java Build Path"
properties page, and immediately click OK to close this window after
bringing up (ONLY SHOWING) the "Java Build Path" properties page, and then
refresh my model again, the type is found by IJavaProject#findType(String).


I have performed additional test:

1. Close Project
2. Open Project

3a.
  --
  IType myType = javaProject.findType("my.Type");
  --
  Result: no type is found

3b.
  --
  javaProject.getResolvedClasspath(false);
  IType myType = javaProject.findType("my.Type");
  --
  Result: no type is found

3c.
  --
  javaProject.getResolvedClasspath(false);
  ((JavaProject) javaProject).updatePackageFragmentRoots();
  IType myType = javaProject.findType("my.Type");
  --
  Result: type is found



It would be nice if there is a way to work around this without the cast to 
internal class JavaProject.
Comment 1 Philipe Mulet CLA 2004-03-12 09:31:08 EST
Pls investigate in 3.0.
Comment 2 Jerome Lanneluc CLA 2004-04-06 04:39:05 EDT
I cannot reproduce this problem in I20040330. Do you have steps to reproduce 
it? 
Comment 3 Gunnar Wagenknecht CLA 2004-04-06 06:39:27 EDT
Maybe this is fixed in 3.0 stream. We are developing against 2.1.2. Do you 
have auto-build turned off?
Comment 4 Jerome Lanneluc CLA 2004-04-06 06:46:05 EDT
Yes I do have autobuild turned off, but this should not change anything for 
IJavaProject#findType(...) as the Java model doesn't depend on the build state.
Comment 5 Jerome Lanneluc CLA 2004-05-12 09:31:53 EDT
Please reopen if you have steps to reproduce this problem.