Community
Participate
Working Groups
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!
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?
Thanks for the explanation. OK to close. Maybe the documentation could be improved on.
Reopening to mark as WORKSFORME.
Works as designed.