Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 388771

Summary: IMemberValuePair#getValue returns null for expressions
Product: [Eclipse Project] JDT Reporter: Pavan V <pavan.ananth>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: srikanth_sankaran
Version: 3.6.1   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard: stalebug

Description Pavan V CLA 2012-09-04 12:43:10 EDT
Take this example for instance,

public class Klass1 {
private final String ONE = "one";
	
@AProperty(iAttr = 5 * 2, bAttr = false | true, sAttr = ONE+"Test", eAttr = EStatus.VAL1)
public String attribute1;
}

For the annotation AProperty, the member value pairs iAttr, bAttr & sAttr store value as null. 

The API I am referring to is: org.eclipse.jdt.core.IMemberValuePair#getValue()
Comment 1 Srikanth Sankaran CLA 2012-09-05 01:07:57 EDT
Could you provide us with a stripped down, minimal, but complete version of client code that shows this problem ? TIA.
Comment 2 Pavan V CLA 2012-09-05 02:03:13 EDT
I thought the example I've included is simple enough :). My usage of the AST is roughly on the lines of :

for(IMemberValuePair memPair : annotation.getMemberValuePairs()){
Object value = memPair.getValue(); //value returns null
}

You could use the QuickFix on the problems marker to create the AProperty annotation & its properties automatically.
Comment 3 Srikanth Sankaran CLA 2012-09-05 04:03:42 EDT
(In reply to comment #2)
> I thought the example I've included is simple enough :). My usage of the AST
> is roughly on the lines of :

The example is simple, but you didn't show the client code that is
processing the file and is running into null's.

> for(IMemberValuePair memPair : annotation.getMemberValuePairs()){
> Object value = memPair.getValue(); //value returns null
> }

Could you attach a complete example, please.
Comment 4 Pavan V CLA 2012-09-05 04:53:04 EDT
Am sorry but the chain of events leading to this state involves too many classes & methods to be included here. 

If I'm not mistaken, you could use a ASTParser to parse this code (as String) & investigate the AST - perhaps the JDT Junits would already be doing this somewhere ?
Comment 5 Srikanth Sankaran CLA 2012-09-05 05:10:19 EDT
Bugs that carry a small reproducible case tend to get attended to sooner than
others where a committer needs to guess. We routinely run into cases where we
try to reconstruct from wordy descriptions only to fail.
Comment 6 Eclipse Genie CLA 2019-11-09 14:53:57 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.