Summary: | isLocal() in IType returns true for anonymous types | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Andreas Thies <andreas.thies> | ||||||
Component: | Core | Assignee: | Jay Arthanareeswaran <jarthana> | ||||||
Status: | VERIFIED FIXED | QA Contact: | |||||||
Severity: | normal | ||||||||
Priority: | P3 | CC: | amj87.iitr, markus.kell.r, Olivier_Thomann | ||||||
Version: | 3.7 | Flags: | markus.kell.r:
review+
|
||||||
Target Milestone: | 3.7 M7 | ||||||||
Hardware: | PC | ||||||||
OS: | Windows XP | ||||||||
Whiteboard: | |||||||||
Attachments: |
|
Description
Andreas Thies
2011-03-09 06:41:03 EST
Interestingly, IType#isLocal() returns true for the given test only in the case of source types. Looks like the binary types already handle this case well - look at ClassFileReader#isLocal() A fix here will break the fix made to bug #85298. Now I am beginning to wonder about the relevance between IType#isLocal and JLS §14.3. Markus/Olivier what do you think? I agree that we're not consistent with the JLS here, but it's too late for a breaking API change like this. The only thing we can do is document the mismatch. The prime definition of JDT's view of the Java type system is in ITypeBinding. There, isLocal() is explicitly specified like this: * A local class is any nested class or enum type not declared as a member * of another class or interface. A local class is a subspecies of nested * type, and mutually exclusive with member types. Note that anonymous * classes are a subspecies of local classes. Since we can't just change ITypeBinding#isLocal() now and since ITypeBinding and IType should stay in sync, nothing should be changed in code. (In reply to comment #3) > Since we can't just change ITypeBinding#isLocal() now and since ITypeBinding > and IType should stay in sync, nothing should be changed in code. I agree. The only thing we can do is improve the doc to make it clear what isLocal() is returning for anonymous class. So Jay, please propose an improvement for the javadoc of the method: org.eclipse.jdt.core.IType#isLocal(). This is the best we can do. (In reply to comment #3) > The only thing we can do is document the mismatch. From a client's perspective that would be enough. A workaround is pretty simple (just check IType#isAnonymous); the only damage for me resulted from the unexpected behavior. Created attachment 190889 [details]
Proposed patch
Patch with updated javadoc for IType#isLocal()
Looks good enough to me. Comment on attachment 190889 [details] Proposed patch (In reply to comment #6) > Created attachment 190889 [details] [diff] The note is unclear. "As per ..." sounds like we follow the spec. But since we don't, this should be stated explicitly ("Note: This deviates from JLS3 14.3..."). Furthermore, it's confusing that you use differing terms "anonymous type" and "anonymous inner classes" for the same thing. And please also update ITypeBinding#isLocal(). Created attachment 191080 [details]
Updated patch
Javadoc updated as according to Markus' comments.
Perfect, thx. Closing since this has been released. Released for 3.7M7. Verified. |