Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Generics lost on IField when coming from .class files
Generics lost on IField when coming from .class files [message #259595] Fri, 17 April 2009 09:14 Go to next message
Eclipse UserFriend
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 #259601 is a reply to message #259595] Fri, 17 April 2009 09:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.domain.invalid

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
>
Re: Generics lost on IField when coming from .class files [message #259605 is a reply to message #259601] Fri, 17 April 2009 09:31 Go to previous messageGo to next message
Eclipse UserFriend
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)
Re: Generics lost on IField when coming from .class files [message #259609 is a reply to message #259605] Fri, 17 April 2009 09:53 Go to previous messageGo to next message
Eclipse UserFriend
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)

Sorry, i read again your message. My previous message was bad.

What i meant is that a generic IField in a .java file exported in Java 6
version lost its generic type when it's read from the .class file.
Meanwhile, the return type and the parameters types of an IMethod keep
their generics.

That's why it seems to be a bug.

Hope it helps ...
Re: Generics lost on IField when coming from .class files [message #259613 is a reply to message #259605] Fri, 17 April 2009 10:04 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: Generics lost on IField when coming from .class files [message #259617 is a reply to message #259595] Fri, 17 April 2009 10:47 Go to previous message
Eclipse UserFriend
Romain Dervaux a écrit :
> 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.
I opened bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=272706.
It is under investigation. Fix looks simple.
Please add yourself to the CC list.
--
Olivier
Previous Topic:How to add superinterface to IType
Next Topic:Retrieving fully qualified names of method and field signatures.
Goto Forum:
  


Current Time: Sat Apr 19 12:02:19 EDT 2025

Powered by FUDForum. Page generated in 0.03374 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top