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 |
} |