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

(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/BinaryTypeBinding.java (-33 / +33 lines)
Lines 160-166 Link Here
160
	   of generics.
160
	   of generics.
161
	 */
161
	 */
162
	char[] typeSignature = binaryType.getGenericSignature();
162
	char[] typeSignature = binaryType.getGenericSignature();
163
	this.typeVariables = typeSignature != null && typeSignature.length > 0 && typeSignature[0] == '<'
163
	this.typeVariables = typeSignature != null && typeSignature.length > 0 && typeSignature[0] == Util.C_GENERIC_START
164
		? null // is initialized in cachePartsFrom (called from LookupEnvironment.createBinaryTypeFrom())... must set to null so isGenericType() answers true
164
		? null // is initialized in cachePartsFrom (called from LookupEnvironment.createBinaryTypeFrom())... must set to null so isGenericType() answers true
165
		: Binding.NO_TYPE_VARIABLES;
165
		: Binding.NO_TYPE_VARIABLES;
166
166
Lines 310-316 Link Here
310
		if (typeSignature != null) {
310
		if (typeSignature != null) {
311
			// ClassSignature = ParameterPart(optional) super_TypeSignature interface_signature
311
			// ClassSignature = ParameterPart(optional) super_TypeSignature interface_signature
312
			wrapper = new SignatureWrapper(typeSignature);
312
			wrapper = new SignatureWrapper(typeSignature);
313
			if (wrapper.signature[wrapper.start] == '<') {
313
			if (wrapper.signature[wrapper.start] == Util.C_GENERIC_START) {
314
				// ParameterPart = '<' ParameterSignature(s) '>'
314
				// ParameterPart = '<' ParameterSignature(s) '>'
315
				wrapper.start++; // skip '<'
315
				wrapper.start++; // skip '<'
316
				this.typeVariables = createTypeVariables(wrapper, true, missingTypeNames);
316
				this.typeVariables = createTypeVariables(wrapper, true, missingTypeNames);
Lines 467-477 Link Here
467
		int numOfParams = 0;
467
		int numOfParams = 0;
468
		char nextChar;
468
		char nextChar;
469
		int index = 0; // first character is always '(' so skip it
469
		int index = 0; // first character is always '(' so skip it
470
		while ((nextChar = methodDescriptor[++index]) != ')') {
470
		while ((nextChar = methodDescriptor[++index]) != Util.C_PARAM_END) {
471
			if (nextChar != '[') {
471
			if (nextChar != Util.C_ARRAY) {
472
				numOfParams++;
472
				numOfParams++;
473
				if (nextChar == 'L')
473
				if (nextChar == Util.C_RESOLVED)
474
					while ((nextChar = methodDescriptor[++index]) != ';'){/*empty*/}
474
					while ((nextChar = methodDescriptor[++index]) != Util.C_NAME_END){/*empty*/}
475
			}
475
			}
476
		}
476
		}
477
477
Lines 495-503 Link Here
495
			index = 1;
495
			index = 1;
496
			int end = 0;   // first character is always '(' so skip it
496
			int end = 0;   // first character is always '(' so skip it
497
			for (int i = 0; i < numOfParams; i++) {
497
			for (int i = 0; i < numOfParams; i++) {
498
				while ((nextChar = methodDescriptor[++end]) == '['){/*empty*/}
498
				while ((nextChar = methodDescriptor[++end]) == Util.C_ARRAY){/*empty*/}
499
				if (nextChar == 'L')
499
				if (nextChar == Util.C_RESOLVED)
500
					while ((nextChar = methodDescriptor[++end]) != ';'){/*empty*/}
500
					while ((nextChar = methodDescriptor[++end]) != Util.C_NAME_END){/*empty*/}
501
501
502
				if (i >= startIndex) {   // skip the synthetic arg if necessary
502
				if (i >= startIndex) {   // skip the synthetic arg if necessary
503
					parameters[i - startIndex] = this.environment.getTypeFromSignature(methodDescriptor, index, end, false, this, missingTypeNames);
503
					parameters[i - startIndex] = this.environment.getTypeFromSignature(methodDescriptor, index, end, false, this, missingTypeNames);
Lines 526-532 Link Here
526
		methodModifiers |= ExtraCompilerModifiers.AccGenericSignature;
526
		methodModifiers |= ExtraCompilerModifiers.AccGenericSignature;
527
		// MethodTypeSignature = ParameterPart(optional) '(' TypeSignatures ')' return_typeSignature ['^' TypeSignature (optional)]
527
		// MethodTypeSignature = ParameterPart(optional) '(' TypeSignatures ')' return_typeSignature ['^' TypeSignature (optional)]
528
		SignatureWrapper wrapper = new SignatureWrapper(methodSignature, use15specifics);
528
		SignatureWrapper wrapper = new SignatureWrapper(methodSignature, use15specifics);
529
		if (wrapper.signature[wrapper.start] == '<') {
529
		if (wrapper.signature[wrapper.start] == Util.C_GENERIC_START) {
530
			// <A::Ljava/lang/annotation/Annotation;>(Ljava/lang/Class<TA;>;)TA;
530
			// <A::Ljava/lang/annotation/Annotation;>(Ljava/lang/Class<TA;>;)TA;
531
			// ParameterPart = '<' ParameterSignature(s) '>'
531
			// ParameterPart = '<' ParameterSignature(s) '>'
532
			wrapper.start++; // skip '<'
532
			wrapper.start++; // skip '<'
Lines 534-546 Link Here
534
			wrapper.start++; // skip '>'
534
			wrapper.start++; // skip '>'
535
		}
535
		}
536
536
537
		if (wrapper.signature[wrapper.start] == '(') {
537
		if (wrapper.signature[wrapper.start] == Util.C_PARAM_START) {
538
			wrapper.start++; // skip '('
538
			wrapper.start++; // skip '('
539
			if (wrapper.signature[wrapper.start] == ')') {
539
			if (wrapper.signature[wrapper.start] == Util.C_PARAM_END) {
540
				wrapper.start++; // skip ')'
540
				wrapper.start++; // skip ')'
541
			} else {
541
			} else {
542
				java.util.ArrayList types = new java.util.ArrayList(2);
542
				java.util.ArrayList types = new java.util.ArrayList(2);
543
				while (wrapper.signature[wrapper.start] != ')')
543
				while (wrapper.signature[wrapper.start] != Util.C_PARAM_END)
544
					types.add(this.environment.getTypeFromTypeSignature(wrapper, typeVars, this, missingTypeNames));
544
					types.add(this.environment.getTypeFromTypeSignature(wrapper, typeVars, this, missingTypeNames));
545
				wrapper.start++; // skip ')'
545
				wrapper.start++; // skip ')'
546
				int numParam = types.size();
546
				int numParam = types.size();
Lines 557-569 Link Here
557
		// always retrieve return type (for constructors, its V for void - will be ignored)
557
		// always retrieve return type (for constructors, its V for void - will be ignored)
558
		returnType = this.environment.getTypeFromTypeSignature(wrapper, typeVars, this, missingTypeNames);
558
		returnType = this.environment.getTypeFromTypeSignature(wrapper, typeVars, this, missingTypeNames);
559
559
560
		if (!wrapper.atEnd() && wrapper.signature[wrapper.start] == '^') {
560
		if (!wrapper.atEnd() && wrapper.signature[wrapper.start] == Util.C_EXCEPTION_START) {
561
			// attempt to find each exception if it exists in the cache (otherwise - resolve it when requested)
561
			// attempt to find each exception if it exists in the cache (otherwise - resolve it when requested)
562
			java.util.ArrayList types = new java.util.ArrayList(2);
562
			java.util.ArrayList types = new java.util.ArrayList(2);
563
			do {
563
			do {
564
				wrapper.start++; // skip '^'
564
				wrapper.start++; // skip '^'
565
				types.add(this.environment.getTypeFromTypeSignature(wrapper, typeVars, this, missingTypeNames));
565
				types.add(this.environment.getTypeFromTypeSignature(wrapper, typeVars, this, missingTypeNames));
566
			} while (!wrapper.atEnd() && wrapper.signature[wrapper.start] == '^');
566
			} while (!wrapper.atEnd() && wrapper.signature[wrapper.start] == Util.C_EXCEPTION_START);
567
			exceptions = new ReferenceBinding[types.size()];
567
			exceptions = new ReferenceBinding[types.size()];
568
			types.toArray(exceptions);
568
			types.toArray(exceptions);
569
		} else { // get the exceptions the old way
569
		} else { // get the exceptions the old way
Lines 621-627 Link Here
621
				total--;
621
				total--;
622
			} else if (iClinit == -1) {
622
			} else if (iClinit == -1) {
623
				char[] methodName = method.getSelector();
623
				char[] methodName = method.getSelector();
624
				if (methodName.length == 8 && methodName[0] == '<') {
624
				if (methodName.length == 8 && methodName[0] == Util.C_GENERIC_START) {
625
					// discard <clinit>
625
					// discard <clinit>
626
					iClinit = i;
626
					iClinit = i;
627
					total--;
627
					total--;
Lines 666-686 Link Here
666
	createVariables: {
666
	createVariables: {
667
		for (int i = 1; i < length; i++) {
667
		for (int i = 1; i < length; i++) {
668
			switch(typeSignature[i]) {
668
			switch(typeSignature[i]) {
669
				case '<' :
669
				case Util.C_GENERIC_START :
670
					depth++;
670
					depth++;
671
					break;
671
					break;
672
				case '>' :
672
				case Util.C_GENERIC_END :
673
					if (--depth < 0)
673
					if (--depth < 0)
674
						break createVariables;
674
						break createVariables;
675
					break;
675
					break;
676
				case ';' :
676
				case Util.C_NAME_END :
677
					if ((depth == 0) && (i +1 < length) && (typeSignature[i+1] != ':'))
677
					if ((depth == 0) && (i +1 < length) && (typeSignature[i+1] != Util.C_COLON))
678
						pendingVariable = true;
678
						pendingVariable = true;
679
					break;
679
					break;
680
				default:
680
				default:
681
					if (pendingVariable) {
681
					if (pendingVariable) {
682
						pendingVariable = false;
682
						pendingVariable = false;
683
						int colon = CharOperation.indexOf(':', typeSignature, i);
683
						int colon = CharOperation.indexOf(Util.C_COLON, typeSignature, i);
684
						char[] variableName = CharOperation.subarray(typeSignature, i, colon);
684
						char[] variableName = CharOperation.subarray(typeSignature, i, colon);
685
						variables.add(new TypeVariableBinding(variableName, this, rank++, this.environment));
685
						variables.add(new TypeVariableBinding(variableName, this, rank++, this.environment));
686
					}
686
					}
Lines 733-739 Link Here
733
733
734
private MethodBinding findMethod(char[] methodDescriptor, char[][][] missingTypeNames) {
734
private MethodBinding findMethod(char[] methodDescriptor, char[][][] missingTypeNames) {
735
	int index = -1;
735
	int index = -1;
736
	while (methodDescriptor[++index] != '(') {
736
	while (methodDescriptor[++index] != Util.C_PARAM_START) {
737
		// empty
737
		// empty
738
	}
738
	}
739
	char[] selector = new char[index];
739
	char[] selector = new char[index];
Lines 742-752 Link Here
742
	int numOfParams = 0;
742
	int numOfParams = 0;
743
	char nextChar;
743
	char nextChar;
744
	int paramStart = index;
744
	int paramStart = index;
745
	while ((nextChar = methodDescriptor[++index]) != ')') {
745
	while ((nextChar = methodDescriptor[++index]) != Util.C_PARAM_END) {
746
		if (nextChar != '[') {
746
		if (nextChar != Util.C_ARRAY) {
747
			numOfParams++;
747
			numOfParams++;
748
			if (nextChar == 'L')
748
			if (nextChar == Util.C_RESOLVED)
749
				while ((nextChar = methodDescriptor[++index]) != ';'){/*empty*/}
749
				while ((nextChar = methodDescriptor[++index]) != Util.C_NAME_END){/*empty*/}
750
		}
750
		}
751
	}
751
	}
752
	if (numOfParams > 0) {
752
	if (numOfParams > 0) {
Lines 754-762 Link Here
754
		index = paramStart + 1;
754
		index = paramStart + 1;
755
		int end = paramStart; // first character is always '(' so skip it
755
		int end = paramStart; // first character is always '(' so skip it
756
		for (int i = 0; i < numOfParams; i++) {
756
		for (int i = 0; i < numOfParams; i++) {
757
			while ((nextChar = methodDescriptor[++end]) == '['){/*empty*/}
757
			while ((nextChar = methodDescriptor[++end]) == Util.C_ARRAY){/*empty*/}
758
			if (nextChar == 'L')
758
			if (nextChar == Util.C_RESOLVED)
759
				while ((nextChar = methodDescriptor[++end]) != ';'){/*empty*/}
759
				while ((nextChar = methodDescriptor[++end]) != Util.C_NAME_END){/*empty*/}
760
760
761
			TypeBinding param = this.environment.getTypeFromSignature(methodDescriptor, index, end, false, this, missingTypeNames);
761
			TypeBinding param = this.environment.getTypeFromSignature(methodDescriptor, index, end, false, this, missingTypeNames);
762
			if (param instanceof UnresolvedReferenceBinding) {
762
			if (param instanceof UnresolvedReferenceBinding) {
Lines 998-1007 Link Here
998
	// ParameterSignature = Identifier ':' TypeSignature
998
	// ParameterSignature = Identifier ':' TypeSignature
999
	//   or Identifier ':' TypeSignature(optional) InterfaceBound(s)
999
	//   or Identifier ':' TypeSignature(optional) InterfaceBound(s)
1000
	// InterfaceBound = ':' TypeSignature
1000
	// InterfaceBound = ':' TypeSignature
1001
	int colon = CharOperation.indexOf(':', wrapper.signature, wrapper.start);
1001
	int colon = CharOperation.indexOf(Util.C_COLON, wrapper.signature, wrapper.start);
1002
	wrapper.start = colon + 1; // skip name + ':'
1002
	wrapper.start = colon + 1; // skip name + ':'
1003
	ReferenceBinding type, firstBound = null;
1003
	ReferenceBinding type, firstBound = null;
1004
	if (wrapper.signature[wrapper.start] == ':') {
1004
	if (wrapper.signature[wrapper.start] == Util.C_COLON) {
1005
		type = this.environment.getResolvedType(TypeConstants.JAVA_LANG_OBJECT, null);
1005
		type = this.environment.getResolvedType(TypeConstants.JAVA_LANG_OBJECT, null);
1006
	} else {
1006
	} else {
1007
		TypeBinding typeFromTypeSignature = this.environment.getTypeFromTypeSignature(wrapper, existingVariables, this, missingTypeNames);
1007
		TypeBinding typeFromTypeSignature = this.environment.getTypeFromTypeSignature(wrapper, existingVariables, this, missingTypeNames);
Lines 1019-1030 Link Here
1019
	variable.superclass = type;
1019
	variable.superclass = type;
1020
1020
1021
	ReferenceBinding[] bounds = null;
1021
	ReferenceBinding[] bounds = null;
1022
	if (wrapper.signature[wrapper.start] == ':') {
1022
	if (wrapper.signature[wrapper.start] == Util.C_COLON) {
1023
		java.util.ArrayList types = new java.util.ArrayList(2);
1023
		java.util.ArrayList types = new java.util.ArrayList(2);
1024
		do {
1024
		do {
1025
			wrapper.start++; // skip ':'
1025
			wrapper.start++; // skip ':'
1026
			types.add(this.environment.getTypeFromTypeSignature(wrapper, existingVariables, this, missingTypeNames));
1026
			types.add(this.environment.getTypeFromTypeSignature(wrapper, existingVariables, this, missingTypeNames));
1027
		} while (wrapper.signature[wrapper.start] == ':');
1027
		} while (wrapper.signature[wrapper.start] == Util.C_COLON);
1028
		bounds = new ReferenceBinding[types.size()];
1028
		bounds = new ReferenceBinding[types.size()];
1029
		types.toArray(bounds);
1029
		types.toArray(bounds);
1030
	}
1030
	}

Return to bug 364890