Bug 41019

Summary: org.eclipse.jdt.core.Signature cannot resolve complex type that has package name starting with letters as any primitive type
Product: [Eclipse Project] JDT Reporter: Kelvin Cheung <kelvinhc>
Component: CoreAssignee: Olivier Thomann <Olivier_Thomann>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: tim_koss
Version: 2.1.1   
Target Milestone: 3.0 M3   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Kelvin Cheung CLA 2003-07-31 11:48:48 EDT
In public static char[] createCharArrayTypeSignature(char[] typeName, boolean 
isResolved), when a complex type has a package name starting with letters 
resembling any primitive types, eg. "interation.test.MyData" 
or "longtest.MyData", it resolves to the primitive type, but not the correct 
complex type.  The reason is that in createCharArrayTypeSignature, it has a big 
switch statement, and the comparison method CharOperation.fragmentEquals does a 
check simiar to "start with". 

	switch (typeName[0]) {
		// primitive type?
		case 'b' :
			if (CharOperation.fragmentEquals(BOOLEAN, typeName, 0, 
true)) {
				sig = new char[arrayCount+1];
				sig[arrayCount] = C_BOOLEAN;
				break;
			} else if (CharOperation.fragmentEquals(BYTE, typeName, 
0, true)) {
				sig = new char[arrayCount+1];
				sig[arrayCount] = C_BYTE;
				break;
			}
		...
		case 'i':
			if (CharOperation.fragmentEquals(INT, typeName, 0, 
true)) {
				sig = new char[arrayCount+1];
				sig[arrayCount] = C_INT;
				break;
			}

This is the call stack:
org.eclipse.jdt.core.Signature.createCharArrayTypeSignature(char[], boolean) 
line: 435
org.eclipse.jdt.core.Signature.createTypeSignature(char[], boolean) line: 414
org.eclipse.jdt.internal.core.SourceMethod.getReturnType() line: 127
com.ibm.etools.java.adapters.jdom.JavaMethodJDOMAdaptor.setReturnType() line: 
258
com.ibm.etools.java.adapters.jdom.JavaMethodJDOMAdaptor.reflectValues() line: 
183
com.ibm.etools.java.adapters.jdom.JavaMethodJDOMAdaptor
(com.ibm.etools.java.adapters.ReflectionAdaptor).reflectValuesIfNecessary() 
line: 121
com.ibm.etools.java.adapters.jdom.JavaMethodJDOMAdaptor
(com.ibm.etools.java.adapters.JavaReflectionAdaptor).reflectValuesIfNecessary() 
line: 251
Comment 1 Olivier Thomann CLA 2003-07-31 12:43:58 EDT
Reproduced. I am investigating.
Comment 2 Olivier Thomann CLA 2003-07-31 13:04:21 EDT
Fixed and released in HEAD.
Regression tests added.
Comment 3 David Audel CLA 2003-08-28 06:01:04 EDT
Verified
Comment 4 Tim Koss CLA 2003-09-17 14:10:48 EDT
would it be possible to get this fix backported to the 2.1.2 stream