Bug 117018 - IVariableBinding#getConstantValue() could be lazy resolved
Summary: IVariableBinding#getConstantValue() could be lazy resolved
Status: RESOLVED DUPLICATE of bug 61946
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-18 05:19 EST by Jerome Lanneluc CLA
Modified: 2005-11-18 12:53 EST (History)
0 users

See Also:


Attachments
Patch for having field binding lazily resolve their constants (5.20 KB, patch)
2005-11-18 06:36 EST, Philipe Mulet CLA
no flags Details | Diff
Regression test (2.29 KB, patch)
2005-11-18 07:13 EST, Jerome Lanneluc CLA
no flags Details | Diff
More aggressive patch (184.59 KB, patch)
2005-11-18 09:30 EST, Philipe Mulet CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jerome Lanneluc CLA 2005-11-18 05:19:48 EST
I20051117

1. Have these 2 cus:
A.java
public class A extends B {
}

B.java
public class B {
  public static final int CONST = 1 + 1;
}

2. Use ASTParser#createASTs(...) to resolve just A.java
3. In the ASTRequestor#accept(...) walk the binding for A to B, then to the
constant CONST
4. Asks for its constant value
Observe: it returns null

We should lazily resolve the constant value.
Comment 1 Jerome Lanneluc CLA 2005-11-18 05:22:51 EST
Calling FieldReference.getConstantFor(fieldBinding, null, false, null) should work.
Comment 2 Philipe Mulet CLA 2005-11-18 06:35:57 EST
I think it should call: FieldReference.getConstantFor(fieldBinding, null, true,
null) to ensure actual constant is surfaced.

I am also wondering if the FieldRef code shouldn't be made more lazy, by simply
having the field binding itself be lazy. This would mean no change for DOM itself.

Will attach corresponding patch, can you give it a try Jerome ?
Comment 3 Philipe Mulet CLA 2005-11-18 06:36:57 EST
Created attachment 30215 [details]
Patch for having field binding lazily resolve their constants
Comment 4 Jerome Lanneluc CLA 2005-11-18 07:13:54 EST
Created attachment 30216 [details]
Regression test
Comment 5 Philipe Mulet CLA 2005-11-18 09:30:03 EST
Created attachment 30221 [details]
More aggressive patch
Comment 6 Philipe Mulet CLA 2005-11-18 11:48:24 EST
Jerome - pls add your test.


*** This bug has been marked as a duplicate of 61946 ***
Comment 7 Jerome Lanneluc CLA 2005-11-18 12:53:58 EST
Test released in HEAD