Community
Participate
Working Groups
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
Created attachment 13590 [details] Plugin to demonstrate the bug
Created attachment 13591 [details] A Java project to run the test plugin on
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.
I will investigate.
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?
That makes sense, but why doesn't Eclipse complain that I'm referencing a class that still has external dependencies?
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.