Bug 119249 - codeResolve, search, etc. don't work on constructor of binary inner class
Summary: codeResolve, search, etc. don't work on constructor of binary inner class
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 M5   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-12-05 10:14 EST by Markus Keller CLA
Modified: 2006-04-20 17:54 EDT (History)
1 user (show)

See Also:


Attachments
Proposed patch and regression tests (15.10 KB, patch)
2005-12-16 08:51 EST, Jerome Lanneluc CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2005-12-05 10:14:26 EST
I20051130-1215

Several jdt.core APIs don't work correctly for a constructor of a binary inner class. One thing is bug 47354 (wrong display in the outline view), but there are many other cases where APIs don't work e.g. on constructor java.util.zip.ZipFile.ZipFileInputStream(long, long, ZipFile):

- codeSelect returns the enclosing type, not the constructor
- getElementAt() returns the enclosing type
- search does not work on the element when selected in the outline
- the element from the outline does not have a valid source range
- IMethodBinding#getJavaElement() returns a non-existent IMethod (which would nevertheless have the right parameter names, parameter types, and source range).

Feel free to mark as dup of bug 47354 if this is really all the same problem.
Comment 1 Jerome Lanneluc CLA 2005-12-16 08:51:32 EST
Created attachment 31868 [details]
Proposed patch and regression tests
Comment 2 Jerome Lanneluc CLA 2006-01-06 06:19:49 EST
Released patch and regression tests. Note that finding references to such constructor still doesn't work and is captured in bug 122880.
Comment 3 Markus Keller CLA 2006-01-06 07:08:23 EST
I just synchronized with JDT/Core HEAD and tried the fix. It seems to work fine, but there's an inconsistency now:

IMethod#getParameterNames() now returns 2 names, but IMethod#getParameterTypes() still returns 3 types (including the synthetic parameter). Shall I open a new bug for this or will it be addressed as part of bug 122880 or bug 47354?
Comment 4 Jerome Lanneluc CLA 2006-01-06 07:34:55 EST
That would be the same problem as described in bug 47354.
getParameterNames() comes from the attached source and getParameterTypes() comes from the binary. Unfortunately binary and source are always inconsistent in the  case of a method/constructor of a binary member type.
Comment 5 Frederic Fusier CLA 2006-02-14 06:07:57 EST
Verified for 3.2 M5 using build I20060214-0010.
Comment 6 Andrey Loskutov CLA 2006-04-17 18:29:28 EDT
I'm not sure if I have found the same problem again in RC1, Build id: I20060413-1718.
I'm trying to get source range for explicit constructors of inner classes from binary types, like the one from HasMap$Entry class in JDK 1.5.
If I call IClassFile.getElementAt() on HashMap, then I get the Entry as BinaryType, but not the constructor itself.
If I then call IClassFile.getElementAt() on HasMap$Entry, then I get null because org.eclipse.jdt.internal.core.SourceMapper could not find the appropriate source range for binary method (Entry constructor) in getSourceRange(). But the source code for this constructor exist (and the binary method "Entry" itself too), so I think that the bug is still not fixed.
As summary:
- getElementAt() returns the enclosing type
- SourceMapper.getSourceRange() returns UNKNOWN_RANGE
Comment 7 Andrey Loskutov CLA 2006-04-17 18:48:24 EDT
Oh, the difference to the first example java.util.zip.ZipFile.ZipFileInputStream is that java.util.HasMap.Entry is a static inner class and it uses generics.

In my case java.util.zip.ZipFile.ZipFileInputStream seems to work fine (got right source range for it), but java.util.HasMap.Entry not...
Comment 8 Jerome Lanneluc CLA 2006-04-18 06:14:54 EDT
Andrei, could you please open a new bug with steps to reproduce the problem and we will investigate ?
Comment 9 Andrey Loskutov CLA 2006-04-20 17:54:36 EDT
comment 8: I have entered bug 137847.