Bug 242961 - [DOM] ITypeBinding.getDeclaredFields returns empty results if any field has undefined type
Summary: [DOM] ITypeBinding.getDeclaredFields returns empty results if any field has u...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.4   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.5 M1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-02 14:01 EDT by Alan Bram CLA
Modified: 2014-06-10 11:28 EDT (History)
4 users (show)

See Also:


Attachments
Proposed fix (1.00 KB, patch)
2008-08-06 10:14 EDT, Olivier Thomann CLA
no flags Details | Diff
Regression test (1.79 KB, patch)
2008-08-06 10:24 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 Alan Bram CLA 2008-08-02 14:01:09 EDT
Build ID: I20080617-2000

Steps To Reproduce:
in a plug-in which supplies an extension to the org.eclipse.core.resources.builders extension point, parse a Java compilation unit called "A.java", containing code like this:

    class A {
        int k;
        B b;
    }

Note: there is no such class named B.

in the plug-in, run some code like this:

parser = ASTParser.newParser(AST.JLS3);

// in the delta visitor of my IncrementalProjectBuilder ...

visit(IResourceDelta d) {
  IResource r = d.getResource();
  IJavaElement je = JavaCore.create(r);
  icu0 = je.getAdapter(ICompilationUnit.class);
  // icu0 != null
  icu = (ICompilationUnit)icu0;
  parser.setSource(icu);
  parser.setResolveBindings(true);
  compilationUnit = (CompilationUnit)parser.createAST(null)
  compilationUnit.accept(new ASTVisitor() {
    public boolean visit(TypeDeclaration typeDeclaration) {
      typeBinding = typeDeclaration.resolveBinding();
      // typeBinding != null
      fields = typeBinding.getDeclaredFields();
      // fields.length == 0

More information:
There is no such class named "B".  However, I expect that getDeclaredFields() should return information about field "k".

This used to work in Eclipse 3.3; it seems to have changed in 3.4.
Comment 1 Olivier Thomann CLA 2008-08-06 10:13:09 EDT
Reproduced.
Comment 2 Olivier Thomann CLA 2008-08-06 10:14:18 EDT
Created attachment 109304 [details]
Proposed fix
Comment 3 Olivier Thomann CLA 2008-08-06 10:23:33 EDT
Philippe,

This is a regression since 3.3.2 as in 3.3.2 we used to return the field 'k'.
I would backport the fix to the 3.4 maintenance stream for inclusion in 3.4.1.
Comment 4 Olivier Thomann CLA 2008-08-06 10:24:51 EDT
Created attachment 109307 [details]
Regression test
Comment 5 Olivier Thomann CLA 2008-08-06 20:41:31 EDT
Released for 3.5M1.
Regression test added in org.eclipse.jdt.core.tests.dom.ASTConverterTestAST3_2#test0692.

Philippe, +1 for 3.4.1?
Comment 6 Olivier Thomann CLA 2008-08-07 11:02:06 EDT
Verified for 3.5M1 using I20080807-0100.
We might reopen later for inclusion into 3.4.1.