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

Collapse All | Expand All

(-)src/org/eclipse/jdt/core/tests/compiler/regression/InnerEmulationTest.java (-1 / +74 lines)
Lines 6862-6868 Link Here
6862
		"    0  invokestatic package2.C.outerMethod() : void";
6862
		"    0  invokestatic package2.C.outerMethod() : void";
6863
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "package2" + File.separator + "C.class", "C", expectedOutput);
6863
	checkDisassembledClassFile(OUTPUT_DIR + File.separator + "package2" + File.separator + "C.class", "C", expectedOutput);
6864
}
6864
}
6865
6865
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=249107 - variation
6866
public void test166() throws Exception {
6867
	this.runConformTest(new String[] {
6868
		"X.java",//=======================
6869
		"class XSuper {\n" + 
6870
		"	protected String field = \"[XSuper#field]\";//$NON-NLS-1$\n" + 
6871
		"}\n" + 
6872
		"public class X extends XSuper {\n" + 
6873
		"	protected String field = \"[X#field]\";//$NON-NLS-1$\n" + 
6874
		"	public static void main(String[] args) {\n" + 
6875
		"		new X().foo();\n" + 
6876
		"	}\n" + 
6877
		"	void foo() {\n" + 
6878
		"		new Object() {\n" + 
6879
		"			void bar() {\n" + 
6880
		"				System.out.print(\"X.this.field=\" + X.this.field);\n" + 
6881
		"				System.out.print(\"X.super.field=\" + X.super.field);\n" + 
6882
		"			}\n" + 
6883
		"		}.bar();\n" + 
6884
		"	}\n" + 
6885
		"}\n",
6886
	},
6887
	"X.this.field=[X#field]X.super.field=[XSuper#field]");
6888
}
6889
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=249107 - variation
6890
public void test167() throws Exception {
6891
	this.runConformTest(new String[] {
6892
		"X.java",//=======================
6893
		"class XSuper {\n" + 
6894
		"	protected String method() { return \"[XSuper#method()]\"; }//$NON-NLS-1$\n" + 
6895
		"}\n" + 
6896
		"public class X extends XSuper {\n" + 
6897
		"	protected String method() { return \"[X#method()]\"; }//$NON-NLS-1$\n" + 
6898
		"	public static void main(String[] args) {\n" + 
6899
		"		new X().foo();\n" + 
6900
		"	}\n" + 
6901
		"	void foo() {\n" + 
6902
		"		new Object() {\n" + 
6903
		"			void bar() {\n" + 
6904
		"				System.out.print(\"X.this.method()=\" + X.this.method());\n" + 
6905
		"				System.out.print(\"X.super.method()=\" + X.super.method());\n" + 
6906
		"			}\n" + 
6907
		"		}.bar();\n" + 
6908
		"	}\n" + 
6909
		"}\n",
6910
	},
6911
	"X.this.method()=[X#method()]X.super.method()=[XSuper#method()]");
6912
}
6913
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=249107 - variation
6914
public void test168() throws Exception {
6915
	this.runConformTest(new String[] {
6916
		"X.java",//=======================
6917
		"class XSuper {\n" + 
6918
		"	protected String field;\n" + 
6919
		"}\n" + 
6920
		"public class X extends XSuper {\n" + 
6921
		"	protected String field;\n" + 
6922
		"	public static void main(String[] args) {\n" + 
6923
		"		new X().foo();\n" + 
6924
		"	}\n" + 
6925
		"	void foo() {\n" + 
6926
		"		new Object() {\n" + 
6927
		"			void bar() {\n" + 
6928
		"				X.this.field = \"[X#field]\";\n" +
6929
		"				X.super.field = \"[XSuper#field]\";\n" +
6930
		"				System.out.print(\"X.this.field=\" + X.this.field);\n" + 
6931
		"				System.out.print(\"X.super.field=\" + X.super.field);\n" + 
6932
		"			}\n" + 
6933
		"		}.bar();\n" + 
6934
		"	}\n" + 
6935
		"}\n",
6936
	},
6937
	"X.this.field=[X#field]X.super.field=[XSuper#field]");
6938
}
6866
public static Class testClass() {
6939
public static Class testClass() {
6867
	return InnerEmulationTest.class;
6940
	return InnerEmulationTest.class;
6868
}
6941
}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java (-3 / +3 lines)
Lines 354-360 Link Here
354
/* Add a new synthetic access method for read/write access to <targetField>.
354
/* Add a new synthetic access method for read/write access to <targetField>.
355
	Answer the new method or the existing method if one already existed.
355
	Answer the new method or the existing method if one already existed.
356
*/
356
*/
357
public SyntheticMethodBinding addSyntheticMethod(FieldBinding targetField, boolean isReadAccess) {
357
public SyntheticMethodBinding addSyntheticMethod(FieldBinding targetField, boolean isReadAccess, boolean isSuperAccess) {
358
	if (this.synthetics == null)
358
	if (this.synthetics == null)
359
		this.synthetics = new HashMap[MAX_SYNTHETICS];
359
		this.synthetics = new HashMap[MAX_SYNTHETICS];
360
	if (this.synthetics[SourceTypeBinding.METHOD_EMUL] == null)
360
	if (this.synthetics[SourceTypeBinding.METHOD_EMUL] == null)
Lines 363-374 Link Here
363
	SyntheticMethodBinding accessMethod = null;
363
	SyntheticMethodBinding accessMethod = null;
364
	SyntheticMethodBinding[] accessors = (SyntheticMethodBinding[]) this.synthetics[SourceTypeBinding.METHOD_EMUL].get(targetField);
364
	SyntheticMethodBinding[] accessors = (SyntheticMethodBinding[]) this.synthetics[SourceTypeBinding.METHOD_EMUL].get(targetField);
365
	if (accessors == null) {
365
	if (accessors == null) {
366
		accessMethod = new SyntheticMethodBinding(targetField, isReadAccess, this);
366
		accessMethod = new SyntheticMethodBinding(targetField, isReadAccess, isSuperAccess, this);
367
		this.synthetics[SourceTypeBinding.METHOD_EMUL].put(targetField, accessors = new SyntheticMethodBinding[2]);
367
		this.synthetics[SourceTypeBinding.METHOD_EMUL].put(targetField, accessors = new SyntheticMethodBinding[2]);
368
		accessors[isReadAccess ? 0 : 1] = accessMethod;
368
		accessors[isReadAccess ? 0 : 1] = accessMethod;
369
	} else {
369
	} else {
370
		if ((accessMethod = accessors[isReadAccess ? 0 : 1]) == null) {
370
		if ((accessMethod = accessors[isReadAccess ? 0 : 1]) == null) {
371
			accessMethod = new SyntheticMethodBinding(targetField, isReadAccess, this);
371
			accessMethod = new SyntheticMethodBinding(targetField, isReadAccess, isSuperAccess, this);
372
			accessors[isReadAccess ? 0 : 1] = accessMethod;
372
			accessors[isReadAccess ? 0 : 1] = accessMethod;
373
		}
373
		}
374
	}
374
	}
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/SyntheticMethodBinding.java (-12 / +14 lines)
Lines 26-43 Link Here
26
26
27
	public final static int FieldReadAccess = 1; 		// field read
27
	public final static int FieldReadAccess = 1; 		// field read
28
	public final static int FieldWriteAccess = 2; 		// field write
28
	public final static int FieldWriteAccess = 2; 		// field write
29
	public final static int MethodAccess = 3; 		// normal method
29
	public final static int SuperFieldReadAccess = 3; // super field read
30
	public final static int ConstructorAccess = 4; 	// constructor
30
	public final static int SuperFieldWriteAccess = 4; // super field write
31
	public final static int SuperMethodAccess = 5; // super method
31
	public final static int MethodAccess = 5; 		// normal method
32
	public final static int BridgeMethod = 6; // bridge method
32
	public final static int ConstructorAccess = 6; 	// constructor
33
	public final static int EnumValues = 7; // enum #values()
33
	public final static int SuperMethodAccess = 7; // super method
34
	public final static int EnumValueOf = 8; // enum #valueOf(String)
34
	public final static int BridgeMethod = 8; // bridge method
35
	public final static int SwitchTable = 9; // switch table method
35
	public final static int EnumValues = 9; // enum #values()
36
	public final static int EnumValueOf = 10; // enum #valueOf(String)
37
	public final static int SwitchTable = 11; // switch table method
36
38
37
	public int sourceStart = 0; // start position of the matching declaration
39
	public int sourceStart = 0; // start position of the matching declaration
38
	public int index; // used for sorting access methods in the class file
40
	public int index; // used for sorting access methods in the class file
39
41
40
	public SyntheticMethodBinding(FieldBinding targetField, boolean isReadAccess, ReferenceBinding declaringClass) {
42
	public SyntheticMethodBinding(FieldBinding targetField, boolean isReadAccess, boolean isSuperAccess, ReferenceBinding declaringClass) {
41
43
42
		this.modifiers = ClassFileConstants.AccDefault | ClassFileConstants.AccStatic | ClassFileConstants.AccSynthetic;
44
		this.modifiers = ClassFileConstants.AccDefault | ClassFileConstants.AccStatic | ClassFileConstants.AccSynthetic;
43
		this.tagBits |= (TagBits.AnnotationResolved | TagBits.DeprecatedAnnotationResolved);
45
		this.tagBits |= (TagBits.AnnotationResolved | TagBits.DeprecatedAnnotationResolved);
Lines 55-61 Link Here
55
				this.parameters[0] = declaringSourceType;
57
				this.parameters[0] = declaringSourceType;
56
			}
58
			}
57
			this.targetReadField = targetField;
59
			this.targetReadField = targetField;
58
			this.purpose = SyntheticMethodBinding.FieldReadAccess;
60
			this.purpose = isSuperAccess ? SyntheticMethodBinding.SuperFieldReadAccess : SyntheticMethodBinding.FieldReadAccess;
59
		} else {
61
		} else {
60
			this.returnType = TypeBinding.VOID;
62
			this.returnType = TypeBinding.VOID;
61
			if (targetField.isStatic()) {
63
			if (targetField.isStatic()) {
Lines 67-73 Link Here
67
				this.parameters[1] = targetField.type;
69
				this.parameters[1] = targetField.type;
68
			}
70
			}
69
			this.targetWriteField = targetField;
71
			this.targetWriteField = targetField;
70
			this.purpose = SyntheticMethodBinding.FieldWriteAccess;
72
			this.purpose = isSuperAccess ? SyntheticMethodBinding.SuperFieldWriteAccess : SyntheticMethodBinding.FieldWriteAccess;
71
		}
73
		}
72
		this.thrownExceptions = Binding.NO_EXCEPTIONS;
74
		this.thrownExceptions = Binding.NO_EXCEPTIONS;
73
		this.declaringClass = declaringSourceType;
75
		this.declaringClass = declaringSourceType;
Lines 206-217 Link Here
206
		this.sourceStart = declaringSourceType.scope.referenceContext.sourceStart; // use the target declaring class name position instead
208
		this.sourceStart = declaringSourceType.scope.referenceContext.sourceStart; // use the target declaring class name position instead
207
	}
209
	}
208
210
209
	public SyntheticMethodBinding(MethodBinding targetMethod, boolean isSuperAccess, ReferenceBinding receiverType) {
211
	public SyntheticMethodBinding(MethodBinding targetMethod, boolean isSuperAccess, ReferenceBinding declaringClass) {
210
212
211
		if (targetMethod.isConstructor()) {
213
		if (targetMethod.isConstructor()) {
212
			initializeConstructorAccessor(targetMethod);
214
			initializeConstructorAccessor(targetMethod);
213
		} else {
215
		} else {
214
			initializeMethodAccessor(targetMethod, isSuperAccess, receiverType);
216
			initializeMethodAccessor(targetMethod, isSuperAccess, declaringClass);
215
		}
217
		}
216
	}
218
	}
217
219
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/BlockScope.java (-1 / +1 lines)
Lines 789-795 Link Here
789
				System.arraycopy(path, 0, (path = new Object[count + 1]), 0, count);
789
				System.arraycopy(path, 0, (path = new Object[count + 1]), 0, count);
790
			}
790
			}
791
			// private access emulation is necessary since synthetic field is private
791
			// private access emulation is necessary since synthetic field is private
792
			path[count++] = ((SourceTypeBinding) syntheticField.declaringClass).addSyntheticMethod(syntheticField, true);
792
			path[count++] = ((SourceTypeBinding) syntheticField.declaringClass).addSyntheticMethod(syntheticField, true/*read*/, false /*not super access*/);
793
			currentType = currentEnclosingType;
793
			currentType = currentEnclosingType;
794
		}
794
		}
795
		if (currentType == targetEnclosingType
795
		if (currentType == targetEnclosingType
(-)compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java (-4 / +12 lines)
Lines 2448-2458 Link Here
2448
public void generateSyntheticBodyForFieldReadAccess(SyntheticMethodBinding accessMethod) {
2448
public void generateSyntheticBodyForFieldReadAccess(SyntheticMethodBinding accessMethod) {
2449
	initializeMaxLocals(accessMethod);
2449
	initializeMaxLocals(accessMethod);
2450
	FieldBinding fieldBinding = accessMethod.targetReadField;
2450
	FieldBinding fieldBinding = accessMethod.targetReadField;
2451
	// target method declaring class may not be accessible (247953);
2452
	TypeBinding declaringClass = accessMethod.purpose == SyntheticMethodBinding.SuperFieldReadAccess 
2453
			? accessMethod.declaringClass.superclass() 
2454
			: accessMethod.declaringClass;
2451
	if (fieldBinding.isStatic()) {
2455
	if (fieldBinding.isStatic()) {
2452
		fieldAccess(Opcodes.OPC_getstatic, fieldBinding, accessMethod.declaringClass); // target method declaring class may not be accessible (247953);
2456
		fieldAccess(Opcodes.OPC_getstatic, fieldBinding, declaringClass); 
2453
	} else {
2457
	} else {
2454
		aload_0();
2458
		aload_0();
2455
		fieldAccess(Opcodes.OPC_getfield, fieldBinding, accessMethod.declaringClass); // target method declaring class may not be accessible (247953);
2459
		fieldAccess(Opcodes.OPC_getfield, fieldBinding, declaringClass);
2456
	}
2460
	}
2457
	switch (fieldBinding.type.id) {
2461
	switch (fieldBinding.type.id) {
2458
//		case T_void :
2462
//		case T_void :
Lines 2482-2494 Link Here
2482
public void generateSyntheticBodyForFieldWriteAccess(SyntheticMethodBinding accessMethod) {
2486
public void generateSyntheticBodyForFieldWriteAccess(SyntheticMethodBinding accessMethod) {
2483
	initializeMaxLocals(accessMethod);
2487
	initializeMaxLocals(accessMethod);
2484
	FieldBinding fieldBinding = accessMethod.targetWriteField;
2488
	FieldBinding fieldBinding = accessMethod.targetWriteField;
2489
	// target method declaring class may not be accessible (247953);
2490
	TypeBinding declaringClass = accessMethod.purpose == SyntheticMethodBinding.SuperFieldWriteAccess 
2491
			? accessMethod.declaringClass.superclass() 
2492
			: accessMethod.declaringClass;	
2485
	if (fieldBinding.isStatic()) {
2493
	if (fieldBinding.isStatic()) {
2486
		load(fieldBinding.type, 0);
2494
		load(fieldBinding.type, 0);
2487
		fieldAccess(Opcodes.OPC_putstatic, fieldBinding, accessMethod.declaringClass); // target method declaring class may not be accessible (247953);
2495
		fieldAccess(Opcodes.OPC_putstatic, fieldBinding, declaringClass);
2488
	} else {
2496
	} else {
2489
		aload_0();
2497
		aload_0();
2490
		load(fieldBinding.type, 1);
2498
		load(fieldBinding.type, 1);
2491
		fieldAccess(Opcodes.OPC_putfield, fieldBinding, accessMethod.declaringClass); // target method declaring class may not be accessible (247953);
2499
		fieldAccess(Opcodes.OPC_putfield, fieldBinding, declaringClass);
2492
	}
2500
	}
2493
	return_();
2501
	return_();
2494
}
2502
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java (-1 / +1 lines)
Lines 745-751 Link Here
745
				this.syntheticAccessors = new MethodBinding[2];
745
				this.syntheticAccessors = new MethodBinding[2];
746
			this.syntheticAccessors[isReadAccess ? SingleNameReference.READ : SingleNameReference.WRITE] =
746
			this.syntheticAccessors[isReadAccess ? SingleNameReference.READ : SingleNameReference.WRITE] =
747
			    ((SourceTypeBinding)currentScope.enclosingSourceType().
747
			    ((SourceTypeBinding)currentScope.enclosingSourceType().
748
					enclosingTypeAt((this.bits & ASTNode.DepthMASK) >> ASTNode.DepthSHIFT)).addSyntheticMethod(codegenField, isReadAccess);
748
					enclosingTypeAt((this.bits & ASTNode.DepthMASK) >> ASTNode.DepthSHIFT)).addSyntheticMethod(codegenField, isReadAccess, false /*not super access*/);
749
			currentScope.problemReporter().needToEmulateFieldAccess(codegenField, this, isReadAccess);
749
			currentScope.problemReporter().needToEmulateFieldAccess(codegenField, this, isReadAccess);
750
			return;
750
			return;
751
		}
751
		}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java (-8 / +4 lines)
Lines 410-444 Link Here
410
 */
410
 */
411
public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo, boolean isReadAccess) {
411
public void manageSyntheticAccessIfNecessary(BlockScope currentScope, FlowInfo flowInfo, boolean isReadAccess) {
412
	if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) != 0)	return;
412
	if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) != 0)	return;
413
413
	
414
	// if field from parameterized type got found, use the original field at codegen time
414
	// if field from parameterized type got found, use the original field at codegen time
415
	FieldBinding codegenBinding = this.binding.original();
415
	FieldBinding codegenBinding = this.binding.original();
416
417
	if (this.binding.isPrivate()) {
416
	if (this.binding.isPrivate()) {
418
		if ((currentScope.enclosingSourceType() != codegenBinding.declaringClass)
417
		if ((currentScope.enclosingSourceType() != codegenBinding.declaringClass)
419
				&& this.binding.constant() == Constant.NotAConstant) {
418
				&& this.binding.constant() == Constant.NotAConstant) {
420
			if (this.syntheticAccessors == null)
419
			if (this.syntheticAccessors == null)
421
				this.syntheticAccessors = new MethodBinding[2];
420
				this.syntheticAccessors = new MethodBinding[2];
422
			this.syntheticAccessors[isReadAccess ? FieldReference.READ : FieldReference.WRITE] =
421
			this.syntheticAccessors[isReadAccess ? FieldReference.READ : FieldReference.WRITE] =
423
				((SourceTypeBinding) codegenBinding.declaringClass).addSyntheticMethod(codegenBinding, isReadAccess);
422
				((SourceTypeBinding) codegenBinding.declaringClass).addSyntheticMethod(codegenBinding, isReadAccess, isSuperAccess());
424
			currentScope.problemReporter().needToEmulateFieldAccess(codegenBinding, this, isReadAccess);
423
			currentScope.problemReporter().needToEmulateFieldAccess(codegenBinding, this, isReadAccess);
425
			return;
424
			return;
426
		}
425
		}
427
428
	} else if (this.receiver instanceof QualifiedSuperReference) { // qualified super
426
	} else if (this.receiver instanceof QualifiedSuperReference) { // qualified super
429
430
		// qualified super need emulation always
427
		// qualified super need emulation always
431
		SourceTypeBinding destinationType =
428
		SourceTypeBinding destinationType =
432
			(SourceTypeBinding) (((QualifiedSuperReference) this.receiver)
429
			(SourceTypeBinding) (((QualifiedSuperReference) this.receiver)
433
				.currentCompatibleType);
430
				.currentCompatibleType);
434
		if (this.syntheticAccessors == null)
431
		if (this.syntheticAccessors == null)
435
			this.syntheticAccessors = new MethodBinding[2];
432
			this.syntheticAccessors = new MethodBinding[2];
436
		this.syntheticAccessors[isReadAccess ? FieldReference.READ : FieldReference.WRITE] = destinationType.addSyntheticMethod(codegenBinding, isReadAccess);
433
		this.syntheticAccessors[isReadAccess ? FieldReference.READ : FieldReference.WRITE] = destinationType.addSyntheticMethod(codegenBinding, isReadAccess, isSuperAccess());
437
		currentScope.problemReporter().needToEmulateFieldAccess(codegenBinding, this, isReadAccess);
434
		currentScope.problemReporter().needToEmulateFieldAccess(codegenBinding, this, isReadAccess);
438
		return;
435
		return;
439
436
440
	} else if (this.binding.isProtected()) {
437
	} else if (this.binding.isProtected()) {
441
442
		SourceTypeBinding enclosingSourceType;
438
		SourceTypeBinding enclosingSourceType;
443
		if (((this.bits & ASTNode.DepthMASK) != 0)
439
		if (((this.bits & ASTNode.DepthMASK) != 0)
444
			&& this.binding.declaringClass.getPackage()
440
			&& this.binding.declaringClass.getPackage()
Lines 449-455 Link Here
449
					(this.bits & ASTNode.DepthMASK) >> ASTNode.DepthSHIFT);
445
					(this.bits & ASTNode.DepthMASK) >> ASTNode.DepthSHIFT);
450
			if (this.syntheticAccessors == null)
446
			if (this.syntheticAccessors == null)
451
				this.syntheticAccessors = new MethodBinding[2];
447
				this.syntheticAccessors = new MethodBinding[2];
452
			this.syntheticAccessors[isReadAccess ? FieldReference.READ : FieldReference.WRITE] = currentCompatibleType.addSyntheticMethod(codegenBinding, isReadAccess);
448
			this.syntheticAccessors[isReadAccess ? FieldReference.READ : FieldReference.WRITE] = currentCompatibleType.addSyntheticMethod(codegenBinding, isReadAccess, isSuperAccess());
453
			currentScope.problemReporter().needToEmulateFieldAccess(codegenBinding, this, isReadAccess);
449
			currentScope.problemReporter().needToEmulateFieldAccess(codegenBinding, this, isReadAccess);
454
			return;
450
			return;
455
		}
451
		}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedSuperReference.java (-43 / +39 lines)
Lines 15-72 Link Here
15
15
16
public class QualifiedSuperReference extends QualifiedThisReference {
16
public class QualifiedSuperReference extends QualifiedThisReference {
17
17
18
	public QualifiedSuperReference(TypeReference name, int pos, int sourceEnd) {
18
public QualifiedSuperReference(TypeReference name, int pos, int sourceEnd) {
19
		super(name, pos, sourceEnd);
19
	super(name, pos, sourceEnd);
20
	}
20
}
21
22
	public boolean isSuper() {
23
24
		return true;
25
	}
26
21
27
	public boolean isThis() {
22
public boolean isSuper() {
23
	return true;
24
}
28
25
29
		return false;
26
public boolean isThis() {
30
	}
27
	return false;
28
}
31
29
32
	public StringBuffer printExpression(int indent, StringBuffer output) {
30
public StringBuffer printExpression(int indent, StringBuffer output) {
31
	return this.qualification.print(0, output).append(".super"); //$NON-NLS-1$
32
}
33
33
34
		return this.qualification.print(0, output).append(".super"); //$NON-NLS-1$
34
public TypeBinding resolveType(BlockScope scope) {
35
	if ((this.bits & ParenthesizedMASK) != 0) {
36
		scope.problemReporter().invalidParenthesizedExpression(this);
37
		return null;
38
	}
39
	super.resolveType(scope);
40
	if (this.currentCompatibleType == null)
41
		return null; // error case
42
43
	if (this.currentCompatibleType.id == T_JavaLangObject) {
44
		scope.problemReporter().cannotUseSuperInJavaLangObject(this);
45
		return null;
35
	}
46
	}
47
	return this.resolvedType = this.currentCompatibleType.superclass();
48
}
36
49
37
	public TypeBinding resolveType(BlockScope scope) {
50
public void traverse(
51
	ASTVisitor visitor,
52
	BlockScope blockScope) {
38
53
39
		if ((this.bits & ParenthesizedMASK) != 0) {
54
	if (visitor.visit(this, blockScope)) {
40
			scope.problemReporter().invalidParenthesizedExpression(this);
55
		this.qualification.traverse(visitor, blockScope);
41
			return null;
42
		}
43
		super.resolveType(scope);
44
		if (this.currentCompatibleType == null)
45
			return null; // error case
46
47
		if (this.currentCompatibleType.id == T_JavaLangObject) {
48
			scope.problemReporter().cannotUseSuperInJavaLangObject(this);
49
			return null;
50
		}
51
		return this.resolvedType = this.currentCompatibleType.superclass();
52
	}
56
	}
53
57
	visitor.endVisit(this, blockScope);
54
	public void traverse(
58
}
59
public void traverse(
55
		ASTVisitor visitor,
60
		ASTVisitor visitor,
56
		BlockScope blockScope) {
61
		ClassScope blockScope) {
57
62
58
		if (visitor.visit(this, blockScope)) {
63
	if (visitor.visit(this, blockScope)) {
59
			this.qualification.traverse(visitor, blockScope);
64
		this.qualification.traverse(visitor, blockScope);
60
		}
61
		visitor.endVisit(this, blockScope);
62
	}
63
	public void traverse(
64
			ASTVisitor visitor,
65
			ClassScope blockScope) {
66
67
		if (visitor.visit(this, blockScope)) {
68
			this.qualification.traverse(visitor, blockScope);
69
		}
70
		visitor.endVisit(this, blockScope);
71
	}
65
	}
66
	visitor.endVisit(this, blockScope);
67
}
72
}
68
}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java (-2 / +2 lines)
Lines 815-821 Link Here
815
	    FieldBinding codegenField = getCodegenBinding(index < 0 ? (this.otherBindings == null ? 0 : this.otherBindings.length) : index);
815
	    FieldBinding codegenField = getCodegenBinding(index < 0 ? (this.otherBindings == null ? 0 : this.otherBindings.length) : index);
816
	    ReferenceBinding declaringClass = codegenField.declaringClass;
816
	    ReferenceBinding declaringClass = codegenField.declaringClass;
817
		if (declaringClass != currentScope.enclosingSourceType()) {
817
		if (declaringClass != currentScope.enclosingSourceType()) {
818
		    setSyntheticAccessor(fieldBinding, index, ((SourceTypeBinding) declaringClass).addSyntheticMethod(codegenField, index >= 0 /*read-access?*/));
818
		    setSyntheticAccessor(fieldBinding, index, ((SourceTypeBinding) declaringClass).addSyntheticMethod(codegenField, index >= 0 /*read-access?*/, false /*not super access*/));
819
			currentScope.problemReporter().needToEmulateFieldAccess(codegenField, this, index >= 0 /*read-access?*/);
819
			currentScope.problemReporter().needToEmulateFieldAccess(codegenField, this, index >= 0 /*read-access?*/);
820
			return;
820
			return;
821
		}
821
		}
Lines 828-834 Link Here
828
		if (depth > 0 && (fieldBinding.declaringClass.getPackage() != currentScope.enclosingSourceType().getPackage())) {
828
		if (depth > 0 && (fieldBinding.declaringClass.getPackage() != currentScope.enclosingSourceType().getPackage())) {
829
		    FieldBinding codegenField = getCodegenBinding(index < 0 ? (this.otherBindings == null ? 0 : this.otherBindings.length) : index);
829
		    FieldBinding codegenField = getCodegenBinding(index < 0 ? (this.otherBindings == null ? 0 : this.otherBindings.length) : index);
830
		    setSyntheticAccessor(fieldBinding, index,
830
		    setSyntheticAccessor(fieldBinding, index,
831
		            ((SourceTypeBinding) currentScope.enclosingSourceType().enclosingTypeAt(depth)).addSyntheticMethod(codegenField, index >= 0 /*read-access?*/));
831
		            ((SourceTypeBinding) currentScope.enclosingSourceType().enclosingTypeAt(depth)).addSyntheticMethod(codegenField, index >= 0 /*read-access?*/, false /*not super access*/));
832
			currentScope.problemReporter().needToEmulateFieldAccess(codegenField, this, index >= 0 /*read-access?*/);
832
			currentScope.problemReporter().needToEmulateFieldAccess(codegenField, this, index >= 0 /*read-access?*/);
833
			return;
833
			return;
834
		}
834
		}
(-)compiler/org/eclipse/jdt/internal/compiler/ClassFile.java (+2 lines)
Lines 1046-1056 Link Here
1046
				SyntheticMethodBinding syntheticMethod = syntheticMethods[i];
1046
				SyntheticMethodBinding syntheticMethod = syntheticMethods[i];
1047
				switch (syntheticMethod.purpose) {
1047
				switch (syntheticMethod.purpose) {
1048
					case SyntheticMethodBinding.FieldReadAccess :
1048
					case SyntheticMethodBinding.FieldReadAccess :
1049
					case SyntheticMethodBinding.SuperFieldReadAccess :
1049
						// generate a method info to emulate an reading access to
1050
						// generate a method info to emulate an reading access to
1050
						// a non-accessible field
1051
						// a non-accessible field
1051
						addSyntheticFieldReadAccessMethod(syntheticMethod);
1052
						addSyntheticFieldReadAccessMethod(syntheticMethod);
1052
						break;
1053
						break;
1053
					case SyntheticMethodBinding.FieldWriteAccess :
1054
					case SyntheticMethodBinding.FieldWriteAccess :
1055
					case SyntheticMethodBinding.SuperFieldWriteAccess :
1054
						// generate a method info to emulate an writing access to
1056
						// generate a method info to emulate an writing access to
1055
						// a non-accessible field
1057
						// a non-accessible field
1056
						addSyntheticFieldWriteAccessMethod(syntheticMethod);
1058
						addSyntheticFieldWriteAccessMethod(syntheticMethod);

Return to bug 249107