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

(-)src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java (-2 / +3 lines)
Lines 6481-6488 Link Here
6481
	
6481
	
6482
	/*
6482
	/*
6483
	 * Check unique instance of generic method bindings 
6483
	 * Check unique instance of generic method bindings 
6484
	 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=104293
6484
	 */
6485
	 */
6485
	public void _test0214() throws JavaModelException {
6486
	public void test0214() throws JavaModelException {
6486
    	this.workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/);
6487
    	this.workingCopy = getWorkingCopy("/Converter15/src/X.java", true/*resolve*/);
6487
    	String contents =
6488
    	String contents =
6488
			"public class X {\n" + 
6489
			"public class X {\n" + 
Lines 6529-6535 Link Here
6529
		invocation = (MethodInvocation) expression;
6530
		invocation = (MethodInvocation) expression;
6530
		IMethodBinding methodBinding2 = invocation.resolveMethodBinding();
6531
		IMethodBinding methodBinding2 = invocation.resolveMethodBinding();
6531
		
6532
		
6532
		assertTrue("Not equals", methodBinding == methodBinding2);
6533
		assertTrue("Not identical", methodBinding == methodBinding2);
6533
	}
6534
	}
6534
	
6535
	
6535
}
6536
}
(-)model/org/eclipse/jdt/internal/core/util/BindingKeyResolver.java (-3 / +2 lines)
Lines 37-43 Link Here
37
import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
37
import org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment;
38
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
38
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
39
import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
39
import org.eclipse.jdt.internal.compiler.lookup.PackageBinding;
40
import org.eclipse.jdt.internal.compiler.lookup.ParameterizedGenericMethodBinding;
41
import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
40
import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
42
import org.eclipse.jdt.internal.compiler.lookup.RawTypeBinding;
41
import org.eclipse.jdt.internal.compiler.lookup.RawTypeBinding;
43
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
42
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
Lines 204-212 Link Here
204
			return;
203
			return;
205
		TypeBinding[] arguments = getTypeBindingArguments();
204
		TypeBinding[] arguments = getTypeBindingArguments();
206
		if (arguments.length != this.methodBinding.typeVariables().length)
205
		if (arguments.length != this.methodBinding.typeVariables().length)
207
			this.methodBinding = new ParameterizedGenericMethodBinding(this.methodBinding, (RawTypeBinding) null, this.environment);
206
			this.methodBinding = this.environment.createParameterizedGenericMethod(this.methodBinding, (RawTypeBinding) null);
208
		else
207
		else
209
	 		this.methodBinding = new ParameterizedGenericMethodBinding(this.methodBinding, arguments, this.environment);
208
	 		this.methodBinding = this.environment.createParameterizedGenericMethod(this.methodBinding, arguments);
210
		this.compilerBinding = this.methodBinding;
209
		this.compilerBinding = this.methodBinding;
211
	}
210
	}
212
	
211
	
(-)codeassist/org/eclipse/jdt/internal/codeassist/CompletionEngine.java (-1 / +1 lines)
Lines 3886-3892 Link Here
3886
				continue next;
3886
				continue next;
3887
			
3887
			
3888
			if (minTypeArgLength != 0) {
3888
			if (minTypeArgLength != 0) {
3889
				method = new ParameterizedGenericMethodBinding(method, typeArgTypes, scope.environment());
3889
				method = scope.environment().createParameterizedGenericMethod(method, typeArgTypes);
3890
			}
3890
			}
3891
			
3891
			
3892
			if (minArgLength > method.parameters.length)
3892
			if (minArgLength > method.parameters.length)
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java (-2 / +2 lines)
Lines 621-627 Link Here
621
		fieldBinding.modifiers = modifiers;
621
		fieldBinding.modifiers = modifiers;
622
	}
622
	}
623
623
624
	public void checkForErasedCandidateCollisions() {
624
	public void checkParameterizedSuperTypeCollisions() {
625
		// check for parameterized interface collisions (when different parameterizations occur)
625
		// check for parameterized interface collisions (when different parameterizations occur)
626
		SourceTypeBinding sourceType = referenceContext.binding;
626
		SourceTypeBinding sourceType = referenceContext.binding;
627
		ReferenceBinding[] interfaces = sourceType.superInterfaces;
627
		ReferenceBinding[] interfaces = sourceType.superInterfaces;
Lines 687-693 Link Here
687
		ReferenceBinding[] memberTypes = referenceContext.binding.memberTypes;
687
		ReferenceBinding[] memberTypes = referenceContext.binding.memberTypes;
688
		if (memberTypes != null && memberTypes != Binding.NO_MEMBER_TYPES)
688
		if (memberTypes != null && memberTypes != Binding.NO_MEMBER_TYPES)
689
			for (int i = 0, size = memberTypes.length; i < size; i++)
689
			for (int i = 0, size = memberTypes.length; i < size; i++)
690
				 ((SourceTypeBinding) memberTypes[i]).scope.checkForErasedCandidateCollisions();
690
				 ((SourceTypeBinding) memberTypes[i]).scope.checkParameterizedSuperTypeCollisions();
691
	}
691
	}
692
692
693
	private void checkForInheritedMemberTypes(SourceTypeBinding sourceType) {
693
	private void checkForInheritedMemberTypes(SourceTypeBinding sourceType) {
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedGenericMethodBinding.java (-4 / +4 lines)
Lines 46-52 Link Here
46
			        // incompatible due to wrong arity
46
			        // incompatible due to wrong arity
47
			        return new ProblemMethodBinding(originalMethod, originalMethod.selector, substitutes, ProblemReasons.TypeParameterArityMismatch);
47
			        return new ProblemMethodBinding(originalMethod, originalMethod.selector, substitutes, ProblemReasons.TypeParameterArityMismatch);
48
				}
48
				}
49
				methodSubstitute = new ParameterizedGenericMethodBinding(originalMethod, substitutes, scope.environment());
49
				methodSubstitute = scope.environment().createParameterizedGenericMethod(originalMethod, substitutes);
50
				break computeSubstitutes;
50
				break computeSubstitutes;
51
			}
51
			}
52
			
52
			
Lines 172-178 Link Here
172
			return null; // incompatible
172
			return null; // incompatible
173
		if (substitutes.length == 0) {
173
		if (substitutes.length == 0) {
174
			// raw generic method inferred
174
			// raw generic method inferred
175
			return new ParameterizedGenericMethodBinding(originalMethod, (RawTypeBinding)null, scope.environment());
175
			return scope.environment().createParameterizedGenericMethod(originalMethod, (RawTypeBinding)null);
176
		}
176
		}
177
		// apply inferred variable substitutions - replacing unresolved variable with original ones in param method
177
		// apply inferred variable substitutions - replacing unresolved variable with original ones in param method
178
		TypeBinding[] resolvedSubstitutes = substitutes;
178
		TypeBinding[] resolvedSubstitutes = substitutes;
Lines 186-192 Link Here
186
				resolvedSubstitutes[i] = substitutes[i];
186
				resolvedSubstitutes[i] = substitutes[i];
187
			}
187
			}
188
		}
188
		}
189
		return new ParameterizedGenericMethodBinding(originalMethod, resolvedSubstitutes, scope.environment());		
189
		return scope.environment().createParameterizedGenericMethod(originalMethod, resolvedSubstitutes);		
190
	}
190
	}
191
	
191
	
192
	private static TypeBinding[] resolveSubstituteConstraints(Scope scope, TypeVariableBinding[] typeVariables, TypeBinding[] substitutes, boolean considerEXTENDSConstraints, Map collectedSubstitutes) {
192
	private static TypeBinding[] resolveSubstituteConstraints(Scope scope, TypeVariableBinding[] typeVariables, TypeBinding[] substitutes, boolean considerEXTENDSConstraints, Map collectedSubstitutes) {
Lines 493-499 Link Here
493
				TypeBinding[] rawArguments = new TypeBinding[length];
493
				TypeBinding[] rawArguments = new TypeBinding[length];
494
				for (int i = 0; i < length; i++)
494
				for (int i = 0; i < length; i++)
495
					rawArguments[i] =  environment.convertToRawType(originalVariables[i].erasure());
495
					rawArguments[i] =  environment.convertToRawType(originalVariables[i].erasure());
496
				this.tiebreakMethod = new ParameterizedGenericMethodBinding(this.originalMethod, rawArguments, this.environment);
496
				this.tiebreakMethod = this.environment.createParameterizedGenericMethod(this.originalMethod, rawArguments);
497
//			}
497
//			}
498
		} 
498
		} 
499
		return this.tiebreakMethod;
499
		return this.tiebreakMethod;
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java (-1 / +1 lines)
Lines 304-310 Link Here
304
	// must substitute to detect cases like:
304
	// must substitute to detect cases like:
305
	//   <T1 extends X<T1>> void dup() {}
305
	//   <T1 extends X<T1>> void dup() {}
306
	//   <T2 extends X<T2>> Object dup() {return null;}
306
	//   <T2 extends X<T2>> Object dup() {return null;}
307
	return new ParameterizedGenericMethodBinding(method, vars, env);
307
	return env.createParameterizedGenericMethod(method, vars);
308
}
308
}
309
/*
309
/*
310
 * declaringUniqueKey dot selector genericSignature
310
 * declaringUniqueKey dot selector genericSignature
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java (-2 / +6 lines)
Lines 192-204 Link Here
192
		System.arraycopy(resolvedImports, 0, resolvedImports = new ImportBinding[index], 0, index);
192
		System.arraycopy(resolvedImports, 0, resolvedImports = new ImportBinding[index], 0, index);
193
	imports = resolvedImports;
193
	imports = resolvedImports;
194
}
194
}
195
void checkParameterizedTypeBounds() {
195
196
/**
197
 * Perform deferred check specific to parameterized types: bound checks, supertype collisions
198
 */
199
void checkParameterizedTypes() {
196
	if (compilerOptions().sourceLevel < ClassFileConstants.JDK1_5) return;
200
	if (compilerOptions().sourceLevel < ClassFileConstants.JDK1_5) return;
197
201
198
	for (int i = 0, length = topLevelTypes.length; i < length; i++) {
202
	for (int i = 0, length = topLevelTypes.length; i < length; i++) {
199
		ClassScope scope = topLevelTypes[i].scope;
203
		ClassScope scope = topLevelTypes[i].scope;
200
		scope.checkParameterizedTypeBounds();
204
		scope.checkParameterizedTypeBounds();
201
		scope.checkForErasedCandidateCollisions();
205
		scope.checkParameterizedSuperTypeCollisions();
202
	}
206
	}
203
}
207
}
204
/*
208
/*
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/MethodVerifier15.java (-1 / +1 lines)
Lines 445-451 Link Here
445
			arguments[i] = inheritedTypeVariables[i].upperBound();
445
			arguments[i] = inheritedTypeVariables[i].upperBound();
446
	}
446
	}
447
	ParameterizedGenericMethodBinding substitute =
447
	ParameterizedGenericMethodBinding substitute =
448
		new ParameterizedGenericMethodBinding(inheritedMethod, arguments, this.environment);
448
		this.environment.createParameterizedGenericMethod(inheritedMethod, arguments);
449
449
450
	// interface I { <T> void foo(T t); }
450
	// interface I { <T> void foo(T t); }
451
	// class X implements I { public <T extends I> void foo(T t) {} }
451
	// class X implements I { public <T extends I> void foo(T t) {} }
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java (-22 / +105 lines)
Lines 26-31 Link Here
26
import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable;
26
import org.eclipse.jdt.internal.compiler.util.SimpleLookupTable;
27
27
28
public class LookupEnvironment implements ProblemReasons, TypeConstants {
28
public class LookupEnvironment implements ProblemReasons, TypeConstants {
29
	
29
	final static int BUILD_FIELDS_AND_METHODS = 4;
30
	final static int BUILD_FIELDS_AND_METHODS = 4;
30
	final static int BUILD_TYPE_HIERARCHY = 1;
31
	final static int BUILD_TYPE_HIERARCHY = 1;
31
	final static int CHECK_AND_SET_IMPORTS = 2;
32
	final static int CHECK_AND_SET_IMPORTS = 2;
Lines 60-65 Link Here
60
	private SimpleLookupTable uniqueParameterizedTypeBindings;
61
	private SimpleLookupTable uniqueParameterizedTypeBindings;
61
	private SimpleLookupTable uniqueRawTypeBindings;
62
	private SimpleLookupTable uniqueRawTypeBindings;
62
	private SimpleLookupTable uniqueWildcardBindings;
63
	private SimpleLookupTable uniqueWildcardBindings;
64
	private SimpleLookupTable uniqueParameterizedGenericMethodBindings;
63
	
65
	
64
	public CompilationUnitDeclaration unitBeingCompleted = null; // only set while completing units
66
	public CompilationUnitDeclaration unitBeingCompleted = null; // only set while completing units
65
67
Lines 79-84 Link Here
79
	this.uniqueParameterizedTypeBindings = new SimpleLookupTable(3);
81
	this.uniqueParameterizedTypeBindings = new SimpleLookupTable(3);
80
	this.uniqueRawTypeBindings = new SimpleLookupTable(3);
82
	this.uniqueRawTypeBindings = new SimpleLookupTable(3);
81
	this.uniqueWildcardBindings = new SimpleLookupTable(3);
83
	this.uniqueWildcardBindings = new SimpleLookupTable(3);
84
	this.uniqueParameterizedGenericMethodBindings = new SimpleLookupTable(3);
82
	this.accessRestrictions = new HashMap(3);
85
	this.accessRestrictions = new HashMap(3);
83
	
86
	
84
	this.classFilePool = ClassFilePool.newInstance();
87
	this.classFilePool = ClassFilePool.newInstance();
Lines 198-204 Link Here
198
201
199
	for (int i = this.lastCompletedUnitIndex + 1; i <= this.lastUnitIndex; i++) {
202
	for (int i = this.lastCompletedUnitIndex + 1; i <= this.lastUnitIndex; i++) {
200
		CompilationUnitScope unitScope = (this.unitBeingCompleted = this.units[i]).scope;
203
		CompilationUnitScope unitScope = (this.unitBeingCompleted = this.units[i]).scope;
201
		unitScope.checkParameterizedTypeBounds();
204
		unitScope.checkParameterizedTypes();
202
		unitScope.buildFieldsAndMethods();
205
		unitScope.buildFieldsAndMethods();
203
		this.units[i] = null; // release unnecessary reference to the parsed unit
206
		this.units[i] = null; // release unnecessary reference to the parsed unit
204
	}
207
	}
Lines 249-255 Link Here
249
252
250
	(this.unitBeingCompleted = parsedUnit).scope.checkAndSetImports();
253
	(this.unitBeingCompleted = parsedUnit).scope.checkAndSetImports();
251
	parsedUnit.scope.connectTypeHierarchy();
254
	parsedUnit.scope.connectTypeHierarchy();
252
	parsedUnit.scope.checkParameterizedTypeBounds();	
255
	parsedUnit.scope.checkParameterizedTypes();	
253
	if (buildFieldsAndMethods)
256
	if (buildFieldsAndMethods)
254
		parsedUnit.scope.buildFieldsAndMethods();
257
		parsedUnit.scope.buildFieldsAndMethods();
255
	this.unitBeingCompleted = null;
258
	this.unitBeingCompleted = null;
Lines 556-572 Link Here
556
	return packageBinding;
559
	return packageBinding;
557
}
560
}
558
561
562
public ParameterizedGenericMethodBinding createParameterizedGenericMethod(MethodBinding genericMethod, RawTypeBinding rawType) {
563
564
	// cached info is array of already created parameterized types for this type
565
	ParameterizedGenericMethodBinding[] cachedInfo = (ParameterizedGenericMethodBinding[])this.uniqueParameterizedGenericMethodBindings.get(genericMethod);
566
	boolean needToGrow = false;
567
	int index = 0;
568
	if (cachedInfo != null){
569
		nextCachedMethod : 
570
			// iterate existing parameterized for reusing one with same type arguments if any
571
			for (int max = cachedInfo.length; index < max; index++){
572
				ParameterizedGenericMethodBinding cachedMethod = cachedInfo[index];
573
				if (cachedMethod == null) break nextCachedMethod;
574
				if (!cachedMethod.isRaw) continue nextCachedMethod;
575
				if (cachedMethod.declaringClass != (rawType == null ? genericMethod.declaringClass : rawType)) continue nextCachedMethod;
576
				return cachedMethod;
577
		}
578
		needToGrow = true;
579
	} else {
580
		cachedInfo = new ParameterizedGenericMethodBinding[5];
581
		this.uniqueParameterizedGenericMethodBindings.put(genericMethod, cachedInfo);
582
	}
583
	// grow cache ?
584
	int length = cachedInfo.length;
585
	if (needToGrow && index == length){
586
		System.arraycopy(cachedInfo, 0, cachedInfo = new ParameterizedGenericMethodBinding[length*2], 0, length);
587
		this.uniqueParameterizedGenericMethodBindings.put(genericMethod, cachedInfo);
588
	}
589
	// add new binding
590
	ParameterizedGenericMethodBinding parameterizedGenericMethod = new ParameterizedGenericMethodBinding(genericMethod, rawType, this);
591
	cachedInfo[index] = parameterizedGenericMethod;
592
	return parameterizedGenericMethod;
593
}
594
595
public ParameterizedGenericMethodBinding createParameterizedGenericMethod(MethodBinding genericMethod, TypeBinding[] typeArguments) {
596
597
	// cached info is array of already created parameterized types for this type
598
	ParameterizedGenericMethodBinding[] cachedInfo = (ParameterizedGenericMethodBinding[])this.uniqueParameterizedGenericMethodBindings.get(genericMethod);
599
	int argLength = typeArguments == null ? 0: typeArguments.length;
600
	boolean needToGrow = false;
601
	int index = 0;
602
	if (cachedInfo != null){
603
		nextCachedMethod : 
604
			// iterate existing parameterized for reusing one with same type arguments if any
605
			for (int max = cachedInfo.length; index < max; index++){
606
				ParameterizedGenericMethodBinding cachedMethod = cachedInfo[index];
607
				if (cachedMethod == null) break nextCachedMethod;
608
				if (cachedMethod.isRaw) continue nextCachedMethod;
609
				TypeBinding[] cachedArguments = cachedMethod.typeArguments;
610
				int cachedArgLength = cachedArguments == null ? 0 : cachedArguments.length;
611
				if (argLength != cachedArgLength) continue nextCachedMethod;
612
				for (int j = 0; j < cachedArgLength; j++){
613
					if (typeArguments[j] != cachedArguments[j]) continue nextCachedMethod;
614
				}
615
				// all arguments match, reuse current
616
				return cachedMethod;
617
		}
618
		needToGrow = true;
619
	} else {
620
		cachedInfo = new ParameterizedGenericMethodBinding[5];
621
		this.uniqueParameterizedGenericMethodBindings.put(genericMethod, cachedInfo);
622
	}
623
	// grow cache ?
624
	int length = cachedInfo.length;
625
	if (needToGrow && index == length){
626
		System.arraycopy(cachedInfo, 0, cachedInfo = new ParameterizedGenericMethodBinding[length*2], 0, length);
627
		this.uniqueParameterizedGenericMethodBindings.put(genericMethod, cachedInfo);
628
	}
629
	// add new binding
630
	ParameterizedGenericMethodBinding parameterizedGenericMethod = new ParameterizedGenericMethodBinding(genericMethod, typeArguments, this);
631
	cachedInfo[index] = parameterizedGenericMethod;
632
	return parameterizedGenericMethod;
633
}
634
559
public ParameterizedTypeBinding createParameterizedType(ReferenceBinding genericType, TypeBinding[] typeArguments, ReferenceBinding enclosingType) {
635
public ParameterizedTypeBinding createParameterizedType(ReferenceBinding genericType, TypeBinding[] typeArguments, ReferenceBinding enclosingType) {
560
636
561
	// cached info is array of already created parameterized types for this type
637
	// cached info is array of already created parameterized types for this type
562
	ParameterizedTypeBinding[] cachedInfo = (ParameterizedTypeBinding[])this.uniqueParameterizedTypeBindings.get(genericType);
638
	ParameterizedTypeBinding[] cachedInfo = (ParameterizedTypeBinding[])this.uniqueParameterizedTypeBindings.get(genericType);
563
	int argLength = typeArguments == null ? 0: typeArguments.length;
639
	int argLength = typeArguments == null ? 0: typeArguments.length;
564
	boolean needToGrow = false;
640
	boolean needToGrow = false;
641
	int index = 0;
565
	if (cachedInfo != null){
642
	if (cachedInfo != null){
566
		nextCachedType : 
643
		nextCachedType : 
567
			// iterate existing parameterized for reusing one with same type arguments if any
644
			// iterate existing parameterized for reusing one with same type arguments if any
568
			for (int i = 0, max = cachedInfo.length; i < max; i++){
645
			for (int max = cachedInfo.length; index < max; index++){
569
			    ParameterizedTypeBinding cachedType = cachedInfo[i];
646
			    ParameterizedTypeBinding cachedType = cachedInfo[index];
647
			    if (cachedType == null) break nextCachedType;
570
			    if (cachedType.type != genericType) continue nextCachedType; // remain of unresolved type
648
			    if (cachedType.type != genericType) continue nextCachedType; // remain of unresolved type
571
			    if (cachedType.enclosingType() != enclosingType) continue nextCachedType;
649
			    if (cachedType.enclosingType() != enclosingType) continue nextCachedType;
572
				TypeBinding[] cachedArguments = cachedType.arguments;
650
				TypeBinding[] cachedArguments = cachedType.arguments;
Lines 580-597 Link Here
580
		}
658
		}
581
		needToGrow = true;
659
		needToGrow = true;
582
	} else {
660
	} else {
583
		cachedInfo = new ParameterizedTypeBinding[1];
661
		cachedInfo = new ParameterizedTypeBinding[5];
584
		this.uniqueParameterizedTypeBindings.put(genericType, cachedInfo);
662
		this.uniqueParameterizedTypeBindings.put(genericType, cachedInfo);
585
	}
663
	}
586
	// grow cache ?
664
	// grow cache ?
587
	if (needToGrow){
665
	int length = cachedInfo.length;
588
		int length = cachedInfo.length;
666
	if (needToGrow && index == length){
589
		System.arraycopy(cachedInfo, 0, cachedInfo = new ParameterizedTypeBinding[length+1], 0, length);
667
		System.arraycopy(cachedInfo, 0, cachedInfo = new ParameterizedTypeBinding[length*2], 0, length);
590
		this.uniqueParameterizedTypeBindings.put(genericType, cachedInfo);
668
		this.uniqueParameterizedTypeBindings.put(genericType, cachedInfo);
591
	}
669
	}
592
	// add new binding
670
	// add new binding
593
	ParameterizedTypeBinding parameterizedType = new ParameterizedTypeBinding(genericType,typeArguments, enclosingType, this);
671
	ParameterizedTypeBinding parameterizedType = new ParameterizedTypeBinding(genericType,typeArguments, enclosingType, this);
594
	cachedInfo[cachedInfo.length-1] = parameterizedType;
672
	cachedInfo[index] = parameterizedType;
595
	return parameterizedType;
673
	return parameterizedType;
596
}
674
}
597
675
Lines 599-609 Link Here
599
	// cached info is array of already created raw types for this type
677
	// cached info is array of already created raw types for this type
600
	RawTypeBinding[] cachedInfo = (RawTypeBinding[])this.uniqueRawTypeBindings.get(genericType);
678
	RawTypeBinding[] cachedInfo = (RawTypeBinding[])this.uniqueRawTypeBindings.get(genericType);
601
	boolean needToGrow = false;
679
	boolean needToGrow = false;
680
	int index = 0;
602
	if (cachedInfo != null){
681
	if (cachedInfo != null){
603
		nextCachedType : 
682
		nextCachedType : 
604
			// iterate existing parameterized for reusing one with same type arguments if any
683
			// iterate existing parameterized for reusing one with same type arguments if any
605
			for (int i = 0, max = cachedInfo.length; i < max; i++){
684
			for (int max = cachedInfo.length; index < max; index++){
606
			    RawTypeBinding cachedType = cachedInfo[i];
685
			    RawTypeBinding cachedType = cachedInfo[index];
686
			    if (cachedType == null) break nextCachedType;
607
			    if (cachedType.type != genericType) continue nextCachedType; // remain of unresolved type
687
			    if (cachedType.type != genericType) continue nextCachedType; // remain of unresolved type
608
			    if (cachedType.enclosingType() != enclosingType) continue nextCachedType;
688
			    if (cachedType.enclosingType() != enclosingType) continue nextCachedType;
609
				// all enclosing type match, reuse current
689
				// all enclosing type match, reuse current
Lines 615-628 Link Here
615
		this.uniqueRawTypeBindings.put(genericType, cachedInfo);
695
		this.uniqueRawTypeBindings.put(genericType, cachedInfo);
616
	}
696
	}
617
	// grow cache ?
697
	// grow cache ?
618
	if (needToGrow){
698
	int length = cachedInfo.length;
619
		int length = cachedInfo.length;
699
	if (needToGrow && index == length){
620
		System.arraycopy(cachedInfo, 0, cachedInfo = new RawTypeBinding[length+1], 0, length);
700
		System.arraycopy(cachedInfo, 0, cachedInfo = new RawTypeBinding[length*2], 0, length);
621
		this.uniqueRawTypeBindings.put(genericType, cachedInfo);
701
		this.uniqueRawTypeBindings.put(genericType, cachedInfo);
622
	}
702
	}
623
	// add new binding
703
	// add new binding
624
	RawTypeBinding rawType = new RawTypeBinding(genericType, enclosingType, this);
704
	RawTypeBinding rawType = new RawTypeBinding(genericType, enclosingType, this);
625
	cachedInfo[cachedInfo.length-1] = rawType;
705
	cachedInfo[index] = rawType;
626
	return rawType;
706
	return rawType;
627
	
707
	
628
}
708
}
Lines 634-644 Link Here
634
		genericType = ReferenceBinding.LUB_GENERIC;
714
		genericType = ReferenceBinding.LUB_GENERIC;
635
	WildcardBinding[] cachedInfo = (WildcardBinding[])this.uniqueWildcardBindings.get(genericType);
715
	WildcardBinding[] cachedInfo = (WildcardBinding[])this.uniqueWildcardBindings.get(genericType);
636
	boolean needToGrow = false;
716
	boolean needToGrow = false;
717
	int index = 0;
637
	if (cachedInfo != null){
718
	if (cachedInfo != null){
638
		nextCachedType : 
719
		nextCachedType : 
639
			// iterate existing wildcards for reusing one with same information if any
720
			// iterate existing wildcards for reusing one with same information if any
640
			for (int i = 0, max = cachedInfo.length; i < max; i++){
721
			for (int max = cachedInfo.length; index < max; index++){
641
			    WildcardBinding cachedType = cachedInfo[i];
722
			    WildcardBinding cachedType = cachedInfo[index];
723
			    if (cachedType == null) break nextCachedType;
642
			    if (cachedType.genericType != genericType) continue nextCachedType; // remain of unresolved type
724
			    if (cachedType.genericType != genericType) continue nextCachedType; // remain of unresolved type
643
			    if (cachedType.rank != rank) continue nextCachedType;
725
			    if (cachedType.rank != rank) continue nextCachedType;
644
			    if (cachedType.boundKind != boundKind) continue nextCachedType;
726
			    if (cachedType.boundKind != boundKind) continue nextCachedType;
Lines 656-673 Link Here
656
		}
738
		}
657
		needToGrow = true;
739
		needToGrow = true;
658
	} else {
740
	} else {
659
		cachedInfo = new WildcardBinding[1];
741
		cachedInfo = new WildcardBinding[10];
660
		this.uniqueWildcardBindings.put(genericType, cachedInfo);
742
		this.uniqueWildcardBindings.put(genericType, cachedInfo);
661
	}
743
	}
662
	// grow cache ?
744
	// grow cache ?
663
	if (needToGrow){
745
	int length = cachedInfo.length;
664
		int length = cachedInfo.length;
746
	if (needToGrow && index == length){
665
		System.arraycopy(cachedInfo, 0, cachedInfo = new WildcardBinding[length+1], 0, length);
747
		System.arraycopy(cachedInfo, 0, cachedInfo = new WildcardBinding[length*2], 0, length);
666
		this.uniqueWildcardBindings.put(genericType, cachedInfo);
748
		this.uniqueWildcardBindings.put(genericType, cachedInfo);
667
	}
749
	}
668
	// add new binding
750
	// add new binding
669
	WildcardBinding wildcard = new WildcardBinding(genericType, rank, bound, otherBounds, boundKind, this);
751
	WildcardBinding wildcard = new WildcardBinding(genericType, rank, bound, otherBounds, boundKind, this);
670
	cachedInfo[cachedInfo.length-1] = wildcard;
752
	cachedInfo[index] = wildcard;
671
	return wildcard;
753
	return wildcard;
672
}
754
}
673
755
Lines 1027-1032 Link Here
1027
	this.uniqueParameterizedTypeBindings = new SimpleLookupTable(3);
1109
	this.uniqueParameterizedTypeBindings = new SimpleLookupTable(3);
1028
	this.uniqueRawTypeBindings = new SimpleLookupTable(3);
1110
	this.uniqueRawTypeBindings = new SimpleLookupTable(3);
1029
	this.uniqueWildcardBindings = new SimpleLookupTable(3);
1111
	this.uniqueWildcardBindings = new SimpleLookupTable(3);
1112
	this.uniqueParameterizedGenericMethodBindings = new SimpleLookupTable(3);
1030
	
1113
	
1031
	for (int i = this.units.length; --i >= 0;)
1114
	for (int i = this.units.length; --i >= 0;)
1032
		this.units[i] = null;
1115
		this.units[i] = null;
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/RawTypeBinding.java (-1 / +1 lines)
Lines 54-60 Link Here
54
		if (originalMethod.typeVariables == Binding.NO_TYPE_VARIABLES || originalMethod.isStatic()) {
54
		if (originalMethod.typeVariables == Binding.NO_TYPE_VARIABLES || originalMethod.isStatic()) {
55
			return super.createParameterizedMethod(originalMethod);
55
			return super.createParameterizedMethod(originalMethod);
56
		}
56
		}
57
		return new ParameterizedGenericMethodBinding(originalMethod, this, this.environment);
57
		return this.environment.createParameterizedGenericMethod(originalMethod, this);
58
	}
58
	}
59
	
59
	
60
	public int kind() {
60
	public int kind() {
(-)src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java (+28 lines)
Lines 30407-30410 Link Here
30407
		},
30407
		},
30408
		"");
30408
		"");
30409
}
30409
}
30410
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=108045
30411
public void test0968() {
30412
	this.runNegativeTest(
30413
		new String[] {
30414
			"X.java", //================================
30415
			"import java.util.*;\n" + 
30416
			"public class X<T0> extends ArrayList<T0> implements I<T0> {\n" + 
30417
			"}\n" + 
30418
			"interface I<T1> extends Collection {\n" + 
30419
			"}\n"
30420
		},
30421
		"----------\n" + 
30422
		"1. ERROR in X.java (at line 2)\n" + 
30423
		"	public class X<T0> extends ArrayList<T0> implements I<T0> {\n" + 
30424
		"	             ^\n" + 
30425
		"The interface Collection cannot be implemented more than once with different arguments: Collection<T0> and Collection\n" + 
30426
		"----------\n" + 
30427
		"2. WARNING in X.java (at line 2)\n" + 
30428
		"	public class X<T0> extends ArrayList<T0> implements I<T0> {\n" + 
30429
		"	             ^\n" + 
30430
		"The serializable class X does not declare a static final serialVersionUID field of type long\n" + 
30431
		"----------\n" + 
30432
		"3. WARNING in X.java (at line 4)\n" + 
30433
		"	interface I<T1> extends Collection {\n" + 
30434
		"	                        ^^^^^^^^^^\n" + 
30435
		"Collection is a raw type. References to generic type Collection<E> should be parameterized\n" + 
30436
		"----------\n");
30437
}
30410
}
30438
}

Return to bug 104293