Bug 70844 - Fields missing from return value of ITypeBinding.getDeclaredFields()
Summary: Fields missing from return value of ITypeBinding.getDeclaredFields()
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-07-26 14:29 EDT by Edwin Chan CLA
Modified: 2004-10-27 06:57 EDT (History)
0 users

See Also:


Attachments
Plugin to demonstrate the bug (7.51 KB, application/zip)
2004-07-26 14:30 EDT, Edwin Chan CLA
no flags Details
A Java project to run the test plugin on (40.02 KB, application/zip)
2004-07-26 14:31 EDT, Edwin Chan CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Edwin Chan CLA 2004-07-26 14:29:41 EDT
Our plugin calls getDeclaredFields() on ITypeBindings, but for some reason, the
method misses a number of (constant) fields that still show up in the class file
editor.

This shows up in the released version of Eclipse 3.0 while looking for fields in
GenericKeyedObjectPool from commons-pool.jar
Comment 1 Edwin Chan CLA 2004-07-26 14:30:21 EDT
Created attachment 13590 [details]
Plugin to demonstrate the bug
Comment 2 Edwin Chan CLA 2004-07-26 14:31:01 EDT
Created attachment 13591 [details]
A Java project to run the test plugin on
Comment 3 Edwin Chan CLA 2004-07-26 14:33:46 EDT
Note that I also added a file TestImage to the test project that shows Eclipse
working correctly in the case of java.awt.Image, so I'd guess it has something
to do with the class file format / compiler that the Apache Commons project is
using.
Comment 4 Olivier Thomann CLA 2004-07-26 14:42:58 EDT
I will investigate.
Comment 5 Olivier Thomann CLA 2004-07-26 22:09:40 EDT
The reason why you don't get the fields for the class in the commons jar is that
some fields have a type that is not "resolvable" on the classpath. If you add
the jar commons-collections-3.1.jar, then you will get all the fields. Because
the bindings are resolved information, all classes required to resolve the
fields and the methods are required on the classpath. Otherwise no fields or
methods can be retrieved from the ITypeBinding.
Ok to close?
Comment 6 Edwin Chan CLA 2004-07-27 12:06:27 EDT
That makes sense, but why doesn't Eclipse complain that I'm referencing a class
that still has external dependencies?
Comment 7 Olivier Thomann CLA 2004-07-27 12:25:09 EDT
You would get such error only if you actually reference those fields in your code.
If you add a method foo() in the TestPool class you provided that looks like this:

	public void foo() {
		super._evictionCursor = null;
	}

Then you would have the same problem. In this case the compiler needs to resolve
the return type of the field _evictionCursor and because it cannot retrieve the
type from the collections jar, it fails. The fields are lazily resolved. So this
is why you don't get the error with your example, but you get it using the
DOM/AST type bindings (in this case you forced all fields to be resolved).

You would also get the same issue if you add a field called:
public int _evictionCursor;

Hope that this is clear enough.

Closing as WONTFIX. Please reopen if you have further questions.