Summary: | ExternalPackageFragmentRoot does not expose its content consistently | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Sebastian Zarnekow <sebastian.zarnekow> |
Component: | Core | Assignee: | Jay Arthanareeswaran <jarthana> |
Status: | VERIFIED WONTFIX | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | Olivier_Thomann |
Version: | 3.5 | ||
Target Milestone: | 3.7 M5 | ||
Hardware: | PC | ||
OS: | Mac OS X - Carbon (unsup.) | ||
Whiteboard: |
Description
Sebastian Zarnekow
2009-02-12 16:09:07 EST
Please note that the referenced class has been rewritten since Feb 2009. (In reply to comment #0) > The bug seems to be, that ExternalPackageFragmentRoot should not return from > resource() when it cannot return an instance, that works as expected. Are you saying it should not cache the "this.resource" or that the method should wait until it can find a valid resource? > the filesystem). This problem occures, if we create an IJavaProject with > contents in a ui-wizard and try to resolve a classpath-uri, when the java > tooling is not yet fully initialized. I know it's been a while since you reported this bug, but a test case or a detailed steps will help. (In reply to comment #2) > I know it's been a while since you reported this bug, but a test case or a > detailed steps will help. As we successfully use a workaround since the early days of Helios, I'm not sure that I can reproduce this issue. This is the code that we use now: // the following code will return null // IResource resource = packageFragmentRoot.getUnderlyingResource(); if (!(packageFragmentRoot instanceof ExternalPackageFragmentRoot)) throw new IllegalStateException(); IResource resource = ((ExternalPackageFragmentRoot)packageFragmentRoot).resource(); Well, I'm not that familiar with the semantics of #getUnderlyingResource() but shouldn't it return the very same instance as the internal #resource() method? (In reply to comment #3) > Well, I'm not that familiar with the semantics of #getUnderlyingResource() but > shouldn't it return the very same instance as the internal #resource() method? For external elements, such as ExternalPackageFragmentRoot and JarPackageFragmentRoot pointing at an external JAR, the underlying resource is null. Please refer to the documentation - IJavaElement#getResource() and IJavaElement#getUnderlyingResource() (In reply to comment #4) > Please refer to the documentation - IJavaElement#getResource() and > IJavaElement#getUnderlyingResource() Well from the docs it's still not clear to me why ExternalPackageFragmentRoot#getUnderlyingResource returns null and why "An external package fragment root never has an associated resource." while the internal #resource() returns the information that I need. Is it really necessary to convert the #getPath by myself? (In reply to comment #5) > Well from the docs it's still not clear to me why > ExternalPackageFragmentRoot#getUnderlyingResource returns null and why "An > external package fragment root never has an associated resource." while the > internal #resource() returns the information that I need. Is it really > necessary to convert the #getPath by myself? In the case of external package fragment root, what the #resource returns is the resource representing the linked folder in the hidden external folder's project. It doesn't really return the underlying resource as such since it's not contained in the workspace. So, I think it makes sense we keep it the way it is now. Agreed. Closing this. Verified. |