Summary: | [compiler] NPE if type collides with a package | ||||||
---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | David Audel <david_audel> | ||||
Component: | Core | Assignee: | Kent Johnson <kent_johnson> | ||||
Status: | VERIFIED FIXED | QA Contact: | |||||
Severity: | normal | ||||||
Priority: | P3 | CC: | Olivier_Thomann, stephan.herrmann | ||||
Version: | 3.5 | ||||||
Target Milestone: | 3.5 M4 | ||||||
Hardware: | PC | ||||||
OS: | Windows XP | ||||||
Whiteboard: | |||||||
Attachments: |
|
Description
David Audel
2008-10-22 07:15:43 EDT
I gave it a quick try, so here's a proposed implementation (not a patch because I had no pristine JDT/Core at hand): public void packageCollidesWithType(CompilationUnitDeclaration compUnitDecl) { String packageName = ""; int start = 0, end = 0; if (compUnitDecl.currentPackage != null) { packageName = CharOperation.toString(compUnitDecl.currentPackage.tokens); start = compUnitDecl.currentPackage.sourceStart; end = compUnitDecl.currentPackage.sourceEnd; } else if (compUnitDecl.scope != null && compUnitDecl.scope.currentPackageName != null) { packageName = CharOperation.toString(compUnitDecl.scope.currentPackageName); // no useful source position available } String[] arguments = new String[] {packageName}; this.handle( IProblem.PackageCollidesWithType, arguments, arguments, start, end); } Reproduced with this case : p1/C1.java: package p1; public class C1 {} p1/C1/C2.java: public class C2 {} // NOTE: no package statement Created attachment 118397 [details]
Proposed patch with testcase
Fix and test released for 3.5M4 Verified for 3.5M4 using I20081208-1800 |