Bug 152603 - [DOM] java.lang.Class qualified name is "java.lang.Class<>"
Summary: [DOM] java.lang.Class qualified name is "java.lang.Class<>"
Status: VERIFIED WONTFIX
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.7 M1   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-08-02 10:48 EDT by Scott Cowan CLA
Modified: 2010-08-04 02:23 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Scott Cowan CLA 2006-08-02 10:48:15 EDT
Define the "getName()" method invocation of "this.getClass().getName()", where "this" is any instance, to be mi.  The following code finds the qualified name of the declaring class, java.lang.Class, to be "java.lang.Class<>", and not "java.lang.Class".

org.eclipse.jdt.core.dom.MethodInvocation mi;
...
IMethodBinding methodBinding = mi.resolveMethodBinding();
String qualifiedName = methodBinding.getDeclaringClass().getQualifiedName();
Comment 1 Olivier Thomann CLA 2006-08-14 20:28:45 EDT
The class is a parameterized class with a capture as the type argument.
Since the qualified name of a capture is an empty string, the answer is right.

Martin,

What would you expect in this case?
Comment 2 Martin Aeschlimann CLA 2006-08-16 06:19:59 EDT
The empty string for captures isn't really helpful. I see two possibilities:
a. we find a notation for captures (for example use curly braces java.lang.Class<{? extends X}>)
b. we skip captures for qualified names, and define that the qualified name for a captures is its wildcard type

I guess to answer that we have to define what the real usecase of 'getQualifiedType' is. Some people use it to render a binding, some to get a canonical name for a binding, some to debug.
To render, it is better to use some own code as you need more options if qualified names should be used or not: In JDT.UI we have the BindingLabelProvider for that, which we should make API for 3.3.
To get a canonical name, clients should use getKey.

I think getQualifiedName makes most sense for type declarations (not references). I'm fine with a.) or b.) but prefer b.) for getQualifiedName
Comment 3 Olivier Thomann CLA 2007-02-13 21:52:10 EST
(In reply to comment #2)
> The empty string for captures isn't really helpful. I see two possibilities:
> a. we find a notation for captures (for example use curly braces
> java.lang.Class<{? extends X}>)
This would break existing spec.

> b. we skip captures for qualified names, and define that the qualified name for
> a captures is its wildcard type
I don't think this would be fine according to the current spec.
The '<' and '>' are required and the capture fully qualified name is an empty string.

So the actual returned value implements the current specs.

I would close as INVALID.
Comment 4 Martin Aeschlimann CLA 2007-02-14 04:19:24 EST
The spec says that the qualified name of a capture is an empty string.
But doesn't that still leave it us to define how the qualified name of a parameterized type with a capture as type argument is rendered?

In the end we want the API to produce something useful. I don't think the current sulution is helping anyone.
Comment 5 Olivier Thomann CLA 2007-02-14 10:04:30 EST
Sure, but we still need to provide a solution that is not an API breakage.
For me a) and b) would break existing API.
I don't see a way to return something else that would not break existing API.
Comment 6 Olivier Thomann CLA 2008-07-28 20:38:48 EDT
Martin,

If you see a way to solve this that is not a breaking change for existing users, let me know. Otherwise I will close as WONTFIX.
I think it would be time to fix this one or close it.
Comment 7 Martin Aeschlimann CLA 2008-07-28 23:26:50 EDT
I leave it up to you.. 
Comment 8 Olivier Thomann CLA 2010-07-28 08:49:26 EDT
Closing as WONTFIX.
There is no way we can fix this without breaking existing users.
Comment 9 Satyam Kandula CLA 2010-08-04 02:23:03 EDT
Verified for 3.7M1