View | Details | Raw Unified | Return to bug 128877
Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/model/JavaSearchBugsTests.java (-6 / +35 lines)
Lines 47-53 Link Here
47
//	org.eclipse.jdt.internal.codeassist.SelectionEngine.DEBUG = true;
47
//	org.eclipse.jdt.internal.codeassist.SelectionEngine.DEBUG = true;
48
//	TESTS_PREFIX =  "testBug110060";
48
//	TESTS_PREFIX =  "testBug110060";
49
//	TESTS_NAMES = new String[] { "testBug126330" };
49
//	TESTS_NAMES = new String[] { "testBug126330" };
50
//	TESTS_NUMBERS = new int[] { 124469 };
50
//	TESTS_NUMBERS = new int[] { 128877 };
51
//	TESTS_RANGE = new int[] { 83304, -1 };
51
//	TESTS_RANGE = new int[] { 83304, -1 };
52
	}
52
	}
53
53
Lines 5162-5176 Link Here
5162
 */
5162
 */
5163
public void testBug110291() throws CoreException {
5163
public void testBug110291() throws CoreException {
5164
	workingCopies = new ICompilationUnit[1];
5164
	workingCopies = new ICompilationUnit[1];
5165
	workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b110291/TestXX.java",
5165
	workingCopies[0] = getWorkingCopy("/JavaSearchBugs/src/b110291/Test110291XX.java",
5166
		"package b110291;\n" + 
5166
		"package b110291;\n" + 
5167
		"public class TestXX {\n" + 
5167
		"public class Test110291XX {\n" + 
5168
		"	class TestYY {}" +
5168
		"	class Test110291YY {}" +
5169
		"}\n"
5169
		"}\n"
5170
	);
5170
	);
5171
	search("Test", CONSTRUCTOR, DECLARATIONS, SearchPattern.R_PREFIX_MATCH);
5171
	search("Test110291", CONSTRUCTOR, DECLARATIONS, SearchPattern.R_PREFIX_MATCH);
5172
	assertSearchResults(
5172
	assertSearchResults(
5173
		"src/b110291/TestXX.java b110291.TestXX$TestYY [TestYY] EXACT_MATCH"
5173
		"src/b110291/Test110291XX.java b110291.Test110291XX$Test110291YY [Test110291YY] EXACT_MATCH"
5174
	);
5174
	);
5175
}
5175
}
5176
5176
Lines 5805-5808 Link Here
5805
	);
5805
	);
5806
}
5806
}
5807
5807
5808
/**
5809
 * Bug 128877: [search] reports inexistent IMethod for binary constructor of inner class
5810
 * @see "https://bugs.eclipse.org/bugs/show_bug.cgi?id=128877"
5811
 */
5812
public void testBug128877a() throws CoreException {
5813
	IType type = getPackageFragment("JavaSearchBugs", "lib/b128877.jar", "pack").getClassFile("Test.class").getType();
5814
	IMethod method = type.getMethod("Test", new String[0]);
5815
	search(method, REFERENCES);
5816
	assertSearchResults(
5817
		"lib/b128877.jar pack.X$Sub(pack.X) EXACT_MATCH"
5818
	);
5819
}
5820
public void testBug128877b() throws CoreException {
5821
	IType type = getPackageFragment("JavaSearchBugs", "lib/b128877.jar", "pack").getClassFile("Test.class").getType();
5822
	IMethod method = type.getMethod("Test", new String[] { "Ljava.lang.String;" });
5823
	search(method, REFERENCES);
5824
	assertSearchResults(
5825
		"lib/b128877.jar pack.X$Sub(pack.X, java.lang.String) EXACT_MATCH"
5826
	);
5827
}
5828
public void testBug128877c() throws CoreException {
5829
	IType type = getPackageFragment("JavaSearchBugs", "lib/b128877.jar", "pack").getClassFile("Test.class").getType();
5830
	IMethod method = type.getMethod("foo128877", new String[] { "I" });
5831
	search(method, REFERENCES);
5832
	assertSearchResults(
5833
		"lib/b128877.jar pack.X$Sub(pack.X) EXACT_MATCH"
5834
	);
5835
}
5836
5808
}
5837
}
(-)workspace/JavaSearchBugs/.classpath (+1 lines)
Lines 9-14 Link Here
9
	<classpathentry kind="lib" path="lib/b124469.jar" sourcepath="/JavaSearchBugs/lib/b124469.jar" rootpath=""/>
9
	<classpathentry kind="lib" path="lib/b124469.jar" sourcepath="/JavaSearchBugs/lib/b124469.jar" rootpath=""/>
10
	<classpathentry kind="lib" path="lib/b125178.jar" sourcepath="" rootpath=""/>
10
	<classpathentry kind="lib" path="lib/b125178.jar" sourcepath="" rootpath=""/>
11
	<classpathentry kind="lib" path="lib/b126330.jar"/>
11
	<classpathentry kind="lib" path="lib/b126330.jar"/>
12
	<classpathentry kind="lib" path="lib/b128877.jar" sourcepath="/JavaSearchBugs/lib/b128877.jar" rootpath=""/>
12
	<classpathentry kind="lib" path="lib/JavaSearch15.jar" sourcepath="/JavaSearchBugs/lib/JavaSearch15.jar" rootpath=""/>
13
	<classpathentry kind="lib" path="lib/JavaSearch15.jar" sourcepath="/JavaSearchBugs/lib/JavaSearch15.jar" rootpath=""/>
13
	<classpathentry sourcepath="lib" kind="lib" path="lib"/>
14
	<classpathentry sourcepath="lib" kind="lib" path="lib"/>
14
    <classpathentry kind="output" path="bin"/>
15
    <classpathentry kind="output" path="bin"/>
(-)workspace/JavaSearchBugs/lib/b128877.jar (+15 lines)
Added Link Here
1
PKU[4META-INF/MANIFEST.MFþÊóMÌËLK-.Ñ
2
K-*ÎÌϳR0Ô3àåâåPK²îPKU[4pack/Test.classuŽMOÂ@†ßéò¡ 
3
ž½U6˜0/&&$? Ü·uÅElI[ŒË“‰€?Ê8»$7ٙݙyŸw>¿Þ?tpP‚E(ÏEüŒd^”àSñ,‚™H&Ám4•qAð.T¢ŠK‚í?	ÎUz'+°Q®Á…G¨‡*‘7‹§Hf#Í$¡¦±˜?E¦ôUtŠ•ªáÚ°Ohùá?á°ÈT2ék;/2ÍùÓä…ïÓ´sÚëu»Ìôzš^ø•aºÈby­´_Y[œhÁDè£#/Íÿ¿Î¤+ÇoØz凅
4
GÏmT9֖œ·
5
ÀÅÎJ|ÎÙúOìq{9°!®£aú»h®0gF	Ðo„»? 5‚°‡}³vËÌ·¿PKîw¡ÏPKU[4pack/Test.java+HLÎNLOU(ÒÖ¼\¥I9™É
6
É9‰ÅÅ
7
!©Å%
8
Õ¼\œ ††¦Bu-Œ\R”™—®P\R-ËÏLQHËÏ74²°07×ÈÌ+Q¨€HPK“w]†QdPKU[4pack/X$Sub.classmPMOÂ@œ¥…B[QðEåPЈx?cbHLH/µ`ÅjmM[ü_”ă?Àe|» 4Í6ûæÍ̛}_ߟê8RcPŸ­ÑcmPîN†
9
d†”¨{v1$¢{',Ÿ1$Í«E؅ã9Ñ%ƒfü‚•>ƒÜöoíÖGB…„
10
ҒQé«ÔÉêXEŽ&Üù~ý¼Ùl4Hft¸:c:ž}3yÚAϺ6CÎôG–Û·‡×sPæyts™™AÌëŪ¹–7®u£ÀñÆ->YÂO²Í?7þcPÂ0
11
øÈ?MZOן#ûÚáóƒSN¡Ï³ƒ¶k…¡*8 Ö,yQ(”è¹-™e³|t‹ÑQ?$<E·+ª9’©¿A­N¡W¥wd^q?þi!O?X&AëTé$&	ò(Âncn×&çk3»“)6—Vª˜ÄM’¦ jma£a»"OQhö°/TŒ¾ûPK"UËËl1PKU[4pack/X.class-NMkÂ@}ccZ­úê¡¡ç/‚Põ¯›¸´«é¦äÃÿåIðÐÐ%N’î°oæ½7ÃÌßíúà#ÁúñÑßÙ0	ýƒ8	?úÓ_Gl¿)­Š¡5?m	æ2ÝK-t<´az?Òò£üŽd¶Q"	ƒ ?E²™ªø¿h_*'8A³í•à†i™År¥*ÛÚ=W«	Þ»Ö2[&"ÏencÀ}ÍÄ$,#>‚cp?ê_Áh3ók´ç8g.¸ŒV-è2zMç‡Z{¬±‡>g—½'þCwPK+È@Dá#PKU[4pack/X.java+HLÎNLOU(ÒÖ¼\¥I9™É
12
É9‰ÅÅ
13
14
Õ¼\œE™e‰%©P±àÒ$…ÔŠ’Ô¼”b…?Ôâ°N ¨†&„É™–Ÿohdaan®a i
15
©…©.)ÊÌKW(.)‚©-.-H-Ò	ÀU1PKBÏ2¾p—PKU[4²îMETA-INF/MANIFEST.MFþÊPKU[4îw¡Ïapack/Test.classPKU[4“w]†Qdºpack/Test.javaPKU[4"UËËl1Gpack/X$Sub.classPKU[4+È@Dá#ñpack/X.classPKU[4BÏ2¾p—pack/X.javaPKpµ
(-)search/org/eclipse/jdt/internal/core/search/matching/MatchLocator.java (-33 / +24 lines)
Lines 471-509 Link Here
471
		if (reader != null) {
471
		if (reader != null) {
472
			IBinaryMethod[] methods = reader.getMethods();
472
			IBinaryMethod[] methods = reader.getMethods();
473
			if (methods != null) {
473
			if (methods != null) {
474
				// build arguments names
474
				boolean firstIsSynthetic = false;
475
				boolean firstIsSynthetic = false;
475
				if (reader.isMember() && method.isConstructor() && !Flags.isStatic(reader.getModifiers())) { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=48261
476
				if (reader.isMember() && method.isConstructor() && !Flags.isStatic(reader.getModifiers())) { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=48261
476
					firstIsSynthetic = true;
477
					firstIsSynthetic = true;
477
					argCount++;
478
					argCount++;
478
				}
479
				}
479
				nextMethod : for (int i = 0, methodsLength = methods.length; i < methodsLength; i++) {
480
				char[][] argumentTypeNames = new char[argCount][];
480
					IBinaryMethod binaryMethod = methods[i];
481
				for (int i = 0; i < argCount; i++) {
481
					char[] selector = binaryMethod.isConstructor() ? type.getElementName().toCharArray() : binaryMethod.getSelector();
482
					char[] typeName = null;
482
					if (CharOperation.equals(selector, method.selector)) {
483
					if (i == 0 && firstIsSynthetic) {
483
						char[] signature = binaryMethod.getGenericSignature();
484
						typeName = type.getDeclaringType().getFullyQualifiedName().toCharArray();
484
						if (signature == null) signature = binaryMethod.getMethodDescriptor();
485
					} else if (arguments != null) {
485
						char[][] parameterTypes = Signature.getParameterTypes(signature);
486
						TypeReference typeRef = arguments[firstIsSynthetic ? i - 1 : i].type;
486
						if (argCount != parameterTypes.length) continue nextMethod;
487
						typeName = CharOperation.concatWith(typeRef.getTypeName(), '.');
487
						if (arguments != null) {
488
						for (int k = 0, dim = typeRef.dimensions(); k < dim; k++)
488
							for (int j = 0; j < argCount; j++) {
489
							typeName = CharOperation.concat(typeName, new char[] {'[', ']'});
489
								char[] typeName;
490
					}
490
								if (j == 0 && firstIsSynthetic) {
491
					if (typeName == null) {
491
									typeName = type.getDeclaringType().getFullyQualifiedName().toCharArray();
492
						// invalid type name
492
								} else {
493
						return null;
493
									TypeReference typeRef = arguments[firstIsSynthetic ? j - 1 : j].type;
494
					}
494
									typeName = CharOperation.concatWith(typeRef.getTypeName(), '.');
495
					argumentTypeNames[i] = typeName;
495
									for (int k = 0, dim = typeRef.dimensions(); k < dim; k++)
496
				}
496
										typeName = CharOperation.concat(typeName, new char[] {'[', ']'});
497
				
497
								}
498
				// return binary method
498
								char[] parameterTypeName = ClassFileMatchLocator.convertClassFileFormat(parameterTypes[j]);
499
				return createBinaryMethodHandle(type, method.selector, argumentTypeNames);
499
								if (!CharOperation.endsWith(Signature.toCharArray(Signature.getTypeErasure(parameterTypeName)), typeName))
500
									continue nextMethod;
501
								parameterTypes[j] = parameterTypeName;
502
							}
503
						}
504
						return createMethodHandle(type, new String(selector), CharOperation.toStrings(parameterTypes));
505
					}
506
				}
507
			}
500
			}
508
		}
501
		}
509
		return null;
502
		return null;
Lines 514-521 Link Here
514
		for (int i = 0; i < argCount; i++) {
507
		for (int i = 0; i < argCount; i++) {
515
			TypeReference typeRef = arguments[i].type;
508
			TypeReference typeRef = arguments[i].type;
516
			char[] typeName = CharOperation.concatWith(typeRef.getParameterizedTypeName(), '.');
509
			char[] typeName = CharOperation.concatWith(typeRef.getParameterizedTypeName(), '.');
517
//			for (int j = 0, dim = typeRef.dimensions(); j < dim; j++)
518
//				typeName = CharOperation.concat(typeName, new char[] {'[', ']'});
519
			parameterTypeSignatures[i] = Signature.createTypeSignature(typeName, false);
510
			parameterTypeSignatures[i] = Signature.createTypeSignature(typeName, false);
520
		}
511
		}
521
	}
512
	}
Lines 525-531 Link Here
525
/*
516
/*
526
 * Create binary method handle
517
 * Create binary method handle
527
 */
518
 */
528
IMethod createBinaryMethodHandle(IType type, char[] methodSelector, char[][] argumentTypeNames, MatchLocator locator) {
519
IMethod createBinaryMethodHandle(IType type, char[] methodSelector, char[][] argumentTypeNames) {
529
	ClassFileReader reader = MatchLocator.classFileReader(type);
520
	ClassFileReader reader = MatchLocator.classFileReader(type);
530
	if (reader != null) {
521
	if (reader != null) {
531
		IBinaryMethod[] methods = reader.getMethods();
522
		IBinaryMethod[] methods = reader.getMethods();
Lines 533-539 Link Here
533
			int argCount = argumentTypeNames == null ? 0 : argumentTypeNames.length;
524
			int argCount = argumentTypeNames == null ? 0 : argumentTypeNames.length;
534
			nextMethod : for (int i = 0, methodsLength = methods.length; i < methodsLength; i++) {
525
			nextMethod : for (int i = 0, methodsLength = methods.length; i < methodsLength; i++) {
535
				IBinaryMethod binaryMethod = methods[i];
526
				IBinaryMethod binaryMethod = methods[i];
536
				char[] selector = binaryMethod.getSelector();
527
				char[] selector = binaryMethod.isConstructor() ? type.getElementName().toCharArray() : binaryMethod.getSelector();
537
				if (CharOperation.equals(selector, methodSelector)) {
528
				if (CharOperation.equals(selector, methodSelector)) {
538
					char[] signature = binaryMethod.getGenericSignature();
529
					char[] signature = binaryMethod.getGenericSignature();
539
					if (signature == null) signature = binaryMethod.getMethodDescriptor();
530
					if (signature == null) signature = binaryMethod.getMethodDescriptor();
Lines 547-553 Link Here
547
							parameterTypes[j] = parameterTypeName;
538
							parameterTypes[j] = parameterTypeName;
548
						}
539
						}
549
					}
540
					}
550
					return (IMethod) locator.createMethodHandle(type, new String(selector), CharOperation.toStrings(parameterTypes));
541
					return (IMethod) createMethodHandle(type, new String(selector), CharOperation.toStrings(parameterTypes));
551
				}
542
				}
552
			}
543
			}
553
		}
544
		}
(-)search/org/eclipse/jdt/internal/core/search/matching/MethodLocator.java (-1 / +1 lines)
Lines 496-502 Link Here
496
			}
496
			}
497
			parameterTypes[i] = typeName;
497
			parameterTypes[i] = typeName;
498
		}
498
		}
499
		method = locator.createBinaryMethodHandle(type, methodBinding.selector, parameterTypes, locator);
499
		method = locator.createBinaryMethodHandle(type, methodBinding.selector, parameterTypes);
500
	} else {
500
	} else {
501
		String[] parameterTypes = new String[parameterLength];
501
		String[] parameterTypes = new String[parameterLength];
502
		for (int i = 0; i  < parameterLength; i++) {
502
		for (int i = 0; i  < parameterLength; i++) {

Return to bug 128877