Bug 272706 - [Model] Generics lost on IField when coming from .class files
Summary: [Model] Generics lost on IField when coming from .class files
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.5   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.5 M7   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-17 10:42 EDT by Olivier Thomann CLA
Modified: 2009-04-28 09:11 EDT (History)
2 users (show)

See Also:


Attachments
Proposed fix + regression test (2.36 KB, patch)
2009-04-17 10:53 EDT, Olivier Thomann CLA
no flags Details | Diff
Additional patch for tests (2.13 KB, patch)
2009-04-23 09:48 EDT, Frederic Fusier CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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