Bug 458845 - "Calculate Uses" should take generics into account
Summary: "Calculate Uses" should take generics into account
Status: RESOLVED WONTFIX
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.5   Edit
Hardware: PC Mac OS X
: P3 major with 2 votes (vote)
Target Milestone: ---   Edit
Assignee: PDE-UI-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: investigate
Depends on:
Blocks:
 
Reported: 2015-01-30 11:52 EST by Andreas Sewe CLA
Modified: 2019-10-29 05:34 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Sewe CLA 2015-01-30 11:52:07 EST
We at Code Recommenders just stumbled over the following situation and the fact that "Calculate Uses" does not generate a uses directive for package org.eclipse.recommenders.utils.names. Here's the situation:

  Bundle org.eclipse.recommenders.jdt
  - package org.eclipse.recommenders.jdt
    - class AstBindings
      - Optional<ITypeName> toTypeName(...) 

  Bundle org.eclipse.recommenders.utils
  - package org.eclipse.recommenders.utils.names
    - class ITypeName

One of our client bundles, requiring both the org.eclipse.recommenders.jdt and org.eclipse.recommenders.utils bundles, called toTypeName().get(). Now, on the caller's side, this generates a "checkcast org.eclipse.recommenders.utils.names.ITypeName" under the hood, but all "Calculate Uses" produced was a constraint on "com.google.common.base.Optional". Thus, at runtime, a ClassCastException ensued.

This whole scenario reminds me a bit of the "pathological" case of <https://bugs.eclipse.org/bugs/show_bug.cgi?id=167968#c15>, only that generics and the checkcasts they result in are baked into the Java language.

It would be great if "Calculate Uses" could take generics into account, generating uses directives for the packages of the upper type bounds of generic return types.
Comment 1 Andreas Sewe CLA 2015-10-13 04:24:19 EDT
Dear PDE team,

what would be needed to fix this bug? We (Eclipse Code Recommenders) have just been bitten (Bug 479540) by this bug *again*.

Here's why: We are in the habit of regularly "calculating" our uses constraints (because maintaining them manually is just a pain). Alas, each time we hit "Calculate Uses" now, due to this bug, we have to *remember* to *manually* add certain uses constraints that PDE misses. This is almost as much pain as maintaining all uses constraints manually, making this feature almost useless to us. And all because we use Optional<T> (which will become more common in APIs, as Java 8 is spreading).
Comment 2 Curtis Windatt CLA 2015-10-13 11:27:56 EDT
This is filed against API tools, are you referring to the API Use Scan to find all uses of types?  Generics are already supposed to be supported there.

Or is the the automated dependency management in the manifest editor? If so, I can't really say how much effort adding in generic support would be.  Probably significant as the code is much older and less extensible than API tools.
Comment 3 Andreas Sewe CLA 2015-10-13 11:34:03 EDT
(In reply to Curtis Windatt from comment #2)
> This is filed against API tools, are you referring to the API Use Scan to
> find all uses of types?  Generics are already supposed to be supported there.
> 
> Or is the the automated dependency management in the manifest editor? If so,
> I can't really say how much effort adding in generic support would be. 
> Probably significant as the code is much older and less extensible than API
> tools.

Hi, I am referring to the "Calculate Uses" button on the "Runtime" tab in the manifest editor. Apologies if I picked the wrong component.
Comment 4 Curtis Windatt CLA 2015-10-13 13:43:32 EDT
(In reply to Andreas Sewe from comment #3)
> Hi, I am referring to the "Calculate Uses" button on the "Runtime" tab in
> the manifest editor. Apologies if I picked the wrong component.

Moving to PDE UI then.  I'm guessing this would require significant investment of time (vs just a bugfix for API tools).  Vikas, let me know what you think after investigating the code.  The code likely has never been updated for any modern java code constructs, but hopefully it is based on JDT...
Comment 5 Vikas Chandra CLA 2016-04-22 16:22:04 EDT
Can you attach a small sample project to recreate this behavior?
Comment 6 Eclipse Genie CLA 2019-04-21 15:03:14 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.

If you have further information on the current state of the bug, please add it. 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.
Comment 7 Lars Vogel CLA 2019-10-29 05:34:13 EDT
This bug is marked as stale for some time. If it is still relevant for the current release, please reopen and remove the stalebug whiteboard tag.