Community
Participate
Working Groups
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.
Pls investigate in 3.0.
I cannot reproduce this problem in I20040330. Do you have steps to reproduce it?
Maybe this is fixed in 3.0 stream. We are developing against 2.1.2. Do you have auto-build turned off?
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.
Please reopen if you have steps to reproduce this problem.