Community
Participate
Working Groups
This is a followup of the bug 119249 comment 6. Seen with the RC1, Build id: I20060413-1718, JDK 1.5 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(offset) on HashMap with the source offset of the HashMap.Entry constructor, then I get the Entry as BinaryType, but not the constructor itself. If I call IClassFile.getElementAt(offset) on HasMap$Entry with the same offset, 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(). Summary: - IClassFile.getElementAt(constructor_offset) returns the enclosing type instead of binary method - SourceMapper.getSourceRange() for some binary constr. returns UNKNOWN_RANGE so that: - - IClassFile.getElementAt(constructor_offset) returns null - - ISourceReference.getSourceRange() returns null for binary constr. Please notice, that in this case the binary constructor *has* the appropriated source code, so it *should* have source range. To reproduce the bug: 1) open HashMap *class file* from JDK 1.5 (the source should be attached to the jdk). 2) The navigation in Java editor will *not* work if you select the Entry(int h, K k, V v, Entry<K,V> n) constructor in the outline. 3) Create breakpoint at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor: protected void setSelection(ISourceReference reference, boolean moveCursor) In RC1 on the line 1995 is the call to the reference.getSourceRange(). The "reference" variable looks in debugger as: Entry(int, K, V, java.util.HashMap.Entry<K,V>) [in Entry [in HashMap$Entry.class [in java.util [in F:\java\jdk1.5.0\jre\lib\rt.jar [in Test]]]]] The source range returned at line 1995 is null. This is NOT the error in JavaEditor, because I've got similar problem in the completely different code which is not related to JavaEditor. Same behavoir for HashIterator() constructor in HashMap. This bug seems to be similar to the bug 119249. The difference is probably that HashMap.Entry is a *static* class, and HashMap.HashIterator an abstract class.
In 3.2RC2 still the same error. I have also realized, that the "Show source of selected element only" button on the Java editor toolbar doesn't work too - in 3.1, if cursor is inside of HashMap.Entry constructor, the code of constructor only could be shown in editor, in 3.2 the whole inner class wil be shown (because source range for constructor is "unknown").
Will consider post 3.2
Seems to be fixed in 3.3-3.4. Verified with 3.4 RC3
Changing resolution to WORKSFORME since no action was taken to fix this particular bug.