Bug 272706

Summary: [Model] Generics lost on IField when coming from .class files
Product: [Eclipse Project] JDT Reporter: Olivier Thomann <Olivier_Thomann>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: romain.dervaux, srikanth_sankaran
Version: 3.5   
Target Milestone: 3.5 M7   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed fix + regression test
none
Additional patch for tests none

Description Olivier Thomann CLA 2009-04-17 10:42:33 EDT
From the jdt newgroup,

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.
======================================================================
It looks like the implementation of org.eclipse.jdt.internal.core.BinaryField.getTypeSignature() is boggus:

public String getTypeSignature() throws JavaModelException {
	IBinaryField info = (IBinaryField) getElementInfo();
	return new String(ClassFile.translatedName(info.getTypeName()));
}

It should check if the info has a generic signature.
Comment 1 Olivier Thomann CLA 2009-04-17 10:53:19 EDT
Created attachment 132249 [details]
Proposed fix + regression test

I'll run all existing tests to validate the fix.
Comment 2 Olivier Thomann CLA 2009-04-17 10:53:44 EDT
Jérôme, please review.
Comment 3 Jerome Lanneluc CLA 2009-04-17 11:12:17 EDT
Looks good
Comment 4 Olivier Thomann CLA 2009-04-17 11:25:12 EDT
Released for 3.5M7.
Regression test added in org.eclipse.jdt.core.tests.model.ClassFileTests#testGenericFieldGetTypeSignature
Comment 5 Frederic Fusier CLA 2009-04-23 09:48:48 EDT
Created attachment 132930 [details]
Additional patch for tests

This patch is needed to have no failure while running ClassFileTests test suite with an 1.4 VM.
Comment 6 Frederic Fusier CLA 2009-04-23 09:49:32 EDT
(In reply to comment #5)
> Created an attachment (id=132930) [details]
> Additional patch for tests
> 
Released in HEAD
Comment 7 Srikanth Sankaran CLA 2009-04-28 09:11:55 EDT
Verified for 3.5M7 using I20090426-2000