Generics lost on IField when coming from .class files [message #259595] |
Fri, 17 April 2009 09:14  |
Eclipse User |
|
|
|
Hi
I am using the package org.eclipse.jdt.core to explore the Java Model of
..class files of libraries which are in the classpath of a Java Project.
I noticed that generics are lost for IField in .class files.
For example :
import java.util.List;
public class A {
protected List<String> myField;
}
I call IField.getTypeSignature() :
In the .java file : Ljava.util.List<Ljava.lang.String;>;
In the .class file : Ljava.util.List;
Strangely, we don't have this problem with the IMethod.
We can easily see this problem in the Outline view.
I searched for a bug report but can't find anything.
If someone can help ... :D
Thanks
|
|
|
|
|
|
Re: Generics lost on IField when coming from .class files [message #259613 is a reply to message #259605] |
Fri, 17 April 2009 10:04   |
Eclipse User |
|
|
|
Originally posted by: none.domain.invalid
Romain Dervaux a écrit :
> Name a écrit :
>> Romain Dervaux a écrit :
>>> Hi
>>>
>>> I am using the package org.eclipse.jdt.core to explore the Java Model
>>> of .class files of libraries which are in the classpath of a Java
>>> Project.
>>>
>>> I noticed that generics are lost for IField in .class files.
>>>
>>> For example :
>>>
>>> import java.util.List;
>>>
>>> public class A {
>>>
>>> protected List<String> myField;
>>> }
>>>
>>> I call IField.getTypeSignature() :
>>>
>>> In the .java file : Ljava.util.List<Ljava.lang.String;>;
>>> In the .class file : Ljava.util.List;
>>>
>>> Strangely, we don't have this problem with the IMethod.
>>
>> Are you sure ? Generics are not included in .class file for jdk <= 1.6
>> so if you really get the generics informations, maybe eclipse gets
>> generics informatons from corresponding .java file ?
>>
>>> We can easily see this problem in the Outline view.
>>> I searched for a bug report but can't find anything.
>>>
>>> If someone can help ... :D
>>> Thanks
>>>
>
> Generics are included in .class files, it is written in the
> specifications of the class file format. (JSR 202)
Wow, from 4.4.4 Signatures, i see:
Signatures are used to encode Java programming language type information
that is not part of the Java virtual machine type system, such as
generic type and method declarations and parameterized types. See The
Java Language Specification, Third Edition, for details about such types.
This kind of type information is needed to support reflection and
debugging, and by the Java compiler.
I didn't know, thanks for the tip.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03374 seconds