Bug 205860 - ASTParser.createBindings() returns [null]
Summary: ASTParser.createBindings() returns [null]
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3.2   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-09 15:32 EDT by Genady Beryozkin CLA
Modified: 2008-09-16 09:49 EDT (History)
6 users (show)

See Also:
philippe_mulet: pmc_approved+


Attachments
Proposed fix (929 bytes, patch)
2007-10-10 10:57 EDT, Olivier Thomann CLA
no flags Details | Diff
Regression tests (2.52 KB, patch)
2007-10-10 11:11 EDT, Olivier Thomann CLA
no flags Details | Diff
New regression tests (2.51 KB, patch)
2007-10-10 12:47 EDT, Olivier Thomann CLA
no flags Details | Diff
Simplified tests (1.99 KB, patch)
2007-10-16 05:21 EDT, Jerome Lanneluc CLA
no flags Details | Diff
Tests that don't depend on jclMin15.jar content (1.69 KB, text/plain)
2007-10-17 09:57 EDT, Jerome Lanneluc CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Genady Beryozkin CLA 2007-10-09 15:32:42 EDT
Build ID: 3.4M2

I have a problem with ASTParser.createBinding returns IBinding[]{null} for the field javax.swing.BoxLayout.LINE_AXIS.
It works fine for the other fields of this class.

Bug?

I use the following code:

ASTParser p = ASTParser.newParser(AST.JLS3);
p.setProject(resolvedField.getJavaProject());
IBinding[] createBindings= p.createBindings(new IJavaElement[]{resolvedField}, monitor);


Wrong result for
int LINE_AXIS [in BoxLayout [in BoxLayout.class [in javax.swing [in C:\Program Files\Java\jdk1.6.0_02\jre\lib\rt.jar]]]]

Good result for

int PAGE_AXIS [in BoxLayout [in BoxLayout.class [in javax.swing [in C:\Program Files\Java\jdk1.6.0_02\jre\lib\rt.jar]]]]
Comment 1 Olivier Thomann CLA 2007-10-09 15:36:20 EDT
I'll investigate.
Comment 2 Olivier Thomann CLA 2007-10-10 10:49:50 EDT
The problem comes from the fact that the binding key parser tries to parse the key of the binary field as a resolved key. It expects to find the return type before the field name.
Since the name starts with a 'L', it considers the key to be a malformed key.
Jérôme, I'll add a regression test for it (disabled for now).

I'll attach a patch to be reviewed.
Comment 3 Olivier Thomann CLA 2007-10-10 10:57:06 EDT
Created attachment 80053 [details]
Proposed fix

Regression tests are coming next.
Jérôme, please review it. Looking at the code it looks like the first letter of each base type was covered by a check that is not done in the case of 'L'.
I simply added the same check there.
Now this case passes as well as all existing tests in the ASTModelBridgeTests.
Comment 4 Olivier Thomann CLA 2007-10-10 11:11:37 EDT
Created attachment 80056 [details]
Regression tests

Two regression tests. One for PAGE_AXIS field and one for LINE_AXIS field.
The first one should also pass without the fix, but the second would fail.
Comment 5 Olivier Thomann CLA 2007-10-10 12:47:24 EDT
Created attachment 80074 [details]
New regression tests

I changed the regression tests to include a test that is using a field name starting with 'T'. This covers the two cases for the patch.
Comment 6 Jerome Lanneluc CLA 2007-10-16 05:21:29 EDT
Created attachment 80430 [details]
Simplified tests

Same tests but simplified (only 1 assert per test) and with more comments.
Comment 7 Jerome Lanneluc CLA 2007-10-17 09:57:39 EDT
Created attachment 80562 [details]
Tests that don't depend on jclMin15.jar content
Comment 8 Jerome Lanneluc CLA 2007-10-17 10:00:23 EDT
Fix and tests released for 3.4M3
Comment 9 Jerome Lanneluc CLA 2007-10-17 11:56:02 EDT
Fix and tests released for 3.3.2
Comment 10 David Audel CLA 2007-10-30 10:26:20 EDT
Verified for 3.4M3 using I20071029-0010 build.
Comment 11 Jerome Lanneluc CLA 2007-11-21 05:11:21 EST
Returning null can lead to NullPointerExceptions. This fix needs to be included in 3.3.2. Philippe please approve.
Comment 12 Philipe Mulet CLA 2007-11-21 12:34:53 EST
+1 for 3.3.2
Comment 13 Eric Jodet CLA 2008-01-24 04:42:09 EST
Verified for 3.3.2 using M20080123-0800 build