Bug 245689 - [model] binary IType#resolveType(String) returns null for imported type that is not referenced in class file
Summary: [model] binary IType#resolveType(String) returns null for imported type that ...
Status: CLOSED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Jay Arthanareeswaran CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
: 337563 434098 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-08-29 09:12 EDT by Markus Keller CLA
Modified: 2020-05-11 12:35 EDT (History)
5 users (show)

See Also:


Attachments
Testcase (1.56 KB, patch)
2011-06-13 06:35 EDT, Jay Arthanareeswaran CLA
no flags Details | Diff
Patch under test (4.57 KB, patch)
2014-09-15 13:52 EDT, Jay Arthanareeswaran 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 2008-08-29 09:12:01 EDT
I20080827-0935

- import org.eclipse.swt plug-in and the platform-specific fragment as binary projects
- open org.eclipse.swt.graphics.Cursor
- show Javadoc for constructor Cursor(Device, int) (either hover or show in Javadoc view)
- click the link SWT.CURSOR_ARROW under "See Also:"
- in JavaElementLinks#resolveType(IType, String), we call IType#resolveType(String) on the binary type 'Cursor' with argument "SWT"
=> should return {{"org.eclipse.swt", "SWT"}} but returns null

Works fine with SWT from source. Also works fine in the JDK (e.g. java.lang.ThreadGroup.setMaxPriority(int) has a link to Thread#MIN_PRIORITY).
Comment 1 Markus Keller CLA 2008-10-06 13:31:52 EDT
The unresolvable types are all *-imported. Adapting summary.

The same problem occurs in I20080930-0921 when I open javax.annotation.Generated from jdk6 and try to resolve "Documented", "Retention", etc. which are imported with "import java.lang.annotation.*;".
Comment 2 Jerome Lanneluc CLA 2008-10-13 11:20:38 EDT
IType.resolveType(...) doesn't consider the attached source. As a result, SWT is not found since it is not referenced in the .class file.

To solve this, we will need to consider the attached source if any.
Comment 3 Jerome Lanneluc CLA 2008-11-12 06:48:27 EST
Lowering priority since this bug no longer blocks another one.
Comment 4 Markus Keller CLA 2011-06-10 13:42:12 EDT
This also breaks e.g. the link to type "Target" in the Javadoc of the SafeVarargs annotation.

This bug should not be P5, since it really is an issue for users.
Comment 5 Olivier Thomann CLA 2011-06-10 13:44:22 EDT
Jay, please investigate.
Comment 6 Jay Arthanareeswaran CLA 2011-06-13 06:32:26 EDT
The issue is the class Cursor is referring to SWT only through Javadoc and no code references to the same. This means the generated code doesn't have the corresponding import since we only use an on-demand import. Hence the type can't be resolved.

Olivier, what can we do here?
Comment 7 Jay Arthanareeswaran CLA 2011-06-13 06:35:18 EDT
Created attachment 197879 [details]
Testcase

A small test I used. Will use it later when we have a fix. The test will pass if we uncomment the method parameter.
Comment 8 Markus Keller CLA 2011-06-14 10:52:26 EDT
(In reply to comment #6)
> Olivier, what can we do here?

If you're asking how to fix the bug, see comment 2:
> IType.resolveType(...) doesn't consider the attached source. As a result, SWT
> is not found since it is not referenced in the .class file.
> 
> To solve this, we will need to consider the attached source if any.

=> The DOM AST contains the imports.
Comment 9 Markus Keller CLA 2014-05-06 11:19:25 EDT
*** Bug 337563 has been marked as a duplicate of this bug. ***
Comment 10 Markus Keller CLA 2014-05-06 11:29:56 EDT
*** Bug 434098 has been marked as a duplicate of this bug. ***
Comment 11 Jay Arthanareeswaran CLA 2014-09-15 13:52:39 EDT
Created attachment 247085 [details]
Patch under test
Comment 12 Jay Arthanareeswaran CLA 2014-09-15 23:41:05 EDT
(In reply to Jayaprakash Arthanareeswaran from comment #11)
> Created attachment 247085 [details]
> Patch under test

In hindsight, this is correct. This just searches all the types with the given name in the name lookup and returns the results and probably works because UI filters in the right ones. But IType#resolveType() should not be returning those that are irrelevant to this type.
Comment 13 Jay Arthanareeswaran CLA 2015-05-12 03:58:07 EDT
This needs closer inspection. Moving to 4.6.
Comment 14 Markus Keller CLA 2015-06-02 12:23:34 EDT
Example in JDK 8: Javadoc of java.lang.Comparable contains ...

 * specify a {@linkplain Comparator comparator}.<p>

... at the end of the second paragraph. This link doesn't work in the Javadoc view. There's an import java.util.*;, and Comparator is not referenced in code.
Comment 15 Jay Arthanareeswaran CLA 2016-04-05 04:34:00 EDT
No progress yet and unlikely to get time during 4.6. Moving out.
Comment 16 Manoj N Palat CLA 2018-05-21 06:06:54 EDT
Bulk move out of 4.8
Comment 17 Eclipse Genie CLA 2020-05-11 12:35:17 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.