Bug 22148

Summary: Qlfd. vs. unqlfd. Name from IField.getTypeSignature
Product: [Eclipse Project] JDT Reporter: Stefan Braun <eclipse>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: P3    
Version: 2.0   
Target Milestone: 2.1 M2   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Stefan Braun CLA 2002-08-04 06:17:14 EDT
IField.getTypeSignature is returning different results for me, depending on if 
I use it on a binary or source type. For source types, it returns 
e.g. "QObject;" where for binary types it would return "Qjava.lang.Object;" 
(which is what I would prefer).

To reproduce, create a package called "pckg" and a class called Test in your 
runtime workspace:

package pckg;
public class Test {
	Object value;
}

E.g. in an editor part's setInput insert the following statements

IFile file = ((IFileEditorInput)input).getFile();
IProject project = file.getProject();
IJavaProject jp = JavaCore.create(project);

try {
	org.eclipse.jdt.core.IType tp = jp.findType("pckg.Test");
	org.eclipse.jdt.core.IField[] fields = tp.getFields();
	String signature = fields[0].getTypeSignature();
} catch (JavaModelException e) {
}

The string signature should be "QObject;". Now go and rename the package to 
pckg2 and you will see that signature contains "Qjava.lang.Object;".

I am using build 200206271827. Thanks for your help!
Comment 1 Jerome Lanneluc CLA 2002-08-20 07:38:17 EDT
getTypeSignature doesn't resolve names. The returned info is as it is found in 
the java element. So for binary types, this info is already resolved (in the 
class file) but for source types, it is not (unless the field is specified as:
java.lang.Object field;)

To resolve this name, use IType.resolveType(String).

Ok to close?
Comment 2 Stefan Braun CLA 2002-08-21 08:40:29 EDT
Thanks for the explanation. OK to close. 
Maybe the documentation could be improved on. 
Comment 3 Jerome Lanneluc CLA 2002-09-19 07:29:20 EDT
Reopening to mark as WORKSFORME.
Comment 4 Jerome Lanneluc CLA 2002-09-19 07:30:05 EDT
Works as designed.