Summary: | [1.5][compiler] JDT allows annotation to have a null default | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Daniel R Somerfield <dsomerfi> | ||||||||
Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> | ||||||||
Status: | VERIFIED FIXED | QA Contact: | |||||||||
Severity: | normal | ||||||||||
Priority: | P3 | CC: | dsomerfi, jgarms | ||||||||
Version: | 3.1.2 | ||||||||||
Target Milestone: | 3.2 M6 | ||||||||||
Hardware: | PC | ||||||||||
OS: | Windows XP | ||||||||||
Whiteboard: | |||||||||||
Attachments: |
|
Description
Daniel R Somerfield
2006-03-27 18:01:50 EST
The null case is not checked in the enum case. Created attachment 37042 [details]
Proposed fix
Created attachment 37043 [details]
Corresponding regression test
Fix looks good Fixed and released in HEAD. Regression test in org.eclipse.jdt.core.tests.compiler.regression.AnnotationTest.test196 After this fix, will a call to getDefaultValue() on a method with an invalid null default still throw a IllegalStateException? Yes, since null should not happen. I could not get the IllegalStateException with or without the fix on a 3.2 build. null is returned instead. We are still seeing the exception. I should have made this clear: I cut off the stack trace so it is: java.lang.IllegalStateException: java.lang.Object@b3a420 at org.eclipse.jdt.core.dom.ResolvedMemberValuePair.buildDOMValue(ResolvedMemberValuePair.java:91) at org.eclipse.jdt.core.dom.MethodBinding.getDefaultValue(MethodBinding.java:451) at ... where "..." is external (non-JDT) code calling in. I think any time code calls getDefaultValue() on an invalid null default value. This is a problem, because even though the code is not valid, it can still show up in source. Are you seeing something different? What version are you using? I don't have the class org.eclipse.jdt.core.dom.ResolvedMemberValuePair anymore. It is now called org.eclipse.jdt.core.dom.MemberValuePairBinding. Verified for 3.2 M6 using build I20060329-0010. Dan was using the APT branch of jdt.core (3.1.2). Looking at the latest in HEAD, the same problem still exists: an IllegalStateException could be thrown if the user's source code is invalid. I'll attach a proposed fix for the IllegalStateException: return null instead. Created attachment 37224 [details]
Fix for IllegalStateException
Fixed and released in HEAD. Verified. There is nothing more to verify that what was done before. |