Bug 185306 - Help with fields and methods on binary super types with unresolved references
Summary: Help with fields and methods on binary super types with unresolved references
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 RC1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-03 06:18 EDT by Martin Aeschlimann CLA
Modified: 2007-05-15 05:13 EDT (History)
5 users (show)

See Also:
Olivier_Thomann: review+


Attachments
Proposed patch (7.54 KB, patch)
2007-05-03 06:27 EDT, Philipe Mulet CLA
no flags Details | Diff
Patch fixing failing search tests (3.19 KB, patch)
2007-05-03 12:29 EDT, Frederic Fusier CLA
no flags Details | Diff
Proposed fix (10.29 KB, patch)
2007-05-09 20:19 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Aeschlimann CLA 2007-05-03 06:18:31 EDT
20070503

When there is a binary super type that has unresolved return types or parameters, the binding AST does not return any fields or methods.

From discussions in 184613, we realized it would be good to have at least the members that can be resolved. At the moment these members can exist as a reference binding in the AST, but they not in the children list of their declared type.

-> fieldBinding.getDeclaringClass().getDeclaredFields() does not contain fieldBinding
Comment 1 Philipe Mulet CLA 2007-05-03 06:27:05 EDT
Created attachment 65740 [details]
Proposed patch

More invocations of ReferenceBinding#methods()/fields() should be addressed (ping'ed David for codeassist/codeselect).

Owners of search/binding key/DOM AST should review the proposed changes
Comment 2 Philipe Mulet CLA 2007-05-03 06:31:42 EDT
Kent - for 3.3, I think we should ensure more are using #availableFields/availableMethods(), but looking into 3.4 I am wondering if we shouldn't rather do sthg different:
Simply make BinaryTypeBinding#methods() and #fields() more resilient (i.e. swallow the behavior of available[Methods/Fields] into them.
Rationale: would be less error prone for existing users, and make binary side be consistent with source side (which is already resilient).
Now, this is fairly late to do in 3.4, and we would need to test/bullet-proof our story a little before going there (thinking of incremental builder consequence for instance).


David/Jerome/Frederic/Olivier - if comfortable with suggested patch, please say so, and provide regression tests demonstrating the net effect (on resilience).
Comment 3 Philipe Mulet CLA 2007-05-03 06:32:39 EDT
Kent - if you agree with comment 2, pls file a separate bug for evolving it into 3.4.
Comment 4 Frederic Fusier CLA 2007-05-03 12:29:01 EDT
Created attachment 65799 [details]
Patch fixing failing search tests

Some potential matches become exact ones with this fix. Fortunately, there were 3 tests on invalid class path, 2 pass with Philippe's patch, 1 is still failing => sounds like we still cover all cases...

So, my patch is simply to update the output assertion for the failing tests...
Comment 5 Kent Johnson CLA 2007-05-03 13:41:42 EDT
Maybe I don't understand exactly what u want to do...

BinaryTypes need to cause classpath errors to happen during the normal compile loop. I don't see why we would want to avoid this happening.

Other users such as code assist can skip fields/methods with unresolvable types, but a normal compile loop MUST fail if the classpath is incomplete.
Comment 6 Olivier Thomann CLA 2007-05-03 16:04:11 EDT
The javadoc would need to be updated for getDeclaredMethods() and getDeclaredFields() to reflect the new behavior.
Comment 7 Olivier Thomann CLA 2007-05-09 09:43:08 EDT
(In reply to comment #5)
> BinaryTypes need to cause classpath errors to happen during the normal compile
> loop. I don't see why we would want to avoid this happening.
> Other users such as code assist can skip fields/methods with unresolvable
> types, but a normal compile loop MUST fail if the classpath is incomplete.
Kent, this is exactly what the patch is doing. It affects only DOM and search.
So now in the DOM you can retrieve all the methods/fields that can actually be resolved instead of an empty list as soon as one fails to resolve.
I am comfortable with the patch and I'll prepare a regression test in DOM to show that more fields or methods are now returned.
I still need to be able to clarify the javadoc of getDeclaredFields() and getDeclaredMethods(). Martin, any suggestions?
Comment 8 Martin Aeschlimann CLA 2007-05-09 09:52:06 EDT
sounds good to me!
Comment 9 Olivier Thomann CLA 2007-05-09 09:54:55 EDT
I meant any suggestions on how to rephrase the javadoc of these two methods :-).
Comment 10 Olivier Thomann CLA 2007-05-09 10:06:50 EDT
I do have a regression test for the DOM side, but since it contains some binary resources I cannot directly attach it here.
I'll release it as a disabled test.
See org.eclipse.jdt.core.tests.dom.ASTConverterTestAST3_2#_test0677
Comment 11 Martin Aeschlimann CLA 2007-05-09 10:10:25 EDT
/**
 * Returns a list of bindings representing all the fields declared
 * as members of this class, interface, or enum type. These include public,
 * protected, default (package-private) access, and private fields declared
 * by the class, but excludes inherited fields. Synthetic fields may or
 * may not be included.
 * Fields from binary types that reference unresolvable types may not be included.
 * ...
Comment 12 Olivier Thomann CLA 2007-05-09 18:36:31 EDT
Forgot to request explicit review.
Comment 13 Olivier Thomann CLA 2007-05-09 18:37:55 EDT
Reviewed Philippe's patch. I'll adjust the javadoc and release.
Comment 14 Olivier Thomann CLA 2007-05-09 20:14:54 EDT
Released for 3.3RC1.
Enabled org.eclipse.jdt.core.tests.dom.ASTConverterTestAST3_2#test0677
Comment 15 Olivier Thomann CLA 2007-05-09 20:19:25 EDT
Created attachment 66592 [details]
Proposed fix

New patch with doc updates.
Comment 16 Jerome Lanneluc CLA 2007-05-10 05:03:13 EDT
Please undo this change (at least for search). As shown in the patch to Java search tests, we now miss valid potential matches.
Comment 17 Frederic Fusier CLA 2007-05-10 05:28:20 EDT
(In reply to comment #16)
> Please undo this change (at least for search). As shown in the patch to Java
> search tests, we now miss valid potential matches.
> 
My fault, I missed this point :-( We can either revert the change on ClassFileMatchLocator or complete it by not returning when there's not the same number of fields/methods and availableFields/Methods. I'm working on it...
Comment 18 Frederic Fusier CLA 2007-05-10 06:40:45 EDT
Talking with Philippe and Jerome about this, we agreed that it will be safer to revert the change on ClassFileMatchLocator and open a new bug against Search component to improve it in this peculiar case...
Comment 19 Frederic Fusier CLA 2007-05-10 06:48:58 EDT
I opened bug 186333 to fix the Search Engine issue and target it to 3.4...
Comment 20 Olivier Thomann CLA 2007-05-10 10:11:05 EDT
(In reply to comment #16)
> Please undo this change (at least for search). As shown in the patch to Java
> search tests, we now miss valid potential matches.
Done. Both search and search tests have been reverted.
Comment 21 Frederic Fusier CLA 2007-05-15 05:13:05 EDT
Verified for 3.3 RC1 using I20070515-0010