View | Details | Raw Unified | Return to bug 247953 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/ast/ASTNode.java (-8 / +11 lines)
Lines 41-60 Link Here
41
	public final static int Bit16 = 0x8000;			// in javadoc comment (name ref, type ref, msg)
41
	public final static int Bit16 = 0x8000;			// in javadoc comment (name ref, type ref, msg)
42
	public final static int Bit17 = 0x10000;			// compound assigned (reference lhs)
42
	public final static int Bit17 = 0x10000;			// compound assigned (reference lhs)
43
	public final static int Bit18 = 0x20000;			// non null (expression) | onDemand (import reference)
43
	public final static int Bit18 = 0x20000;			// non null (expression) | onDemand (import reference)
44
	public final static int Bit19 = 0x40000;			// didResolve (parameterized qualified type ref/parameterized single type ref)  | empty (javadoc return statement)
44
	public final static int Bit19 = 0x40000;			// didResolve (parameterized qualified type ref/parameterized single type ref)  | empty (javadoc return statement) | needReceiverGenericCast (msg/fieldref)
45
	public final static int Bit20 = 0x80000;
45
	public final static int Bit20 = 0x80000;
46
	public final static int Bit21 = 0x100000;
46
	public final static int Bit21 = 0x100000;
47
	public final static int Bit22 = 0x200000;		// parenthesis count (expression) | used (import reference)
47
	public final static int Bit22 = 0x200000;			// parenthesis count (expression) | used (import reference)
48
	public final static int Bit23 = 0x400000;		// parenthesis count (expression)
48
	public final static int Bit23 = 0x400000;			// parenthesis count (expression)
49
	public final static int Bit24 = 0x800000;		// parenthesis count (expression)
49
	public final static int Bit24 = 0x800000;			// parenthesis count (expression)
50
	public final static int Bit25 = 0x1000000;		// parenthesis count (expression)
50
	public final static int Bit25 = 0x1000000;		// parenthesis count (expression)
51
	public final static int Bit26 = 0x2000000;		// parenthesis count (expression)
51
	public final static int Bit26 = 0x2000000;		// parenthesis count (expression)
52
	public final static int Bit27 = 0x4000000;		// parenthesis count (expression)
52
	public final static int Bit27 = 0x4000000;		// parenthesis count (expression)
53
	public final static int Bit28 = 0x8000000;		// parenthesis count (expression)
53
	public final static int Bit28 = 0x8000000;		// parenthesis count (expression)
54
	public final static int Bit29 = 0x10000000;	// parenthesis count (expression)
54
	public final static int Bit29 = 0x10000000;		// parenthesis count (expression)
55
	public final static int Bit30 = 0x20000000;	// elseif (if statement) | try block exit (try statement) | fall-through (case statement) | ignore no effect assign (expression ref) | needScope (for statement) | isAnySubRoutineEscaping (return statement) | blockExit (synchronized statement)
55
	public final static int Bit30 = 0x20000000;		// elseif (if statement) | try block exit (try statement) | fall-through (case statement) | ignore no effect assign (expression ref) | needScope (for statement) | isAnySubRoutineEscaping (return statement) | blockExit (synchronized statement)
56
	public final static int Bit31 = 0x40000000;	// local declaration reachable (local decl) | ignore raw type check (type ref) | discard entire assignment (assignment) | isSynchronized (return statement) | thenExit (if statement)
56
	public final static int Bit31 = 0x40000000;		// local declaration reachable (local decl) | ignore raw type check (type ref) | discard entire assignment (assignment) | isSynchronized (return statement) | thenExit (if statement)
57
	public final static int Bit32 = 0x80000000;	// reachable (statement)
57
	public final static int Bit32 = 0x80000000;		// reachable (statement)
58
58
59
	public final static long Bit32L = 0x80000000L;
59
	public final static long Bit32L = 0x80000000L;
60
	public final static long Bit33L = 0x100000000L;
60
	public final static long Bit33L = 0x100000000L;
Lines 112-117 Link Here
112
	// for name refs or local decls
112
	// for name refs or local decls
113
	public static final int FirstAssignmentToLocal = Bit4;
113
	public static final int FirstAssignmentToLocal = Bit4;
114
114
115
	// for msg or field references
116
	public static final int NeedReceiverGenericCast = Bit19;
117
	
115
	// for this reference
118
	// for this reference
116
	public static final int IsImplicitThis = Bit3;
119
	public static final int IsImplicitThis = Bit3;
117
120
(-)compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java (-6 / +10 lines)
Lines 210-215 Link Here
210
			|| ((this.implicitConversion & TypeIds.UNBOXING) != 0)
210
			|| ((this.implicitConversion & TypeIds.UNBOXING) != 0)
211
			|| (this.genericCast != null)) {
211
			|| (this.genericCast != null)) {
212
		this.receiver.generateCode(currentScope, codeStream, !isStatic);
212
		this.receiver.generateCode(currentScope, codeStream, !isStatic);
213
		if ((this.bits & NeedReceiverGenericCast) != 0) {
214
			codeStream.checkcast(this.actualReceiverType);
215
		}		
213
		pc = codeStream.position;
216
		pc = codeStream.position;
214
		if (codegenBinding.declaringClass == null) { // array length
217
		if (codegenBinding.declaringClass == null) { // array length
215
			codeStream.arraylength();
218
			codeStream.arraylength();
Lines 545-557 Link Here
545
		scope.problemReporter().invalidField(this, this.actualReceiverType);
548
		scope.problemReporter().invalidField(this, this.actualReceiverType);
546
		return null;
549
		return null;
547
	}
550
	}
548
	TypeBinding receiverErasure = this.actualReceiverType.erasure();
551
	// handle indirect inheritance thru variable secondary bound
549
	if (receiverErasure instanceof ReferenceBinding) {
552
	// receiver may receive generic cast, as part of implicit conversion
550
		if (receiverErasure.findSuperTypeOriginatingFrom(fieldBinding.declaringClass) == null) {
553
	TypeBinding oldReceiverType = this.actualReceiverType;
551
			this.actualReceiverType = fieldBinding.declaringClass; // handle indirect inheritance thru variable secondary bound
554
	this.actualReceiverType = this.actualReceiverType.getErasureCompatibleType(fieldBinding.declaringClass);
552
		}
553
	}
554
	this.receiver.computeConversion(scope, this.actualReceiverType, this.actualReceiverType);
555
	this.receiver.computeConversion(scope, this.actualReceiverType, this.actualReceiverType);
556
	if (this.actualReceiverType != oldReceiverType && this.receiver.postConversionType(scope) != this.actualReceiverType) { // record need for explicit cast at codegen since receiver could not handle it
557
		this.bits |= NeedReceiverGenericCast;
558
	}
555
	if (isFieldUseDeprecated(fieldBinding, scope, (this.bits & ASTNode.IsStrictlyAssigned) !=0)) {
559
	if (isFieldUseDeprecated(fieldBinding, scope, (this.bits & ASTNode.IsStrictlyAssigned) !=0)) {
556
		scope.problemReporter().deprecatedField(fieldBinding, this);
560
		scope.problemReporter().deprecatedField(fieldBinding, this);
557
	}
561
	}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java (-12 / +10 lines)
Lines 50-56 Link Here
50
	public long nameSourcePosition ; //(start<<32)+end
50
	public long nameSourcePosition ; //(start<<32)+end
51
51
52
	public TypeBinding actualReceiverType;
52
	public TypeBinding actualReceiverType;
53
	public TypeBinding receiverGenericCast; // extra reference type cast to perform on generic receiver
54
	public TypeBinding valueCast; // extra reference type cast to perform on method returned value
53
	public TypeBinding valueCast; // extra reference type cast to perform on method returned value
55
	public TypeReference[] typeArguments;
54
	public TypeReference[] typeArguments;
56
	public TypeBinding[] genericTypeArguments;
55
	public TypeBinding[] genericTypeArguments;
Lines 123-131 Link Here
123
 * @param valueRequired boolean
122
 * @param valueRequired boolean
124
 */
123
 */
125
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
124
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) {
126
127
	int pc = codeStream.position;
125
	int pc = codeStream.position;
128
129
	// generate receiver/enclosing instance access
126
	// generate receiver/enclosing instance access
130
	MethodBinding codegenBinding = this.binding.original();
127
	MethodBinding codegenBinding = this.binding.original();
131
	boolean isStatic = codegenBinding.isStatic();
128
	boolean isStatic = codegenBinding.isStatic();
Lines 139-146 Link Here
139
		codeStream.generateOuterAccess(path, this, targetType, currentScope);
136
		codeStream.generateOuterAccess(path, this, targetType, currentScope);
140
	} else {
137
	} else {
141
		this.receiver.generateCode(currentScope, codeStream, true);
138
		this.receiver.generateCode(currentScope, codeStream, true);
142
		if (this.receiverGenericCast != null)
139
		if ((this.bits & NeedReceiverGenericCast) != 0) {
143
			codeStream.checkcast(this.receiverGenericCast);
140
			codeStream.checkcast(this.actualReceiverType);
141
		}
144
		codeStream.recordPositionsFrom(pc, this.sourceStart);
142
		codeStream.recordPositionsFrom(pc, this.sourceStart);
145
143
146
	}
144
	}
Lines 149-155 Link Here
149
147
150
	// actual message invocation
148
	// actual message invocation
151
	if (this.syntheticAccessor == null){
149
	if (this.syntheticAccessor == null){
152
		TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, codegenBinding, this.actualReceiverType, this.receiver.isImplicitThis(), this.receiverGenericCast != null);
150
		TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, codegenBinding, this.actualReceiverType, this.receiver.isImplicitThis());
153
		if (isStatic){
151
		if (isStatic){
154
			codeStream.invoke(Opcodes.OPC_invokestatic, codegenBinding, constantPoolDeclaringClass);
152
			codeStream.invoke(Opcodes.OPC_invokestatic, codegenBinding, constantPoolDeclaringClass);
155
		} else if( (this.receiver.isSuper()) || codegenBinding.isPrivate()){
153
		} else if( (this.receiver.isSuper()) || codegenBinding.isPrivate()){
Lines 454-466 Link Here
454
				scope.problemReporter().rawTypeReference(this.receiver, this.actualReceiverType);
452
				scope.problemReporter().rawTypeReference(this.receiver, this.actualReceiverType);
455
			}
453
			}
456
		} else {
454
		} else {
455
			// handle indirect inheritance thru variable secondary bound
456
			// receiver may receive generic cast, as part of implicit conversion
457
			TypeBinding oldReceiverType = this.actualReceiverType;
458
			this.actualReceiverType = this.actualReceiverType.getErasureCompatibleType(this.binding.declaringClass);
457
			this.receiver.computeConversion(scope, this.actualReceiverType, this.actualReceiverType);
459
			this.receiver.computeConversion(scope, this.actualReceiverType, this.actualReceiverType);
458
			// compute generic cast if necessary
460
			if (this.actualReceiverType != oldReceiverType && this.receiver.postConversionType(scope) != this.actualReceiverType) { // record need for explicit cast at codegen since receiver could not handle it
459
			TypeBinding receiverErasure = this.actualReceiverType.erasure();
461
				this.bits |= NeedReceiverGenericCast;
460
			if (receiverErasure instanceof ReferenceBinding) {
461
				if (receiverErasure.findSuperTypeOriginatingFrom(this.binding.declaringClass) == null) {
462
					this.receiverGenericCast = this.binding.declaringClass; // handle indirect inheritance thru variable secondary bound
463
				}
464
			}
462
			}
465
		}
463
		}
466
	} else {
464
	} else {
(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java (-8 / +4 lines)
Lines 737-752 Link Here
737
			// set generic cast of for previous field (if any)
737
			// set generic cast of for previous field (if any)
738
			if (previousField != null) {
738
			if (previousField != null) {
739
				TypeBinding fieldReceiverType = type;
739
				TypeBinding fieldReceiverType = type;
740
				TypeBinding receiverErasure = type.erasure();
740
				TypeBinding oldReceiverType = fieldReceiverType;
741
				if (receiverErasure instanceof ReferenceBinding) {
741
				fieldReceiverType = fieldReceiverType.getErasureCompatibleType(field.declaringClass);// handle indirect inheritance thru variable secondary bound
742
					if (receiverErasure.findSuperTypeOriginatingFrom(field.declaringClass) == null) {
743
						fieldReceiverType = field.declaringClass; // handle indirect inheritance thru variable secondary bound
744
					}
745
				}
746
				FieldBinding originalBinding = previousField.original();
742
				FieldBinding originalBinding = previousField.original();
747
			    if (originalBinding.type.leafComponentType().isTypeVariable()) {
743
				if (fieldReceiverType != oldReceiverType || originalBinding.type.leafComponentType().isTypeVariable()) { // record need for explicit cast at codegen
748
			    	setGenericCast(index-1,originalBinding.type.genericCast(fieldReceiverType)); // type cannot be base-type even in boxing case
744
			    	setGenericCast(index-1,originalBinding.type.genericCast(fieldReceiverType)); // type cannot be base-type even in boxing case
749
			    }
745
				}				
750
		    }
746
		    }
751
			// only last field is actually a write access if any
747
			// only last field is actually a write access if any
752
			if (isFieldUseDeprecated(field, scope, (this.bits & ASTNode.IsStrictlyAssigned) !=0 && index+1 == length)) {
748
			if (isFieldUseDeprecated(field, scope, (this.bits & ASTNode.IsStrictlyAssigned) !=0 && index+1 == length)) {
(-)compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java (-3 / +2 lines)
Lines 2932-2941 Link Here
2932
 * @param codegenBinding
2932
 * @param codegenBinding
2933
 * @param actualReceiverType
2933
 * @param actualReceiverType
2934
 * @param isImplicitThisReceiver
2934
 * @param isImplicitThisReceiver
2935
 * @param hasGenericCast
2936
 * @return the receiver type to use in constant pool
2935
 * @return the receiver type to use in constant pool
2937
 */
2936
 */
2938
public static TypeBinding getConstantPoolDeclaringClass(Scope currentScope, MethodBinding codegenBinding, TypeBinding actualReceiverType, boolean isImplicitThisReceiver, boolean hasGenericCast) {
2937
public static TypeBinding getConstantPoolDeclaringClass(Scope currentScope, MethodBinding codegenBinding, TypeBinding actualReceiverType, boolean isImplicitThisReceiver) {
2939
	TypeBinding constantPoolDeclaringClass = codegenBinding.declaringClass;
2938
	TypeBinding constantPoolDeclaringClass = codegenBinding.declaringClass;
2940
	// Post 1.4.0 target, array clone() invocations are qualified with array type
2939
	// Post 1.4.0 target, array clone() invocations are qualified with array type
2941
	// This is handled in array type #clone method binding resolution (see Scope and UpdatedMethodBinding)
2940
	// This is handled in array type #clone method binding resolution (see Scope and UpdatedMethodBinding)
Lines 2949-2955 Link Here
2949
		// for runtime compatibility on 1.2 VMs : change the declaring class of the binding
2948
		// for runtime compatibility on 1.2 VMs : change the declaring class of the binding
2950
		// NOTE: from target 1.2 on, method's declaring class is touched if any different from receiver type
2949
		// NOTE: from target 1.2 on, method's declaring class is touched if any different from receiver type
2951
		// and not from Object or implicit static method call.
2950
		// and not from Object or implicit static method call.
2952
		if (constantPoolDeclaringClass != actualReceiverType.erasure() && !hasGenericCast && !actualReceiverType.isArrayType()) {
2951
		if (constantPoolDeclaringClass != actualReceiverType.erasure() && !actualReceiverType.isArrayType()) {
2953
			CompilerOptions options = currentScope.compilerOptions();
2952
			CompilerOptions options = currentScope.compilerOptions();
2954
			if ((options.targetJDK >= ClassFileConstants.JDK1_2
2953
			if ((options.targetJDK >= ClassFileConstants.JDK1_2
2955
						&& (options.complianceLevel >= ClassFileConstants.JDK1_4 || !(isImplicitThisReceiver && codegenBinding.isStatic()))
2954
						&& (options.complianceLevel >= ClassFileConstants.JDK1_4 || !(isImplicitThisReceiver && codegenBinding.isStatic()))
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java (-12 / +14 lines)
Lines 67-80 Link Here
67
			}
67
			}
68
		} else {
68
		} else {
69
			this.receiver.generateCode(currentScope, codeStream, !isStatic);
69
			this.receiver.generateCode(currentScope, codeStream, !isStatic);
70
			if (this.receiverGenericCast != null)
70
			if ((this.bits & NeedReceiverGenericCast) != 0) {
71
				codeStream.checkcast(this.receiverGenericCast);
71
				codeStream.checkcast(this.actualReceiverType);
72
			}			
72
			codeStream.recordPositionsFrom(pc, this.sourceStart);
73
			codeStream.recordPositionsFrom(pc, this.sourceStart);
73
		}
74
		}
74
		// generate arguments
75
		// generate arguments
75
		generateArguments(this.binding, this.arguments, currentScope, codeStream);
76
		generateArguments(this.binding, this.arguments, currentScope, codeStream);
76
		// actual message invocation
77
		// actual message invocation
77
		TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, codegenBinding, this.actualReceiverType, this.receiver.isImplicitThis(), this.receiverGenericCast != null);
78
		TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, codegenBinding, this.actualReceiverType, this.receiver.isImplicitThis());
78
		if (isStatic) {
79
		if (isStatic) {
79
			codeStream.invoke(Opcodes.OPC_invokestatic, codegenBinding, constantPoolDeclaringClass);
80
			codeStream.invoke(Opcodes.OPC_invokestatic, codegenBinding, constantPoolDeclaringClass);
80
		} else if( (this.receiver.isSuper()) || codegenBinding.isPrivate()){
81
		} else if( (this.receiver.isSuper()) || codegenBinding.isPrivate()){
Lines 96-103 Link Here
96
			currentScope.problemReporter().needImplementation(this);
97
			currentScope.problemReporter().needImplementation(this);
97
		} else {
98
		} else {
98
			this.receiver.generateCode(currentScope, codeStream, !isStatic);
99
			this.receiver.generateCode(currentScope, codeStream, !isStatic);
99
			if (this.receiverGenericCast != null)
100
			if ((this.bits & NeedReceiverGenericCast) != 0) {
100
				codeStream.checkcast(this.receiverGenericCast);
101
				codeStream.checkcast(this.actualReceiverType);
102
			}			
101
			codeStream.recordPositionsFrom(pc, this.sourceStart);
103
			codeStream.recordPositionsFrom(pc, this.sourceStart);
102
		}
104
		}
103
		if (isStatic) {
105
		if (isStatic) {
Lines 299-312 Link Here
299
				&& (((NameReference) this.receiver).bits & Binding.TYPE) != 0) {
301
				&& (((NameReference) this.receiver).bits & Binding.TYPE) != 0) {
300
			scope.problemReporter().mustUseAStaticMethod(this, this.binding);
302
			scope.problemReporter().mustUseAStaticMethod(this, this.binding);
301
		} else {
303
		} else {
302
			// compute generic cast if necessary
304
			// handle indirect inheritance thru variable secondary bound
303
			TypeBinding receiverErasure = this.actualReceiverType.erasure();
305
			// receiver may receive generic cast, as part of implicit conversion
304
			if (receiverErasure instanceof ReferenceBinding) {
306
			TypeBinding oldReceiverType = this.actualReceiverType;
305
				if (receiverErasure.findSuperTypeOriginatingFrom(this.binding.declaringClass) == null) {
307
			this.actualReceiverType = this.actualReceiverType.getErasureCompatibleType(this.binding.declaringClass);
306
					this.actualReceiverType = this.binding.declaringClass; // handle indirect inheritance thru variable secondary bound
307
				}
308
			}
309
			this.receiver.computeConversion(scope, this.actualReceiverType, this.actualReceiverType);
308
			this.receiver.computeConversion(scope, this.actualReceiverType, this.actualReceiverType);
309
			if (this.actualReceiverType != oldReceiverType && this.receiver.postConversionType(scope) != this.actualReceiverType) { // record need for explicit cast at codegen since receiver could not handle it
310
				this.bits |= NeedReceiverGenericCast;
311
			}			
310
		}
312
		}
311
	}
313
	}
312
	checkInvocationArguments(scope, this.receiver, this.actualReceiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this);
314
	checkInvocationArguments(scope, this.receiver, this.actualReceiverType, this.binding, this.arguments, argumentTypes, argsContainCast, this);
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/TypeBinding.java (+45 lines)
Lines 358-363 Link Here
358
	return signature();
358
	return signature();
359
}
359
}
360
360
361
/**
362
 * Return the supertype which would erase as a subtype of a given declaring class.
363
 * If the receiver is already erasure compatible, then it will returned. If not, then will return the alternate lowest
364
 * upper bound compatible with declaring class.
365
 * NOTE: the declaringClass is already know to be compatible with the receiver
366
 * @param declaringClass to look for
367
 * @return the lowest erasure compatible type (considering alternate bounds)
368
 */
369
public TypeBinding getErasureCompatibleType(TypeBinding declaringClass) {
370
	switch(kind()) {
371
		case Binding.TYPE_PARAMETER :
372
			TypeVariableBinding variable = (TypeVariableBinding) this;
373
			if (variable.erasure().findSuperTypeOriginatingFrom(declaringClass) != null) {
374
				return this; // no need for alternate receiver type
375
			}
376
			if (variable.superclass != null && variable.superclass.findSuperTypeOriginatingFrom(declaringClass) != null) {
377
				return variable.superclass.getErasureCompatibleType(declaringClass);
378
			}
379
			for (int i = 0, otherLength = variable.superInterfaces.length; i < otherLength; i++) {
380
				ReferenceBinding superInterface = variable.superInterfaces[i];
381
				if (superInterface.findSuperTypeOriginatingFrom(declaringClass) != null) {
382
					return superInterface.getErasureCompatibleType(declaringClass);
383
				}
384
			}
385
			return this; // only occur if passed null declaringClass for arraylength
386
		case Binding.INTERSECTION_TYPE :
387
			WildcardBinding intersection = (WildcardBinding) this;
388
			if (intersection.erasure().findSuperTypeOriginatingFrom(declaringClass) != null) {
389
				return this; // no need for alternate receiver type
390
			}
391
			if (intersection.superclass != null && intersection.superclass.findSuperTypeOriginatingFrom(declaringClass) != null) {
392
				return intersection.superclass.getErasureCompatibleType(declaringClass);
393
			}
394
			for (int i = 0, otherLength = intersection.superInterfaces.length; i < otherLength; i++) {
395
				ReferenceBinding superInterface = intersection.superInterfaces[i];
396
				if (superInterface.findSuperTypeOriginatingFrom(declaringClass) != null) {
397
					return superInterface.getErasureCompatibleType(declaringClass);
398
				}
399
			}
400
			return this; // only occur if passed null declaringClass for arraylength
401
		default :
402
			return this;
403
	}
404
}
405
361
public abstract PackageBinding getPackage();
406
public abstract PackageBinding getPackage();
362
407
363
void initializeForStaticImports() {
408
void initializeForStaticImports() {
(-)src/org/eclipse/jdt/core/tests/compiler/regression/GenericTypeTest.java (-50 / +104 lines)
Lines 46336-46342 Link Here
46336
			"----------\n");
46336
			"----------\n");
46337
}
46337
}
46338
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247953
46338
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247953
46339
public void _test1381()  throws Exception {
46339
public void test1381()  throws Exception {
46340
	this.runConformTest(
46340
	this.runConformTest(
46341
		new String[] {
46341
		new String[] {
46342
			"X.java",
46342
			"X.java",
Lines 46361-46390 Link Here
46361
			"}\n",
46361
			"}\n",
46362
			"p/IB.java", // =====================
46362
			"p/IB.java", // =====================
46363
			"package p;\n" +
46363
			"package p;\n" +
46364
			"interface IA {\n" + 
46364
			"interface IA {\n" + // non visible
46365
			"	void baz();\n" + 
46365
			"	void baz();\n" + 
46366
			"}\n" + 
46366
			"}\n" + 
46367
			"public interface IB extends IA {\n" + 
46367
			"public interface IB extends IA {\n" + 
46368
			"}\n",
46368
			"}\n",
46369
		},
46369
		},
46370
		"done");
46370
		"done");
46371
	// check #baz() invocation declaring class is IA
46371
	// check #baz() invocation declaring class is IB
46372
	String expectedOutput =
46372
	String expectedOutput =
46373
		"  // Method descriptor #21 (LX;)V\n" + 
46373
		"  // Method descriptor #10 ()V\n" + 
46374
		"  // Signature: (LX<TT;>;)V\n" + 
46374
		"  // Stack: 1, Locals: 1\n" + 
46375
		"  // Stack: 1, Locals: 2\n" + 
46375
		"  void foo();\n" + 
46376
		"  void foo(X xt);\n" + 
46376
		"     0  aload_0 [this]\n" + 
46377
		"     0  aload_1 [xt]\n" + 
46377
		"     1  getfield X.t : AA [21]\n" + 
46378
		"     1  invokevirtual X.get() : AA [23]\n" + 
46378
		"     4  checkcast p.IB [23]\n" + 
46379
		"     4  checkcast p.IA [25]\n" + 
46379
		"     7  invokeinterface p.IB.baz() : void [25] [nargs: 1]\n" + 
46380
		"     7  invokeinterface p.IA.baz() : void [27] [nargs: 1]\n" + 
46381
		"    12  return\n" + 
46380
		"    12  return\n" + 
46382
		"      Line numbers:\n" + 
46381
		"      Line numbers:\n" + 
46383
		"        [pc: 0, line: 5]\n" + 
46382
		"        [pc: 0, line: 4]\n" + 
46384
		"        [pc: 12, line: 6]\n" + 
46383
		"        [pc: 12, line: 5]\n" + 
46385
		"      Local variable table:\n" + 
46384
		"      Local variable table:\n" + 
46386
		"        [pc: 0, pc: 13] local: this index: 0 type: X\n" + 
46385
		"        [pc: 0, pc: 13] local: this index: 0 type: X\n";
46387
		"        [pc: 0, pc: 13] local: xt index: 1 type: X\n";
46388
46386
46389
	File f = new File(OUTPUT_DIR + File.separator + "X.class");
46387
	File f = new File(OUTPUT_DIR + File.separator + "X.class");
46390
	byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
46388
	byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
Lines 46399-46405 Link Here
46399
	}
46397
	}
46400
}
46398
}
46401
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247953 - variation
46399
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247953 - variation
46402
public void _test1382()  throws Exception {
46400
public void test1382()  throws Exception {
46403
	this.runConformTest(
46401
	this.runConformTest(
46404
		new String[] {
46402
		new String[] {
46405
			"X.java",
46403
			"X.java",
Lines 46452-46458 Link Here
46452
	}
46450
	}
46453
}
46451
}
46454
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247953 - variation
46452
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247953 - variation
46455
public void _test1383()  throws Exception {
46453
public void test1383()  throws Exception {
46456
	this.runConformTest(
46454
	this.runConformTest(
46457
		new String[] {
46455
		new String[] {
46458
			"X.java",
46456
			"X.java",
Lines 46507-46513 Link Here
46507
	}
46505
	}
46508
}
46506
}
46509
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247953 - variation
46507
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247953 - variation
46510
public void _test1384()  throws Exception {
46508
public void test1384()  throws Exception {
46511
	this.runConformTest(
46509
	this.runConformTest(
46512
		new String[] {
46510
		new String[] {
46513
			"X.java",
46511
			"X.java",
Lines 46561-46567 Link Here
46561
	}
46559
	}
46562
}
46560
}
46563
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247953 - variation
46561
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247953 - variation
46564
public void _test1385()  throws Exception {
46562
public void test1385()  throws Exception {
46565
	this.runConformTest(
46563
	this.runConformTest(
46566
		new String[] {
46564
		new String[] {
46567
			"X.java",
46565
			"X.java",
Lines 46613-46619 Link Here
46613
	}
46611
	}
46614
}
46612
}
46615
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247953 - variation
46613
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247953 - variation
46616
public void _test1386()  throws Exception {
46614
public void test1386()  throws Exception {
46617
	this.runConformTest(
46615
	this.runConformTest(
46618
		new String[] {
46616
		new String[] {
46619
			"X.java",
46617
			"X.java",
Lines 46635-46641 Link Here
46635
			"public interface IB extends IA {\n" + 
46633
			"public interface IB extends IA {\n" + 
46636
			"}\n",
46634
			"}\n",
46637
		},
46635
		},
46638
		"111");
46636
		"");
46639
	// check #baz() invocation declaring class is not IA
46637
	// check #baz() invocation declaring class is not IA
46640
	String expectedOutput =
46638
	String expectedOutput =
46641
		"  // Method descriptor #21 (LX;)V\n" + 
46639
		"  // Method descriptor #21 (LX;)V\n" + 
Lines 46667-46673 Link Here
46667
	}
46665
	}
46668
}
46666
}
46669
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247953 - variation
46667
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247953 - variation
46670
public void _test1387()  throws Exception {
46668
public void test1387()  throws Exception {
46671
	this.runConformTest(
46669
	this.runConformTest(
46672
		new String[] {
46670
		new String[] {
46673
			"X.java",
46671
			"X.java",
Lines 46698-46718 Link Here
46698
		"done");
46696
		"done");
46699
	// check #baz declaring class is not IA
46697
	// check #baz declaring class is not IA
46700
	String expectedOutput =
46698
	String expectedOutput =
46701
		"  // Method descriptor #21 (LX;)V\n" + 
46699
		"  // Method descriptor #10 ()V\n" + 
46702
		"  // Signature: (LX<TT;>;)V\n" + 
46700
		"  // Stack: 2, Locals: 1\n" + 
46703
		"  // Stack: 1, Locals: 2\n" + 
46701
		"  void foo();\n" + 
46704
		"  void foo(X xt);\n" + 
46702
		"     0  getstatic java.lang.System.out : java.io.PrintStream [21]\n" + 
46705
		"     0  aload_1 [xt]\n" + 
46703
		"     3  aload_0 [this]\n" + 
46706
		"     1  invokevirtual X.get() : AA [23]\n" + 
46704
		"     4  getfield X.t : AA [27]\n" + 
46707
		"     4  checkcast p.IB [25]\n" + 
46705
		"     7  checkcast p.IB [29]\n" + 
46708
		"     7  invokeinterface p.IB.baz() : void [27] [nargs: 1]\n" + 
46706
		"    10  pop\n" + 
46709
		"    12  return\n" + 
46707
		"    11  getstatic p.IB.baz : java.lang.Object [31]\n" + 
46708
		"    14  invokevirtual java.io.PrintStream.println(java.lang.Object) : void [35]\n" + 
46709
		"    17  return\n" + 
46710
		"      Line numbers:\n" + 
46710
		"      Line numbers:\n" + 
46711
		"        [pc: 0, line: 5]\n" + 
46711
		"        [pc: 0, line: 4]\n" + 
46712
		"        [pc: 12, line: 6]\n" + 
46712
		"        [pc: 17, line: 5]\n" + 
46713
		"      Local variable table:\n" + 
46713
		"      Local variable table:\n" + 
46714
		"        [pc: 0, pc: 13] local: this index: 0 type: X\n" + 
46714
		"        [pc: 0, pc: 18] local: this index: 0 type: X\n";
46715
		"        [pc: 0, pc: 13] local: xt index: 1 type: X\n";
46716
46715
46717
	File f = new File(OUTPUT_DIR + File.separator + "X.class");
46716
	File f = new File(OUTPUT_DIR + File.separator + "X.class");
46718
	byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
46717
	byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
Lines 46727-46733 Link Here
46727
	}
46726
	}
46728
}
46727
}
46729
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247953 - variation
46728
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247953 - variation
46730
public void _test1388()  throws Exception {
46729
public void test1388()  throws Exception {
46731
	this.runConformTest(
46730
	this.runConformTest(
46732
		new String[] {
46731
		new String[] {
46733
			"X.java",
46732
			"X.java",
Lines 46758-46778 Link Here
46758
		"done");
46757
		"done");
46759
	// check #baz declaring class is not IA
46758
	// check #baz declaring class is not IA
46760
	String expectedOutput =
46759
	String expectedOutput =
46761
		"  // Method descriptor #21 (LX;)V\n" + 
46760
		"  // Method descriptor #10 ()V\n" + 
46762
		"  // Signature: (LX<TT;>;)V\n" + 
46761
		"  // Stack: 2, Locals: 1\n" + 
46763
		"  // Stack: 1, Locals: 2\n" + 
46762
		"  void foo();\n" + 
46764
		"  void foo(X xt);\n" + 
46763
		"     0  getstatic java.lang.System.out : java.io.PrintStream [21]\n" + 
46765
		"     0  aload_1 [xt]\n" + 
46764
		"     3  aload_0 [this]\n" + 
46766
		"     1  invokevirtual X.get() : AA [23]\n" + 
46765
		"     4  getfield X.t : AA [27]\n" + 
46767
		"     4  checkcast p.IB [25]\n" + 
46766
		"     7  checkcast p.IB [29]\n" + 
46768
		"     7  invokeinterface p.IB.baz() : void [27] [nargs: 1]\n" + 
46767
		"    10  pop\n" + 
46769
		"    12  return\n" + 
46768
		"    11  getstatic p.IB.baz : java.lang.Object [31]\n" + 
46769
		"    14  invokevirtual java.io.PrintStream.println(java.lang.Object) : void [35]\n" + 
46770
		"    17  return\n" + 
46770
		"      Line numbers:\n" + 
46771
		"      Line numbers:\n" + 
46771
		"        [pc: 0, line: 5]\n" + 
46772
		"        [pc: 0, line: 4]\n" + 
46772
		"        [pc: 12, line: 6]\n" + 
46773
		"        [pc: 17, line: 5]\n" + 
46773
		"      Local variable table:\n" + 
46774
		"      Local variable table:\n" + 
46774
		"        [pc: 0, pc: 13] local: this index: 0 type: X\n" + 
46775
		"        [pc: 0, pc: 18] local: this index: 0 type: X\n";
46775
		"        [pc: 0, pc: 13] local: xt index: 1 type: X\n";
46776
46776
46777
	File f = new File(OUTPUT_DIR + File.separator + "X.class");
46777
	File f = new File(OUTPUT_DIR + File.separator + "X.class");
46778
	byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
46778
	byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
Lines 46787-46793 Link Here
46787
	}
46787
	}
46788
}
46788
}
46789
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247953 - variation
46789
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247953 - variation
46790
public void _test1389()  throws Exception {
46790
public void test1389()  throws Exception {
46791
	this.runConformTest(
46791
	this.runConformTest(
46792
		new String[] {
46792
		new String[] {
46793
			"X.java",
46793
			"X.java",
Lines 47136-47139 Link Here
47136
		assertEquals("Wrong contents", expectedOutput, result);
47136
		assertEquals("Wrong contents", expectedOutput, result);
47137
	}
47137
	}
47138
}
47138
}
47139
public void test1396()  throws Exception {
47140
	this.runConformTest(
47141
		new String[] {
47142
			"X.java",
47143
			"public class X<T extends SubX2<T>> {\n" + 
47144
			"	T sx1;\n" + 
47145
			"	void foo(T t) {\n" + 
47146
			"		t.sx2.t.getClass();\n" + 
47147
			"	}\n" + 
47148
			"}\n" + 
47149
			"interface X1<T extends X2<T>> {\n" + 
47150
			"}\n" + 
47151
			"abstract class SubX1<T extends X2<T>> implements X1<T> {\n" + 
47152
			"	T sx2;\n" + 
47153
			"}\n" + 
47154
			"interface X2<T extends X2<T>> extends X1<T>{\n" + 
47155
			"}\n" + 
47156
			"abstract class SubX2<T extends X2<T>> extends SubX1<T> implements X2<T> {\n" + 
47157
			"	T t;\n" + 
47158
			"}\n",
47159
		},
47160
		"");
47161
	String expectedOutput =
47162
		"  // Method descriptor #21 (LSubX2;)V\n" + 
47163
		"  // Signature: (TT;)V\n" + 
47164
		"  // Stack: 1, Locals: 2\n" + 
47165
		"  void foo(SubX2 t);\n" + 
47166
		"     0  aload_1 [t]\n" + 
47167
		"     1  getfield SubX2.sx2 : X2 [23]\n" + 
47168
		"     4  checkcast SubX2 [24]\n" + 
47169
		"     7  getfield SubX2.t : X2 [29]\n" + 
47170
		"    10  checkcast SubX2 [24]\n" + 
47171
		"    13  invokevirtual java.lang.Object.getClass() : java.lang.Class [32]\n" + 
47172
		"    16  pop\n" + 
47173
		"    17  return\n" + 
47174
		"      Line numbers:\n" + 
47175
		"        [pc: 0, line: 4]\n" + 
47176
		"        [pc: 17, line: 5]\n" + 
47177
		"      Local variable table:\n" + 
47178
		"        [pc: 0, pc: 18] local: this index: 0 type: X\n" + 
47179
		"        [pc: 0, pc: 18] local: t index: 1 type: SubX2\n";
47180
47181
	File f = new File(OUTPUT_DIR + File.separator + "X.class");
47182
	byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(f);
47183
	ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
47184
	String result = disassembler.disassemble(classFileBytes, "\n", ClassFileBytesDisassembler.DETAILED);
47185
	int index = result.indexOf(expectedOutput);
47186
	if (index == -1 || expectedOutput.length() == 0) {
47187
		System.out.println(Util.displayString(result, 3));
47188
	}
47189
	if (index == -1) {
47190
		assertEquals("Wrong contents", expectedOutput, result);
47191
	}
47192
}
47139
}
47193
}

Return to bug 247953