Bug 41019 - org.eclipse.jdt.core.Signature cannot resolve complex type that has package name starting with letters as any primitive type
Summary: org.eclipse.jdt.core.Signature cannot resolve complex type that has package n...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 3.0 M3   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-07-31 11:48 EDT by Kelvin Cheung CLA
Modified: 2003-09-17 14:10 EDT (History)
1 user (show)

See Also:


Attachments

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