Summary: | [1.5][compiler] NPE in ProblemReporter | ||||||
---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Martin Aeschlimann <martinae> | ||||
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> | ||||
Status: | VERIFIED FIXED | QA Contact: | |||||
Severity: | normal | ||||||
Priority: | P3 | CC: | mstevens, tyeung | ||||
Version: | 3.1.1 | ||||||
Target Milestone: | 3.1.2 | ||||||
Hardware: | PC | ||||||
OS: | Windows XP | ||||||
Whiteboard: | |||||||
Attachments: |
|
Description
Martin Aeschlimann
2005-09-26 10:12:48 EDT
Now I got the exception in the debugger. - jdt.core 3.2 HEAD and jdt.ui (5.0 pioneering) set to 5.0 compliance, PDE target location set to a 3.2 M2 build - method that is problematic: org.eclipse.jdt.core.search.IJavaSearchScope createJavaSearchScope(NULL TYPE) - method.source() returns null -> NPE in missingDeprecatedAnnotationForMethod Cannot reproduce with 3.1.1 SDK, JDT/Core from HEAD and JDT/UI from Pioneering_5_0 branch. Suspect you need to enable the optional warning for missing @Override annotation Actually, did mean the warning for missing @Deprecated annotation Still cannot reproduce. Cannot reproduce either. Some questions: 1) do you have any specific compiler settings? If so, it would be great to attach them to this bug to help us to reproduce. 2) I do not really understand how createJavaSearchScope may be problematic as it does not override any method (neither in SearchEngine nor BasicSearchEngine). Can you be more precise on this point? 3) You talked about method.source() for the NPE origin but cannot see this code in missingDeprecatedAnnotationForMethod. Looking at line in stack trace, it sounds more like 'method' itself was null. Could you confirm that? Forget question 2), I mixed @Override and @Deprecated tags... Created attachment 27556 [details]
my preferences
I also failed to recreate the bug on a fresh workspace, so it doesn't seem to
be reproducible.
In answer of Frederics question 3.)
SourceTypeBinding.resolveTypesFor line 1199 calles
this.scope.problemReporter().missingDeprecatedAnnotationForMethod(method.sourceMethod());
When I had this in the debugger, method.sourceMethod() was null. 3 lines later
a extra null check is performed on that.
method.sourceMethod() was null as the method (taken from
sourceTypeBinding.methods contained unresolved parameters (NULL), and this
method could not be found in sourceTypeBinding.scope.referenceContext.methods
Pls reopen if steps become available Reopen. *** Bug 116958 has been marked as a duplicate of this bug. *** Philippe, Bug 116958 provides a patch for this issue. *** Bug 115508 has been marked as a duplicate of this bug. *** Reproduced using testcase from bug 116958. Theodora's patch is good. Problem comes from a forward reference to a method which hasn't been fully resolved yet, and for which the binding got discarded since parameters couldn't be resolved. Simpler testcase: 2 files X.java & Y.java, compile X and Y on command line, X being first. Needs to be in 1.5 mode, with diagnostic for missing @Deprecated annotation enabled. public class X { void foo(Y y) { y.initialize(null, null, null); } } public class Y { /** * @deprecated */ public void initialize(Zork z, String s) { } public void initialize(Zork z, String s, Thread t) { } } Added AnnotationTest#test182 Backported to 3.1.2 Actually, reconsidering the fix. The check was occurring at a time it is difficult to tell for sure; and also same code pattern exists for fields and types (though not problematic interestingly). A better way is to move the missing @Deprecated check at the stage the source declaration is being resolved as part of its declaring unit (and not potentially as a forward reference like in the original scenario). Released new fix in #resolve(...) methods. Added AnnotationTest#test182-184. Fixed both in 3.2 and 3.1.2 streams. Verified for 3.2M4 in I20051212-2000 Verified for 3.1.2 in M20060109-0800. |