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

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/lookup/SourceTypeBinding.java (+3 lines)
Lines 44-49 Link Here
44
	private final static int METHOD_EMUL = 0;
44
	private final static int METHOD_EMUL = 0;
45
	private final static int FIELD_EMUL = 1;
45
	private final static int FIELD_EMUL = 1;
46
	private final static int CLASS_LITERAL_EMUL = 2;
46
	private final static int CLASS_LITERAL_EMUL = 2;
47
	/** @deprecated */
47
	private final static int RECEIVER_TYPE_EMUL = 3;
48
	private final static int RECEIVER_TYPE_EMUL = 3;
48
49
49
	private final static int MAX_SYNTHETICS = 4;
50
	private final static int MAX_SYNTHETICS = 4;
Lines 1064-1069 Link Here
1064
public ReferenceBinding[] memberTypes() {
1065
public ReferenceBinding[] memberTypes() {
1065
	return this.memberTypes;
1066
	return this.memberTypes;
1066
}
1067
}
1068
/** @deprecated */
1067
public FieldBinding getUpdatedFieldBinding(FieldBinding targetField, ReferenceBinding newDeclaringClass) {
1069
public FieldBinding getUpdatedFieldBinding(FieldBinding targetField, ReferenceBinding newDeclaringClass) {
1068
	if (this.synthetics == null)
1070
	if (this.synthetics == null)
1069
		this.synthetics = new HashMap[MAX_SYNTHETICS];
1071
		this.synthetics = new HashMap[MAX_SYNTHETICS];
Lines 1082-1087 Link Here
1082
	}
1084
	}
1083
	return updatedField;
1085
	return updatedField;
1084
}
1086
}
1087
/** @deprecated */
1085
public MethodBinding getUpdatedMethodBinding(MethodBinding targetMethod, ReferenceBinding newDeclaringClass) {
1088
public MethodBinding getUpdatedMethodBinding(MethodBinding targetMethod, ReferenceBinding newDeclaringClass) {
1086
	if (this.synthetics == null)
1089
	if (this.synthetics == null)
1087
		this.synthetics = new HashMap[MAX_SYNTHETICS];
1090
		this.synthetics = new HashMap[MAX_SYNTHETICS];
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java (-51 / +44 lines)
Lines 23-29 Link Here
23
import org.eclipse.jdt.internal.compiler.util.ObjectVector;
23
import org.eclipse.jdt.internal.compiler.util.ObjectVector;
24
import org.eclipse.jdt.internal.compiler.util.SimpleSet;
24
import org.eclipse.jdt.internal.compiler.util.SimpleSet;
25
25
26
public abstract class Scope implements TypeConstants, TypeIds {
26
public abstract class Scope {
27
27
28
	/* Scope kinds */
28
	/* Scope kinds */
29
	public final static int BLOCK_SCOPE = 1;
29
	public final static int BLOCK_SCOPE = 1;
Lines 781-787 Link Here
781
			// special treatment for Object.getClass() in 1.5 mode (substitute parameterized return type)
781
			// special treatment for Object.getClass() in 1.5 mode (substitute parameterized return type)
782
			if (receiverType.isInterface() || exactMethod.canBeSeenBy(receiverType, invocationSite, this)) {
782
			if (receiverType.isInterface() || exactMethod.canBeSeenBy(receiverType, invocationSite, this)) {
783
				if (argumentTypes == Binding.NO_PARAMETERS
783
				if (argumentTypes == Binding.NO_PARAMETERS
784
				    && CharOperation.equals(selector, GETCLASS)
784
				    && CharOperation.equals(selector, TypeConstants.GETCLASS)
785
				    && exactMethod.returnType.isParameterizedType()/*1.5*/) {
785
				    && exactMethod.returnType.isParameterizedType()/*1.5*/) {
786
						return ParameterizedMethodBinding.instantiateGetClass(receiverType, exactMethod, this);
786
						return ParameterizedMethodBinding.instantiateGetClass(receiverType, exactMethod, this);
787
			    }
787
			    }
Lines 832-838 Link Here
832
			if (leafType instanceof ReferenceBinding)
832
			if (leafType instanceof ReferenceBinding)
833
				if (!((ReferenceBinding) leafType).canBeSeenBy(this))
833
				if (!((ReferenceBinding) leafType).canBeSeenBy(this))
834
					return new ProblemFieldBinding((ReferenceBinding)leafType, fieldName, ProblemReasons.ReceiverTypeNotVisible);
834
					return new ProblemFieldBinding((ReferenceBinding)leafType, fieldName, ProblemReasons.ReceiverTypeNotVisible);
835
			if (CharOperation.equals(fieldName, LENGTH)) {
835
			if (CharOperation.equals(fieldName, TypeConstants.LENGTH)) {
836
				if ((leafType.tagBits & TagBits.HasMissingType) != 0) {
836
				if ((leafType.tagBits & TagBits.HasMissingType) != 0) {
837
					return new ProblemFieldBinding(ArrayBinding.ArrayLength, null, fieldName, ProblemReasons.NotFound);
837
					return new ProblemFieldBinding(ArrayBinding.ArrayLength, null, fieldName, ProblemReasons.NotFound);
838
				}
838
				}
Lines 1314-1332 Link Here
1314
			if (argumentTypes == Binding.NO_PARAMETERS) {
1314
			if (argumentTypes == Binding.NO_PARAMETERS) {
1315
			    switch (selector[0]) {
1315
			    switch (selector[0]) {
1316
			        case 'c':
1316
			        case 'c':
1317
			            if (CharOperation.equals(selector, CLONE)) {
1317
			            if (CharOperation.equals(selector, TypeConstants.CLONE)) {
1318
							return new UpdatedMethodBinding(
1318
			            	return environment().computeArrayClone(methodBinding);
1319
								compilerOptions().targetJDK >= ClassFileConstants.JDK1_4 ? (TypeBinding)receiverType : (TypeBinding)object, // remember its array type for codegen purpose on target>=1.4.0
1320
								(methodBinding.modifiers & ~ClassFileConstants.AccProtected) | ClassFileConstants.AccPublic,
1321
								CLONE,
1322
								methodBinding.returnType,
1323
								argumentTypes,
1324
								null,
1325
								object);
1326
			            }
1319
			            }
1327
			            break;
1320
			            break;
1328
			        case 'g':
1321
			        case 'g':
1329
			            if (CharOperation.equals(selector, GETCLASS) && methodBinding.returnType.isParameterizedType()/*1.5*/) {
1322
			            if (CharOperation.equals(selector, TypeConstants.GETCLASS) && methodBinding.returnType.isParameterizedType()/*1.5*/) {
1330
							return ParameterizedMethodBinding.instantiateGetClass(receiverType, methodBinding, this);
1323
							return ParameterizedMethodBinding.instantiateGetClass(receiverType, methodBinding, this);
1331
			            }
1324
			            }
1332
			            break;
1325
			            break;
Lines 1854-1860 Link Here
1854
										}
1847
										}
1855
										// special treatment for Object.getClass() in 1.5 mode (substitute parameterized return type)
1848
										// special treatment for Object.getClass() in 1.5 mode (substitute parameterized return type)
1856
										if (argumentTypes == Binding.NO_PARAMETERS
1849
										if (argumentTypes == Binding.NO_PARAMETERS
1857
										    && CharOperation.equals(selector, GETCLASS)
1850
										    && CharOperation.equals(selector, TypeConstants.GETCLASS)
1858
										    && methodBinding.returnType.isParameterizedType()/*1.5*/) {
1851
										    && methodBinding.returnType.isParameterizedType()/*1.5*/) {
1859
												return ParameterizedMethodBinding.instantiateGetClass(receiverType, methodBinding, this);
1852
												return ParameterizedMethodBinding.instantiateGetClass(receiverType, methodBinding, this);
1860
										}
1853
										}
Lines 2014-2078 Link Here
2014
2007
2015
	public final ReferenceBinding getJavaIoSerializable() {
2008
	public final ReferenceBinding getJavaIoSerializable() {
2016
		CompilationUnitScope unitScope = compilationUnitScope();
2009
		CompilationUnitScope unitScope = compilationUnitScope();
2017
		unitScope.recordQualifiedReference(JAVA_IO_SERIALIZABLE);
2010
		unitScope.recordQualifiedReference(TypeConstants.JAVA_IO_SERIALIZABLE);
2018
		return unitScope.environment.getResolvedType(JAVA_IO_SERIALIZABLE, this);
2011
		return unitScope.environment.getResolvedType(TypeConstants.JAVA_IO_SERIALIZABLE, this);
2019
	}
2012
	}
2020
2013
2021
	public final ReferenceBinding getJavaLangAnnotationAnnotation() {
2014
	public final ReferenceBinding getJavaLangAnnotationAnnotation() {
2022
		CompilationUnitScope unitScope = compilationUnitScope();
2015
		CompilationUnitScope unitScope = compilationUnitScope();
2023
		unitScope.recordQualifiedReference(JAVA_LANG_ANNOTATION_ANNOTATION);
2016
		unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_ANNOTATION_ANNOTATION);
2024
		return unitScope.environment.getResolvedType(JAVA_LANG_ANNOTATION_ANNOTATION, this);
2017
		return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_ANNOTATION_ANNOTATION, this);
2025
	}
2018
	}
2026
2019
2027
	public final ReferenceBinding getJavaLangAssertionError() {
2020
	public final ReferenceBinding getJavaLangAssertionError() {
2028
		CompilationUnitScope unitScope = compilationUnitScope();
2021
		CompilationUnitScope unitScope = compilationUnitScope();
2029
		unitScope.recordQualifiedReference(JAVA_LANG_ASSERTIONERROR);
2022
		unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_ASSERTIONERROR);
2030
		return unitScope.environment.getResolvedType(JAVA_LANG_ASSERTIONERROR, this);
2023
		return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_ASSERTIONERROR, this);
2031
	}
2024
	}
2032
2025
2033
	public final ReferenceBinding getJavaLangClass() {
2026
	public final ReferenceBinding getJavaLangClass() {
2034
		CompilationUnitScope unitScope = compilationUnitScope();
2027
		CompilationUnitScope unitScope = compilationUnitScope();
2035
		unitScope.recordQualifiedReference(JAVA_LANG_CLASS);
2028
		unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_CLASS);
2036
		return unitScope.environment.getResolvedType(JAVA_LANG_CLASS, this);
2029
		return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_CLASS, this);
2037
	}
2030
	}
2038
2031
2039
	public final ReferenceBinding getJavaLangCloneable() {
2032
	public final ReferenceBinding getJavaLangCloneable() {
2040
		CompilationUnitScope unitScope = compilationUnitScope();
2033
		CompilationUnitScope unitScope = compilationUnitScope();
2041
		unitScope.recordQualifiedReference(JAVA_LANG_CLONEABLE);
2034
		unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_CLONEABLE);
2042
		return unitScope.environment.getResolvedType(JAVA_LANG_CLONEABLE, this);
2035
		return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_CLONEABLE, this);
2043
	}
2036
	}
2044
	public final ReferenceBinding getJavaLangEnum() {
2037
	public final ReferenceBinding getJavaLangEnum() {
2045
		CompilationUnitScope unitScope = compilationUnitScope();
2038
		CompilationUnitScope unitScope = compilationUnitScope();
2046
		unitScope.recordQualifiedReference(JAVA_LANG_ENUM);
2039
		unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_ENUM);
2047
		return unitScope.environment.getResolvedType(JAVA_LANG_ENUM, this);
2040
		return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_ENUM, this);
2048
	}
2041
	}
2049
2042
2050
	public final ReferenceBinding getJavaLangIterable() {
2043
	public final ReferenceBinding getJavaLangIterable() {
2051
		CompilationUnitScope unitScope = compilationUnitScope();
2044
		CompilationUnitScope unitScope = compilationUnitScope();
2052
		unitScope.recordQualifiedReference(JAVA_LANG_ITERABLE);
2045
		unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_ITERABLE);
2053
		return unitScope.environment.getResolvedType(JAVA_LANG_ITERABLE, this);
2046
		return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_ITERABLE, this);
2054
	}
2047
	}
2055
	public final ReferenceBinding getJavaLangObject() {
2048
	public final ReferenceBinding getJavaLangObject() {
2056
		CompilationUnitScope unitScope = compilationUnitScope();
2049
		CompilationUnitScope unitScope = compilationUnitScope();
2057
		unitScope.recordQualifiedReference(JAVA_LANG_OBJECT);
2050
		unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_OBJECT);
2058
		return unitScope.environment.getResolvedType(JAVA_LANG_OBJECT, this);
2051
		return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_OBJECT, this);
2059
	}
2052
	}
2060
2053
2061
	public final ReferenceBinding getJavaLangString() {
2054
	public final ReferenceBinding getJavaLangString() {
2062
		CompilationUnitScope unitScope = compilationUnitScope();
2055
		CompilationUnitScope unitScope = compilationUnitScope();
2063
		unitScope.recordQualifiedReference(JAVA_LANG_STRING);
2056
		unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_STRING);
2064
		return unitScope.environment.getResolvedType(JAVA_LANG_STRING, this);
2057
		return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_STRING, this);
2065
	}
2058
	}
2066
2059
2067
	public final ReferenceBinding getJavaLangThrowable() {
2060
	public final ReferenceBinding getJavaLangThrowable() {
2068
		CompilationUnitScope unitScope = compilationUnitScope();
2061
		CompilationUnitScope unitScope = compilationUnitScope();
2069
		unitScope.recordQualifiedReference(JAVA_LANG_THROWABLE);
2062
		unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_THROWABLE);
2070
		return unitScope.environment.getResolvedType(JAVA_LANG_THROWABLE, this);
2063
		return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_THROWABLE, this);
2071
	}
2064
	}
2072
	public final ReferenceBinding getJavaUtilIterator() {
2065
	public final ReferenceBinding getJavaUtilIterator() {
2073
		CompilationUnitScope unitScope = compilationUnitScope();
2066
		CompilationUnitScope unitScope = compilationUnitScope();
2074
		unitScope.recordQualifiedReference(JAVA_UTIL_ITERATOR);
2067
		unitScope.recordQualifiedReference(TypeConstants.JAVA_UTIL_ITERATOR);
2075
		return unitScope.environment.getResolvedType(JAVA_UTIL_ITERATOR, this);
2068
		return unitScope.environment.getResolvedType(TypeConstants.JAVA_UTIL_ITERATOR, this);
2076
	}
2069
	}
2077
2070
2078
	/* Answer the type binding corresponding to the typeName argument, relative to the enclosingType.
2071
	/* Answer the type binding corresponding to the typeName argument, relative to the enclosingType.
Lines 2114-2120 Link Here
2114
2107
2115
			// special treatment for Object.getClass() in 1.5 mode (substitute parameterized return type)
2108
			// special treatment for Object.getClass() in 1.5 mode (substitute parameterized return type)
2116
			if (argumentTypes == Binding.NO_PARAMETERS
2109
			if (argumentTypes == Binding.NO_PARAMETERS
2117
			    && CharOperation.equals(selector, GETCLASS)
2110
			    && CharOperation.equals(selector, TypeConstants.GETCLASS)
2118
			    && methodBinding.returnType.isParameterizedType()/*1.5*/) {
2111
			    && methodBinding.returnType.isParameterizedType()/*1.5*/) {
2119
					return ParameterizedMethodBinding.instantiateGetClass(receiverType, methodBinding, this);
2112
					return ParameterizedMethodBinding.instantiateGetClass(receiverType, methodBinding, this);
2120
		    }
2113
		    }
Lines 3038-3045 Link Here
3038
			case 0 : return TypeBinding.VOID;
3031
			case 0 : return TypeBinding.VOID;
3039
			case 1 : return mecs[0];
3032
			case 1 : return mecs[0];
3040
			case 2 :
3033
			case 2 :
3041
				if ((commonDim == 0 ? mecs[1].id : mecs[1].leafComponentType().id) == T_JavaLangObject) return mecs[0];
3034
				if ((commonDim == 0 ? mecs[1].id : mecs[1].leafComponentType().id) == TypeIds.T_JavaLangObject) return mecs[0];
3042
				if ((commonDim == 0 ? mecs[0].id : mecs[0].leafComponentType().id) == T_JavaLangObject) return mecs[1];
3035
				if ((commonDim == 0 ? mecs[0].id : mecs[0].leafComponentType().id) == TypeIds.T_JavaLangObject) return mecs[1];
3043
		}
3036
		}
3044
		TypeBinding[] otherBounds = new TypeBinding[count - 1];
3037
		TypeBinding[] otherBounds = new TypeBinding[count - 1];
3045
		int rank = 0;
3038
		int rank = 0;
Lines 3118-3124 Link Here
3118
			if (dim > 0) {
3111
			if (dim > 0) {
3119
				leafType = typeToVisit.leafComponentType();
3112
				leafType = typeToVisit.leafComponentType();
3120
				switch(leafType.id) {
3113
				switch(leafType.id) {
3121
					case T_JavaLangObject:
3114
					case TypeIds.T_JavaLangObject:
3122
						if (dim > 1) { // Object[][] supertype is Object[]
3115
						if (dim > 1) { // Object[][] supertype is Object[]
3123
							TypeBinding elementType = ((ArrayBinding)typeToVisit).elementsType();
3116
							TypeBinding elementType = ((ArrayBinding)typeToVisit).elementsType();
3124
							if (!typesToVisit.contains(elementType)) {
3117
							if (!typesToVisit.contains(elementType)) {
Lines 3128-3141 Link Here
3128
							continue;
3121
							continue;
3129
						}
3122
						}
3130
						//$FALL-THROUGH$
3123
						//$FALL-THROUGH$
3131
					case T_byte:
3124
					case TypeIds.T_byte:
3132
					case T_short:
3125
					case TypeIds.T_short:
3133
					case T_char:
3126
					case TypeIds.T_char:
3134
					case T_boolean:
3127
					case TypeIds.T_boolean:
3135
					case T_int:
3128
					case TypeIds.T_int:
3136
					case T_long:
3129
					case TypeIds.T_long:
3137
					case T_float:
3130
					case TypeIds.T_float:
3138
					case T_double:
3131
					case TypeIds.T_double:
3139
						TypeBinding superType = getJavaIoSerializable();
3132
						TypeBinding superType = getJavaIoSerializable();
3140
						if (!typesToVisit.contains(superType)) {
3133
						if (!typesToVisit.contains(superType)) {
3141
							typesToVisit.add(superType);
3134
							typesToVisit.add(superType);
Lines 3254-3260 Link Here
3254
				TypeBinding erasedSuperType = erasedSuperTypes[j];
3247
				TypeBinding erasedSuperType = erasedSuperTypes[j];
3255
				if (erasedSuperType == null) continue nextSuperType;
3248
				if (erasedSuperType == null) continue nextSuperType;
3256
				TypeBinding match;
3249
				TypeBinding match;
3257
				if (erasedSuperType == otherType || erasedSuperType.id == T_JavaLangObject && otherType.isInterface()) {
3250
				if (erasedSuperType == otherType || erasedSuperType.id == TypeIds.T_JavaLangObject && otherType.isInterface()) {
3258
					match = erasedSuperType;
3251
					match = erasedSuperType;
3259
				} else {
3252
				} else {
3260
					if (erasedSuperType.isArrayType()) {
3253
					if (erasedSuperType.isArrayType()) {
Lines 3302-3315 Link Here
3302
					TypeBinding otherType = erasedSuperTypes[j];
3295
					TypeBinding otherType = erasedSuperTypes[j];
3303
					if (otherType == null) continue nextOtherType;
3296
					if (otherType == null) continue nextOtherType;
3304
					if (erasedSuperType instanceof ReferenceBinding) {
3297
					if (erasedSuperType instanceof ReferenceBinding) {
3305
						if (otherType.id == T_JavaLangObject && erasedSuperType.isInterface()) continue nextOtherType; // keep Object for an interface
3298
						if (otherType.id == TypeIds.T_JavaLangObject && erasedSuperType.isInterface()) continue nextOtherType; // keep Object for an interface
3306
						if (erasedSuperType.findSuperTypeOriginatingFrom(otherType) != null) {
3299
						if (erasedSuperType.findSuperTypeOriginatingFrom(otherType) != null) {
3307
							erasedSuperTypes[j] = null; // discard non minimal supertype
3300
							erasedSuperTypes[j] = null; // discard non minimal supertype
3308
							remaining--;
3301
							remaining--;
3309
						}
3302
						}
3310
					} else if (erasedSuperType.isArrayType()) {
3303
					} else if (erasedSuperType.isArrayType()) {
3311
					if (otherType.isArrayType() // keep Object[...] for an interface array (same dimensions)
3304
					if (otherType.isArrayType() // keep Object[...] for an interface array (same dimensions)
3312
							&& otherType.leafComponentType().id == T_JavaLangObject
3305
							&& otherType.leafComponentType().id == TypeIds.T_JavaLangObject
3313
							&& otherType.dimensions() == erasedSuperType.dimensions()
3306
							&& otherType.dimensions() == erasedSuperType.dimensions()
3314
							&& erasedSuperType.leafComponentType().isInterface()) continue nextOtherType;
3307
							&& erasedSuperType.leafComponentType().isInterface()) continue nextOtherType;
3315
						if (erasedSuperType.findSuperTypeOriginatingFrom(otherType) != null) {
3308
						if (erasedSuperType.findSuperTypeOriginatingFrom(otherType) != null) {
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java (-1 / +15 lines)
Lines 62-67 Link Here
62
	private CompilationUnitDeclaration[] units = new CompilationUnitDeclaration[4];
62
	private CompilationUnitDeclaration[] units = new CompilationUnitDeclaration[4];
63
	private MethodVerifier verifier;
63
	private MethodVerifier verifier;
64
64
65
	public MethodBinding arrayClone;
66
	
65
	final static int BUILD_FIELDS_AND_METHODS = 4;
67
	final static int BUILD_FIELDS_AND_METHODS = 4;
66
	final static int BUILD_TYPE_HIERARCHY = 1;
68
	final static int BUILD_TYPE_HIERARCHY = 1;
67
	final static int CHECK_AND_SET_IMPORTS = 2;
69
	final static int CHECK_AND_SET_IMPORTS = 2;
Lines 251-257 Link Here
251
		parsedUnit.scope.buildFieldsAndMethods();
253
		parsedUnit.scope.buildFieldsAndMethods();
252
	this.unitBeingCompleted = null;
254
	this.unitBeingCompleted = null;
253
}
255
}
254
256
public MethodBinding computeArrayClone(MethodBinding objectClone) {
257
	if (this.arrayClone == null) {
258
		this.arrayClone = new MethodBinding(
259
				(objectClone.modifiers & ~ClassFileConstants.AccProtected) | ClassFileConstants.AccPublic,
260
				TypeConstants.CLONE,
261
				objectClone.returnType,
262
				Binding.NO_PARAMETERS,
263
				Binding.NO_EXCEPTIONS, // no exception for array specific method
264
				(ReferenceBinding)objectClone.returnType);
265
	}
266
	return this.arrayClone;
267
	
268
}
255
public TypeBinding computeBoxingType(TypeBinding type) {
269
public TypeBinding computeBoxingType(TypeBinding type) {
256
	TypeBinding boxedType;
270
	TypeBinding boxedType;
257
	switch (type.id) {
271
	switch (type.id) {
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/TypeConstants.java (+1 lines)
Lines 73-78 Link Here
73
    char[] UPPER_LOCAL_VARIABLE = "LOCAL_VARIABLE".toCharArray(); //$NON-NLS-1$
73
    char[] UPPER_LOCAL_VARIABLE = "LOCAL_VARIABLE".toCharArray(); //$NON-NLS-1$
74
    char[] UPPER_ANNOTATION_TYPE = "ANNOTATION_TYPE".toCharArray(); //$NON-NLS-1$
74
    char[] UPPER_ANNOTATION_TYPE = "ANNOTATION_TYPE".toCharArray(); //$NON-NLS-1$
75
    char[] UPPER_PACKAGE = "PACKAGE".toCharArray(); //$NON-NLS-1$
75
    char[] UPPER_PACKAGE = "PACKAGE".toCharArray(); //$NON-NLS-1$
76
    char[] ITERATOR = "iterator".toCharArray(); //$NON-NLS-1$
76
77
77
	// Constant compound names
78
	// Constant compound names
78
	char[][] JAVA_LANG = {JAVA, LANG};
79
	char[][] JAVA_LANG = {JAVA, LANG};
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/CompilationUnitScope.java (-7 / +7 lines)
Lines 154-160 Link Here
154
	int numberOfImports = numberOfStatements + 1;
154
	int numberOfImports = numberOfStatements + 1;
155
	for (int i = 0; i < numberOfStatements; i++) {
155
	for (int i = 0; i < numberOfStatements; i++) {
156
		ImportReference importReference = this.referenceContext.imports[i];
156
		ImportReference importReference = this.referenceContext.imports[i];
157
		if (((importReference.bits & ASTNode.OnDemand) != 0) && CharOperation.equals(JAVA_LANG, importReference.tokens) && !importReference.isStatic()) {
157
		if (((importReference.bits & ASTNode.OnDemand) != 0) && CharOperation.equals(TypeConstants.JAVA_LANG, importReference.tokens) && !importReference.isStatic()) {
158
			numberOfImports--;
158
			numberOfImports--;
159
			break;
159
			break;
160
		}
160
		}
Lines 313-319 Link Here
313
	int numberOfImports = numberOfStatements + 1;
313
	int numberOfImports = numberOfStatements + 1;
314
	for (int i = 0; i < numberOfStatements; i++) {
314
	for (int i = 0; i < numberOfStatements; i++) {
315
		ImportReference importReference = this.referenceContext.imports[i];
315
		ImportReference importReference = this.referenceContext.imports[i];
316
		if (((importReference.bits & ASTNode.OnDemand) != 0) && CharOperation.equals(JAVA_LANG, importReference.tokens) && !importReference.isStatic()) {
316
		if (((importReference.bits & ASTNode.OnDemand) != 0) && CharOperation.equals(TypeConstants.JAVA_LANG, importReference.tokens) && !importReference.isStatic()) {
317
			numberOfImports--;
317
			numberOfImports--;
318
			break;
318
			break;
319
		}
319
		}
Lines 569-589 Link Here
569
	// initialize the default imports if necessary... share the default java.lang.* import
569
	// initialize the default imports if necessary... share the default java.lang.* import
570
	if (this.environment.defaultImports != null) return this.environment.defaultImports;
570
	if (this.environment.defaultImports != null) return this.environment.defaultImports;
571
571
572
	Binding importBinding = this.environment.getTopLevelPackage(JAVA);
572
	Binding importBinding = this.environment.getTopLevelPackage(TypeConstants.JAVA);
573
	if (importBinding != null)
573
	if (importBinding != null)
574
		importBinding = ((PackageBinding) importBinding).getTypeOrPackage(JAVA_LANG[1]);
574
		importBinding = ((PackageBinding) importBinding).getTypeOrPackage(TypeConstants.JAVA_LANG[1]);
575
575
576
	if (importBinding == null || !importBinding.isValidBinding()) {
576
	if (importBinding == null || !importBinding.isValidBinding()) {
577
		// create a proxy for the missing BinaryType
577
		// create a proxy for the missing BinaryType
578
		problemReporter().isClassPathCorrect(
578
		problemReporter().isClassPathCorrect(
579
			JAVA_LANG_OBJECT,
579
				TypeConstants.JAVA_LANG_OBJECT,
580
			this.referenceContext,
580
			this.referenceContext,
581
			this.environment.missingClassFileLocation);
581
			this.environment.missingClassFileLocation);
582
		BinaryTypeBinding missingObject = this.environment.createMissingType(null, JAVA_LANG_OBJECT);
582
		BinaryTypeBinding missingObject = this.environment.createMissingType(null, TypeConstants.JAVA_LANG_OBJECT);
583
		importBinding = missingObject.fPackage;
583
		importBinding = missingObject.fPackage;
584
	}
584
	}
585
585
586
	return this.environment.defaultImports = new ImportBinding[] {new ImportBinding(JAVA_LANG, true, importBinding, null)};
586
	return this.environment.defaultImports = new ImportBinding[] {new ImportBinding(TypeConstants.JAVA_LANG, true, importBinding, null)};
587
}
587
}
588
// NOT Public API
588
// NOT Public API
589
public final Binding getImport(char[][] compoundName, boolean onDemand, boolean isStaticImport) {
589
public final Binding getImport(char[][] compoundName, boolean onDemand, boolean isStaticImport) {
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/MethodBinding.java (-8 lines)
Lines 391-404 Link Here
391
	return uniqueKey;
391
	return uniqueKey;
392
}
392
}
393
393
394
/*
395
 * Answer the declaring class to use in the constant pool
396
 * may not be a reference binding (see subtypes)
397
 */
398
public TypeBinding constantPoolDeclaringClass() {
399
	return this.declaringClass;
400
}
401
402
/* Answer the receiver's constant pool name.
394
/* Answer the receiver's constant pool name.
403
*
395
*
404
* <init> for constructors
396
* <init> for constructors
(-)compiler/org/eclipse/jdt/internal/compiler/lookup/UpdatedMethodBinding.java (-25 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler.lookup;
12
13
public class UpdatedMethodBinding extends MethodBinding {
14
15
	public TypeBinding updatedDeclaringClass;
16
17
	public UpdatedMethodBinding(TypeBinding updatedDeclaringClass, int modifiers, char[] selector, TypeBinding returnType, TypeBinding[] args, ReferenceBinding[] exceptions, ReferenceBinding declaringClass) {
18
		super(modifiers, selector, returnType, args, exceptions, declaringClass);
19
		this.updatedDeclaringClass = updatedDeclaringClass;
20
	}
21
22
	public TypeBinding constantPoolDeclaringClass() {
23
		return this.updatedDeclaringClass;
24
	}
25
}
(-)compiler/org/eclipse/jdt/internal/compiler/codegen/CodeStream.java (-20 / +21 lines)
Lines 2245-2251 Link Here
2245
			FieldBinding fieldBinding = (FieldBinding) mappingSequence[i];
2245
			FieldBinding fieldBinding = (FieldBinding) mappingSequence[i];
2246
			getfield(fieldBinding);
2246
			getfield(fieldBinding);
2247
		} else {
2247
		} else {
2248
			invokestatic((MethodBinding) mappingSequence[i]);
2248
			invokestatic((MethodBinding) mappingSequence[i], null /* default declaringClass */);
2249
		}
2249
		}
2250
	}
2250
	}
2251
}
2251
}
Lines 2312-2320 Link Here
2312
 * @param accessBinding the access method binding to generate
2312
 * @param accessBinding the access method binding to generate
2313
 */
2313
 */
2314
public void generateSyntheticBodyForConstructorAccess(SyntheticMethodBinding accessBinding) {
2314
public void generateSyntheticBodyForConstructorAccess(SyntheticMethodBinding accessBinding) {
2315
2316
	initializeMaxLocals(accessBinding);
2315
	initializeMaxLocals(accessBinding);
2317
2318
	MethodBinding constructorBinding = accessBinding.targetMethod;
2316
	MethodBinding constructorBinding = accessBinding.targetMethod;
2319
	TypeBinding[] parameters = constructorBinding.parameters;
2317
	TypeBinding[] parameters = constructorBinding.parameters;
2320
	int length = parameters.length;
2318
	int length = parameters.length;
Lines 2359-2365 Link Here
2359
				resolvedPosition++;
2357
				resolvedPosition++;
2360
		}
2358
		}
2361
	}
2359
	}
2362
	invokespecial(constructorBinding);
2360
	invokespecial(constructorBinding, null /* default declaringClass */);
2363
	return_();
2361
	return_();
2364
}
2362
}
2365
//static X valueOf(String name) {
2363
//static X valueOf(String name) {
Lines 2451-2457 Link Here
2451
	return_();
2449
	return_();
2452
}
2450
}
2453
public void generateSyntheticBodyForMethodAccess(SyntheticMethodBinding accessMethod) {
2451
public void generateSyntheticBodyForMethodAccess(SyntheticMethodBinding accessMethod) {
2454
2455
	initializeMaxLocals(accessMethod);
2452
	initializeMaxLocals(accessMethod);
2456
	MethodBinding targetMethod = accessMethod.targetMethod;
2453
	MethodBinding targetMethod = accessMethod.targetMethod;
2457
	TypeBinding[] parameters = targetMethod.parameters;
2454
	TypeBinding[] parameters = targetMethod.parameters;
Lines 2482-2499 Link Here
2482
			resolvedPosition++;
2479
			resolvedPosition++;
2483
	}
2480
	}
2484
	if (targetMethod.isStatic())
2481
	if (targetMethod.isStatic())
2485
		invokestatic(targetMethod);
2482
		invokestatic(targetMethod, null /* default declaringClass */);
2486
	else {
2483
	else {
2487
		if (targetMethod.isConstructor()
2484
		if (targetMethod.isConstructor()
2488
			|| targetMethod.isPrivate()
2485
			|| targetMethod.isPrivate()
2489
			// qualified super "X.super.foo()" targets methods from superclass
2486
			// qualified super "X.super.foo()" targets methods from superclass
2490
			|| accessMethod.purpose == SyntheticMethodBinding.SuperMethodAccess){
2487
			|| accessMethod.purpose == SyntheticMethodBinding.SuperMethodAccess){
2491
			invokespecial(targetMethod);
2488
			invokespecial(targetMethod, null /* default declaringClass */);
2492
		} else {
2489
		} else {
2493
			if (targetMethod.declaringClass.isInterface()) { // interface or annotation type
2490
			if (targetMethod.declaringClass.isInterface()) { // interface or annotation type
2494
				invokeinterface(targetMethod);
2491
				invokeinterface(targetMethod, null /* default declaringClass */);
2495
			} else {
2492
			} else {
2496
				invokevirtual(targetMethod);
2493
				invokevirtual(targetMethod, accessMethod.declaringClass);
2497
			}
2494
			}
2498
		}
2495
		}
2499
	}
2496
	}
Lines 3845-3852 Link Here
3845
			ConstantPool.Ordinal,
3842
			ConstantPool.Ordinal,
3846
			ConstantPool.OrdinalSignature);
3843
			ConstantPool.OrdinalSignature);
3847
}
3844
}
3848
public void invokeinterface(MethodBinding methodBinding) {
3845
public void invokeinterface(MethodBinding methodBinding, TypeBinding declaringClass) {
3849
	if (DEBUG) System.out.println(this.position + "\t\tinvokeinterface: " + methodBinding); //$NON-NLS-1$
3846
	if (DEBUG) System.out.println(this.position + "\t\tinvokeinterface: " + methodBinding); //$NON-NLS-1$
3847
	if (declaringClass == null) declaringClass = methodBinding.declaringClass;
3850
	this.countLabels = 0;
3848
	this.countLabels = 0;
3851
	// initialized to 1 to take into account this  immediately
3849
	// initialized to 1 to take into account this  immediately
3852
	int argCount = 1;
3850
	int argCount = 1;
Lines 3858-3864 Link Here
3858
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_invokeinterface;
3856
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_invokeinterface;
3859
	writeUnsignedShort(
3857
	writeUnsignedShort(
3860
		this.constantPool.literalIndexForMethod(
3858
		this.constantPool.literalIndexForMethod(
3861
			methodBinding.constantPoolDeclaringClass(),
3859
			declaringClass,
3862
			methodBinding.selector,
3860
			methodBinding.selector,
3863
			methodBinding.signature(this.classFile),
3861
			methodBinding.signature(this.classFile),
3864
			true));
3862
			true));
Lines 4143-4150 Link Here
4143
			ConstantPool.GetClass,
4141
			ConstantPool.GetClass,
4144
			ConstantPool.GetClassSignature);
4142
			ConstantPool.GetClassSignature);
4145
}
4143
}
4146
public void invokespecial(MethodBinding methodBinding) {
4144
public void invokespecial(MethodBinding methodBinding, TypeBinding declaringClass) {
4147
	if (DEBUG) System.out.println(this.position + "\t\tinvokespecial:"+methodBinding); //$NON-NLS-1$
4145
	if (DEBUG) System.out.println(this.position + "\t\tinvokespecial:"+methodBinding); //$NON-NLS-1$
4146
	if (declaringClass == null) declaringClass = methodBinding.declaringClass;
4148
	this.countLabels = 0;
4147
	this.countLabels = 0;
4149
	// initialized to 1 to take into account this immediately
4148
	// initialized to 1 to take into account this immediately
4150
	int argCount = 1;
4149
	int argCount = 1;
Lines 4156-4170 Link Here
4156
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_invokespecial;
4155
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_invokespecial;
4157
	writeUnsignedShort(
4156
	writeUnsignedShort(
4158
		this.constantPool.literalIndexForMethod(
4157
		this.constantPool.literalIndexForMethod(
4159
			methodBinding.constantPoolDeclaringClass(),
4158
				declaringClass,
4160
			methodBinding.selector,
4159
			methodBinding.selector,
4161
			methodBinding.signature(this.classFile),
4160
			methodBinding.signature(this.classFile),
4162
			false));
4161
			false));
4163
	if (methodBinding.isConstructor()) {
4162
	if (methodBinding.isConstructor()) {
4164
		final ReferenceBinding declaringClass = methodBinding.declaringClass;
4165
		if (declaringClass.isNestedType()) {
4163
		if (declaringClass.isNestedType()) {
4164
			final ReferenceBinding nestedType = (ReferenceBinding) declaringClass;
4166
			// enclosing instances
4165
			// enclosing instances
4167
			TypeBinding[] syntheticArgumentTypes = declaringClass.syntheticEnclosingInstanceTypes();
4166
			TypeBinding[] syntheticArgumentTypes = nestedType.syntheticEnclosingInstanceTypes();
4168
			if (syntheticArgumentTypes != null) {
4167
			if (syntheticArgumentTypes != null) {
4169
				for (int i = 0, max = syntheticArgumentTypes.length; i < max; i++) {
4168
				for (int i = 0, max = syntheticArgumentTypes.length; i < max; i++) {
4170
					if (((id = syntheticArgumentTypes[i].id) == TypeIds.T_double) || (id == TypeIds.T_long)) {
4169
					if (((id = syntheticArgumentTypes[i].id) == TypeIds.T_double) || (id == TypeIds.T_long)) {
Lines 4175-4181 Link Here
4175
				}
4174
				}
4176
			}
4175
			}
4177
			// outer local variables
4176
			// outer local variables
4178
			SyntheticArgumentBinding[] syntheticArguments = declaringClass.syntheticOuterLocalVariables();
4177
			SyntheticArgumentBinding[] syntheticArguments = nestedType.syntheticOuterLocalVariables();
4179
			if (syntheticArguments != null) {
4178
			if (syntheticArguments != null) {
4180
				for (int i = 0, max = syntheticArguments.length; i < max; i++) {
4179
				for (int i = 0, max = syntheticArguments.length; i < max; i++) {
4181
					if (((id = syntheticArguments[i].type.id) == TypeIds.T_double) || (id == TypeIds.T_long)) {
4180
					if (((id = syntheticArguments[i].type.id) == TypeIds.T_double) || (id == TypeIds.T_long)) {
Lines 4206-4213 Link Here
4206
	if (this.stackDepth > this.stackMax)
4205
	if (this.stackDepth > this.stackMax)
4207
		this.stackMax = this.stackDepth;
4206
		this.stackMax = this.stackDepth;
4208
}
4207
}
4209
public void invokestatic(MethodBinding methodBinding) {
4208
public void invokestatic(MethodBinding methodBinding, TypeBinding declaringClass) {
4210
	if (DEBUG) System.out.println(this.position + "\t\tinvokestatic:"+methodBinding); //$NON-NLS-1$
4209
	if (DEBUG) System.out.println(this.position + "\t\tinvokestatic:"+methodBinding); //$NON-NLS-1$
4210
	if (declaringClass == null) declaringClass = methodBinding.declaringClass;
4211
	// initialized to 0 to take into account that there is no this for
4211
	// initialized to 0 to take into account that there is no this for
4212
	// a static method
4212
	// a static method
4213
	this.countLabels = 0;
4213
	this.countLabels = 0;
Lines 4220-4226 Link Here
4220
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_invokestatic;
4220
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_invokestatic;
4221
	writeUnsignedShort(
4221
	writeUnsignedShort(
4222
		this.constantPool.literalIndexForMethod(
4222
		this.constantPool.literalIndexForMethod(
4223
			methodBinding.constantPoolDeclaringClass(),
4223
			declaringClass,
4224
			methodBinding.selector,
4224
			methodBinding.selector,
4225
			methodBinding.signature(this.classFile),
4225
			methodBinding.signature(this.classFile),
4226
			false));
4226
			false));
Lines 4481-4488 Link Here
4481
			ConstantPool.GetMessage,
4481
			ConstantPool.GetMessage,
4482
			ConstantPool.GetMessageSignature);
4482
			ConstantPool.GetMessageSignature);
4483
}
4483
}
4484
public void invokevirtual(MethodBinding methodBinding) {
4484
public void invokevirtual(MethodBinding methodBinding,TypeBinding declaringClass) {
4485
	if (DEBUG) System.out.println(this.position + "\t\tinvokevirtual:"+methodBinding); //$NON-NLS-1$
4485
	if (DEBUG) System.out.println(this.position + "\t\tinvokevirtual:"+methodBinding); //$NON-NLS-1$
4486
	if (declaringClass == null) declaringClass = methodBinding.declaringClass;
4486
	this.countLabels = 0;
4487
	this.countLabels = 0;
4487
	// initialized to 1 to take into account this  immediately
4488
	// initialized to 1 to take into account this  immediately
4488
	int argCount = 1;
4489
	int argCount = 1;
Lines 4494-4500 Link Here
4494
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_invokevirtual;
4495
	this.bCodeStream[this.classFileOffset++] = Opcodes.OPC_invokevirtual;
4495
	writeUnsignedShort(
4496
	writeUnsignedShort(
4496
		this.constantPool.literalIndexForMethod(
4497
		this.constantPool.literalIndexForMethod(
4497
			methodBinding.constantPoolDeclaringClass(),
4498
				declaringClass,
4498
			methodBinding.selector,
4499
			methodBinding.selector,
4499
			methodBinding.signature(this.classFile),
4500
			methodBinding.signature(this.classFile),
4500
			false));
4501
			false));
(-)compiler/org/eclipse/jdt/internal/compiler/ast/FieldReference.java (-6 / +6 lines)
Lines 233-239 Link Here
233
					codeStream.getfield(this.codegenBinding);
233
					codeStream.getfield(this.codegenBinding);
234
				}
234
				}
235
			} else {
235
			} else {
236
				codeStream.invokestatic(this.syntheticAccessors[FieldReference.READ]);
236
				codeStream.invokestatic(this.syntheticAccessors[FieldReference.READ], null /* default declaringClass */);
237
			}
237
			}
238
			// required cast must occur even if no value is required
238
			// required cast must occur even if no value is required
239
			if (this.genericCast != null) codeStream.checkcast(this.genericCast);
239
			if (this.genericCast != null) codeStream.checkcast(this.genericCast);
Lines 262-268 Link Here
262
					if (accessor == null) {
262
					if (accessor == null) {
263
						codeStream.getstatic(this.codegenBinding);
263
						codeStream.getstatic(this.codegenBinding);
264
					} else {
264
					} else {
265
						codeStream.invokestatic(accessor);
265
						codeStream.invokestatic(accessor, null /* default declaringClass */);
266
					}
266
					}
267
					switch (this.codegenBinding.type.id) {
267
					switch (this.codegenBinding.type.id) {
268
						case T_long :
268
						case T_long :
Lines 295-308 Link Here
295
		if (this.syntheticAccessors == null || this.syntheticAccessors[FieldReference.READ] == null) {
295
		if (this.syntheticAccessors == null || this.syntheticAccessors[FieldReference.READ] == null) {
296
			codeStream.getstatic(this.codegenBinding);
296
			codeStream.getstatic(this.codegenBinding);
297
		} else {
297
		} else {
298
			codeStream.invokestatic(this.syntheticAccessors[FieldReference.READ]);
298
			codeStream.invokestatic(this.syntheticAccessors[FieldReference.READ], null /* default declaringClass */);
299
		}
299
		}
300
	} else {
300
	} else {
301
		codeStream.dup();
301
		codeStream.dup();
302
		if (this.syntheticAccessors == null || this.syntheticAccessors[FieldReference.READ] == null) {
302
		if (this.syntheticAccessors == null || this.syntheticAccessors[FieldReference.READ] == null) {
303
			codeStream.getfield(this.codegenBinding);
303
			codeStream.getfield(this.codegenBinding);
304
		} else {
304
		} else {
305
			codeStream.invokestatic(this.syntheticAccessors[FieldReference.READ]);
305
			codeStream.invokestatic(this.syntheticAccessors[FieldReference.READ], null /* default declaringClass */);
306
		}
306
		}
307
	}
307
	}
308
	int operationTypeID;
308
	int operationTypeID;
Lines 346-359 Link Here
346
		if (this.syntheticAccessors == null || this.syntheticAccessors[FieldReference.READ] == null) {
346
		if (this.syntheticAccessors == null || this.syntheticAccessors[FieldReference.READ] == null) {
347
			codeStream.getstatic(this.codegenBinding);
347
			codeStream.getstatic(this.codegenBinding);
348
		} else {
348
		} else {
349
			codeStream.invokestatic(this.syntheticAccessors[FieldReference.READ]);
349
			codeStream.invokestatic(this.syntheticAccessors[FieldReference.READ], null /* default declaringClass */);
350
		}
350
		}
351
	} else {
351
	} else {
352
		codeStream.dup();
352
		codeStream.dup();
353
		if (this.syntheticAccessors == null || this.syntheticAccessors[FieldReference.READ] == null) {
353
		if (this.syntheticAccessors == null || this.syntheticAccessors[FieldReference.READ] == null) {
354
			codeStream.getfield(this.codegenBinding);
354
			codeStream.getfield(this.codegenBinding);
355
		} else {
355
		} else {
356
			codeStream.invokestatic(this.syntheticAccessors[FieldReference.READ]);
356
			codeStream.invokestatic(this.syntheticAccessors[FieldReference.READ], null /* default declaringClass */);
357
		}
357
		}
358
	}
358
	}
359
	TypeBinding operandType;
359
	TypeBinding operandType;
(-)compiler/org/eclipse/jdt/internal/compiler/ast/Reference.java (-2 / +2 lines)
Lines 44-50 Link Here
44
		if (syntheticWriteAccessor == null) {
44
		if (syntheticWriteAccessor == null) {
45
			codeStream.putstatic(fieldBinding);
45
			codeStream.putstatic(fieldBinding);
46
		} else {
46
		} else {
47
			codeStream.invokestatic(syntheticWriteAccessor);
47
			codeStream.invokestatic(syntheticWriteAccessor, null /* default declaringClass */);
48
		}
48
		}
49
	} else { // Stack:  [owner][new field value]  ---> [new field value][owner][new field value]
49
	} else { // Stack:  [owner][new field value]  ---> [new field value][owner][new field value]
50
		if (valueRequired) {
50
		if (valueRequired) {
Lines 57-63 Link Here
57
		if (syntheticWriteAccessor == null) {
57
		if (syntheticWriteAccessor == null) {
58
			codeStream.putfield(fieldBinding);
58
			codeStream.putfield(fieldBinding);
59
		} else {
59
		} else {
60
			codeStream.invokestatic(syntheticWriteAccessor);
60
			codeStream.invokestatic(syntheticWriteAccessor, null /* default declaringClass */);
61
		}
61
		}
62
	}
62
	}
63
	codeStream.recordPositionsFrom(pc, this.sourceStart);
63
	codeStream.recordPositionsFrom(pc, this.sourceStart);
(-)compiler/org/eclipse/jdt/internal/compiler/ast/SingleNameReference.java (-6 / +6 lines)
Lines 377-383 Link Here
377
					if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
377
					if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
378
						codeStream.getstatic(fieldBinding);
378
						codeStream.getstatic(fieldBinding);
379
					} else {
379
					} else {
380
						codeStream.invokestatic(this.syntheticAccessors[SingleNameReference.READ]);
380
						codeStream.invokestatic(this.syntheticAccessors[SingleNameReference.READ], null /* default declaringClass */);
381
					}
381
					}
382
				} else {
382
				} else {
383
					if (!valueRequired
383
					if (!valueRequired
Lines 399-405 Link Here
399
					if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
399
					if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
400
						codeStream.getfield(fieldBinding);
400
						codeStream.getfield(fieldBinding);
401
					} else {
401
					} else {
402
						codeStream.invokestatic(this.syntheticAccessors[SingleNameReference.READ]);
402
						codeStream.invokestatic(this.syntheticAccessors[SingleNameReference.READ], null /* default declaringClass */);
403
					}
403
					}
404
				}
404
				}
405
				break;
405
				break;
Lines 474-480 Link Here
474
				if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
474
				if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
475
					codeStream.getstatic(fieldBinding);
475
					codeStream.getstatic(fieldBinding);
476
				} else {
476
				} else {
477
					codeStream.invokestatic(this.syntheticAccessors[SingleNameReference.READ]);
477
					codeStream.invokestatic(this.syntheticAccessors[SingleNameReference.READ], null /* default declaringClass */);
478
				}
478
				}
479
			} else {
479
			} else {
480
				if ((this.bits & ASTNode.DepthMASK) != 0) {
480
				if ((this.bits & ASTNode.DepthMASK) != 0) {
Lines 488-494 Link Here
488
				if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
488
				if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
489
					codeStream.getfield(fieldBinding);
489
					codeStream.getfield(fieldBinding);
490
				} else {
490
				} else {
491
					codeStream.invokestatic(this.syntheticAccessors[SingleNameReference.READ]);
491
					codeStream.invokestatic(this.syntheticAccessors[SingleNameReference.READ], null /* default declaringClass */);
492
				}
492
				}
493
			}
493
			}
494
			break;
494
			break;
Lines 587-593 Link Here
587
				if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
587
				if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
588
					codeStream.getstatic(fieldBinding);
588
					codeStream.getstatic(fieldBinding);
589
				} else {
589
				} else {
590
					codeStream.invokestatic(this.syntheticAccessors[SingleNameReference.READ]);
590
					codeStream.invokestatic(this.syntheticAccessors[SingleNameReference.READ], null /* default declaringClass */);
591
				}
591
				}
592
			} else {
592
			} else {
593
				if ((this.bits & ASTNode.DepthMASK) != 0) {
593
				if ((this.bits & ASTNode.DepthMASK) != 0) {
Lines 601-607 Link Here
601
				if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
601
				if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
602
					codeStream.getfield(fieldBinding);
602
					codeStream.getfield(fieldBinding);
603
				} else {
603
				} else {
604
					codeStream.invokestatic(this.syntheticAccessors[SingleNameReference.READ]);
604
					codeStream.invokestatic(this.syntheticAccessors[SingleNameReference.READ], null /* default declaringClass */);
605
				}
605
				}
606
			}
606
			}
607
			TypeBinding operandType;
607
			TypeBinding operandType;
(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedAllocationExpression.java (-2 / +2 lines)
Lines 138-144 Link Here
138
138
139
		// invoke constructor
139
		// invoke constructor
140
		if (this.syntheticAccessor == null) {
140
		if (this.syntheticAccessor == null) {
141
			codeStream.invokespecial(this.codegenBinding);
141
			codeStream.invokespecial(this.codegenBinding, null /* default declaringClass */);
142
		} else {
142
		} else {
143
			// synthetic accessor got some extra arguments appended to its signature, which need values
143
			// synthetic accessor got some extra arguments appended to its signature, which need values
144
			for (int i = 0,
144
			for (int i = 0,
Lines 147-153 Link Here
147
				i++) {
147
				i++) {
148
				codeStream.aconst_null();
148
				codeStream.aconst_null();
149
			}
149
			}
150
			codeStream.invokespecial(this.syntheticAccessor);
150
			codeStream.invokespecial(this.syntheticAccessor, null /* default declaringClass */);
151
		}
151
		}
152
		if (valueRequired) {
152
		if (valueRequired) {
153
			codeStream.generateImplicitConversion(this.implicitConversion);
153
			codeStream.generateImplicitConversion(this.implicitConversion);
(-)compiler/org/eclipse/jdt/internal/compiler/ast/SwitchStatement.java (-1 / +1 lines)
Lines 156-162 Link Here
156
			if (resolvedType.isEnum()) {
156
			if (resolvedType.isEnum()) {
157
				if (needSwitch) {
157
				if (needSwitch) {
158
					// go through the translation table
158
					// go through the translation table
159
					codeStream.invokestatic(this.synthetic);
159
					codeStream.invokestatic(this.synthetic, null /* default declaringClass */);
160
					this.expression.generateCode(currentScope, codeStream, true);
160
					this.expression.generateCode(currentScope, codeStream, true);
161
					// get enum constant ordinal()
161
					// get enum constant ordinal()
162
					codeStream.invokeEnumOrdinal(resolvedType.constantPoolName());
162
					codeStream.invokeEnumOrdinal(resolvedType.constantPoolName());
(-)compiler/org/eclipse/jdt/internal/compiler/ast/AllocationExpression.java (-2 / +2 lines)
Lines 115-121 Link Here
115
	}
115
	}
116
	// invoke constructor
116
	// invoke constructor
117
	if (this.syntheticAccessor == null) {
117
	if (this.syntheticAccessor == null) {
118
		codeStream.invokespecial(this.codegenBinding);
118
		codeStream.invokespecial(this.codegenBinding, null /* default declaringClass */);
119
	} else {
119
	} else {
120
		// synthetic accessor got some extra arguments appended to its signature, which need values
120
		// synthetic accessor got some extra arguments appended to its signature, which need values
121
		for (int i = 0,
121
		for (int i = 0,
Lines 124-130 Link Here
124
			i++) {
124
			i++) {
125
			codeStream.aconst_null();
125
			codeStream.aconst_null();
126
		}
126
		}
127
		codeStream.invokespecial(this.syntheticAccessor);
127
		codeStream.invokespecial(this.syntheticAccessor, null /* default declaringClass */);
128
	}
128
	}
129
	if (valueRequired) {
129
	if (valueRequired) {
130
		codeStream.generateImplicitConversion(this.implicitConversion);
130
		codeStream.generateImplicitConversion(this.implicitConversion);
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ForeachStatement.java (-11 / +19 lines)
Lines 12-19 Link Here
12
12
13
import org.eclipse.jdt.internal.compiler.ASTVisitor;
13
import org.eclipse.jdt.internal.compiler.ASTVisitor;
14
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
14
import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
15
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
16
import org.eclipse.jdt.internal.compiler.codegen.BranchLabel;
15
import org.eclipse.jdt.internal.compiler.codegen.BranchLabel;
16
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
17
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
17
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
18
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
18
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
19
import org.eclipse.jdt.internal.compiler.flow.LoopingFlowContext;
19
import org.eclipse.jdt.internal.compiler.flow.LoopingFlowContext;
Lines 27-32 Link Here
27
import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
27
import org.eclipse.jdt.internal.compiler.lookup.ParameterizedTypeBinding;
28
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
28
import org.eclipse.jdt.internal.compiler.lookup.ReferenceBinding;
29
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
29
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
30
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
30
31
31
public class ForeachStatement extends Statement {
32
public class ForeachStatement extends Statement {
32
33
Lines 63-68 Link Here
63
	int postCollectionInitStateIndex = -1;
64
	int postCollectionInitStateIndex = -1;
64
	int mergedInitStateIndex = -1;
65
	int mergedInitStateIndex = -1;
65
66
67
	private static MethodBinding ITERATOR_METHOD;
68
	
66
	public ForeachStatement(
69
	public ForeachStatement(
67
		LocalDeclaration elementVariable,
70
		LocalDeclaration elementVariable,
68
		int start) {
71
		int start) {
Lines 212-229 Link Here
212
			case GENERIC_ITERABLE :
215
			case GENERIC_ITERABLE :
213
				this.collection.generateCode(this.scope, codeStream, true);
216
				this.collection.generateCode(this.scope, codeStream, true);
214
				// declaringClass.iterator();
217
				// declaringClass.iterator();
215
				MethodBinding iteratorMethodBinding =
216
					new MethodBinding(
217
							ClassFileConstants.AccPublic,
218
							"iterator".toCharArray(),//$NON-NLS-1$
219
							this.scope.getJavaUtilIterator(),
220
							Binding.NO_PARAMETERS,
221
							Binding.NO_EXCEPTIONS,
222
							(ReferenceBinding) this.iteratorReceiverType.erasure());
223
				if (this.iteratorReceiverType.isInterface()) {
218
				if (this.iteratorReceiverType.isInterface()) {
224
					codeStream.invokeinterface(iteratorMethodBinding);
219
					codeStream.invokeinterface(getIteratorMethod(), this.iteratorReceiverType);
225
				} else {
220
				} else {
226
					codeStream.invokevirtual(iteratorMethodBinding);
221
					codeStream.invokevirtual(getIteratorMethod(), this.iteratorReceiverType);
227
				}
222
				}
228
				codeStream.store(this.indexVariable, false);
223
				codeStream.store(this.indexVariable, false);
229
				codeStream.addVariable(this.indexVariable);
224
				codeStream.addVariable(this.indexVariable);
Lines 367-372 Link Here
367
		this.breakLabel.place();
362
		this.breakLabel.place();
368
		codeStream.recordPositionsFrom(pc, this.sourceStart);
363
		codeStream.recordPositionsFrom(pc, this.sourceStart);
369
	}
364
	}
365
	private MethodBinding getIteratorMethod() {
366
		if (ITERATOR_METHOD == null) {
367
			ITERATOR_METHOD = new MethodBinding(
368
					ClassFileConstants.AccPublic,
369
					TypeConstants.ITERATOR,
370
					this.scope.getJavaUtilIterator(),
371
					Binding.NO_PARAMETERS,
372
					Binding.NO_EXCEPTIONS,
373
					null);
374
			
375
		}
376
		return ITERATOR_METHOD;
377
	}
370
378
371
	public StringBuffer printStatement(int indent, StringBuffer output) {
379
	public StringBuffer printStatement(int indent, StringBuffer output) {
372
380
(-)compiler/org/eclipse/jdt/internal/compiler/ast/MessageSend.java (-42 / +43 lines)
Lines 34-40 Link Here
34
import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
34
import org.eclipse.jdt.internal.compiler.lookup.SourceTypeBinding;
35
import org.eclipse.jdt.internal.compiler.lookup.TagBits;
35
import org.eclipse.jdt.internal.compiler.lookup.TagBits;
36
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
36
import org.eclipse.jdt.internal.compiler.lookup.TypeBinding;
37
import org.eclipse.jdt.internal.compiler.lookup.TypeConstants;
38
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
37
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
39
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
38
import org.eclipse.jdt.internal.compiler.problem.ProblemSeverities;
40
39
Lines 96-107 Link Here
96
	    		? compileTimeType  // unboxing: checkcast before conversion
95
	    		? compileTimeType  // unboxing: checkcast before conversion
97
	    		: runtimeTimeType;
96
	    		: runtimeTimeType;
98
	        this.valueCast = originalType.genericCast(targetType);
97
	        this.valueCast = originalType.genericCast(targetType);
99
		} 	else if (this.actualReceiverType.isArrayType()
98
		} 	else if (this.binding == scope.environment().arrayClone
100
						&& runtimeTimeType.id != TypeIds.T_JavaLangObject
99
				&& runtimeTimeType.id != TypeIds.T_JavaLangObject
101
						&& this.binding.parameters == Binding.NO_PARAMETERS
100
				&& scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) {
102
						&& scope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_5
101
					// from 1.5 source level on, array#clone() resolves to array type, but codegen to #clone()Object - thus require extra inserted cast
103
						&& CharOperation.equals(this.binding.selector, TypeConstants.CLONE)) {
104
					// from 1.5 compliant mode on, array#clone() resolves to array type, but codegen to #clone()Object - thus require extra inserted cast
105
			this.valueCast = runtimeTimeType;
102
			this.valueCast = runtimeTimeType;
106
		}
103
		}
107
        if (this.valueCast instanceof ReferenceBinding) {
104
        if (this.valueCast instanceof ReferenceBinding) {
Lines 148-170 Link Here
148
	}
145
	}
149
	// generate arguments
146
	// generate arguments
150
	generateArguments(this.binding, this.arguments, currentScope, codeStream);
147
	generateArguments(this.binding, this.arguments, currentScope, codeStream);
148
151
	// actual message invocation
149
	// actual message invocation
152
	if (this.syntheticAccessor == null){
150
	if (this.syntheticAccessor == null){
151
		TypeBinding constantPoolDeclaringClass = getConstantPoolDeclaringClass(currentScope);
153
		if (isStatic){
152
		if (isStatic){
154
			codeStream.invokestatic(this.codegenBinding);
153
			codeStream.invokestatic(this.codegenBinding, constantPoolDeclaringClass);
154
		} else if( (this.receiver.isSuper()) || this.codegenBinding.isPrivate()){
155
			codeStream.invokespecial(this.codegenBinding, constantPoolDeclaringClass);
155
		} else {
156
		} else {
156
			if( (this.receiver.isSuper()) || this.codegenBinding.isPrivate()){
157
			if (constantPoolDeclaringClass.isInterface()) { // interface or annotation type
157
				codeStream.invokespecial(this.codegenBinding);
158
				codeStream.invokeinterface(this.codegenBinding, constantPoolDeclaringClass);
158
			} else {
159
			} else {
159
				if (this.codegenBinding.declaringClass.isInterface()) { // interface or annotation type
160
				codeStream.invokevirtual(this.codegenBinding, constantPoolDeclaringClass);
160
					codeStream.invokeinterface(this.codegenBinding);
161
				} else {
162
					codeStream.invokevirtual(this.codegenBinding);
163
				}
164
			}
161
			}
165
		}
162
		}
166
	} else {
163
	} else {
167
		codeStream.invokestatic(this.syntheticAccessor);
164
		codeStream.invokestatic(this.syntheticAccessor, null /* default declaringClass */);
168
	}
165
	}
169
	// required cast must occur even if no value is required
166
	// required cast must occur even if no value is required
170
	if (this.valueCast != null) codeStream.checkcast(this.valueCast);
167
	if (this.valueCast != null) codeStream.checkcast(this.valueCast);
Lines 188-194 Link Here
188
	}
185
	}
189
	codeStream.recordPositionsFrom(pc, (int)(this.nameSourcePosition >>> 32)); // highlight selector
186
	codeStream.recordPositionsFrom(pc, (int)(this.nameSourcePosition >>> 32)); // highlight selector
190
}
187
}
191
192
/**
188
/**
193
 * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#genericTypeArguments()
189
 * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#genericTypeArguments()
194
 */
190
 */
Lines 196-201 Link Here
196
	return this.genericTypeArguments;
192
	return this.genericTypeArguments;
197
}
193
}
198
194
195
protected TypeBinding getConstantPoolDeclaringClass(BlockScope currentScope) {
196
	// constantpool declaringClass
197
	TypeBinding constantPoolDeclaringClass = this.codegenBinding.declaringClass;
198
	// Post 1.4.0 target, array clone() invocations are qualified with array type
199
	// This is handled in array type #clone method binding resolution (see Scope and UpdatedMethodBinding)
200
	if (this.codegenBinding == currentScope.environment().arrayClone) {
201
		CompilerOptions options = currentScope.compilerOptions();
202
		if (options.sourceLevel > ClassFileConstants.JDK1_4 ) {
203
			constantPoolDeclaringClass = this.actualReceiverType.erasure();
204
		}
205
	} else {
206
		// if the binding declaring class is not visible, need special action
207
		// for runtime compatibility on 1.2 VMs : change the declaring class of the binding
208
		// NOTE: from target 1.2 on, method's declaring class is touched if any different from receiver type
209
		// and not from Object or implicit static method call.
210
		if (constantPoolDeclaringClass != this.actualReceiverType && this.receiverGenericCast == null && !this.actualReceiverType.isArrayType()) {
211
			CompilerOptions options = currentScope.compilerOptions();
212
			if ((options.targetJDK >= ClassFileConstants.JDK1_2
213
						&& (options.complianceLevel >= ClassFileConstants.JDK1_4 || !(this.receiver.isImplicitThis() && this.codegenBinding.isStatic()))
214
						&& this.binding.declaringClass.id != TypeIds.T_JavaLangObject) // no change for Object methods
215
					|| !this.binding.declaringClass.canBeSeenBy(currentScope)) {
216
				constantPoolDeclaringClass = this.actualReceiverType.erasure();
217
			}
218
		}				
219
	}
220
	return constantPoolDeclaringClass;
221
}
222
199
public boolean isSuperAccess() {
223
public boolean isSuperAccess() {
200
	return this.receiver.isSuper();
224
	return this.receiver.isSuper();
201
}
225
}
Lines 239-264 Link Here
239
			return;
263
			return;
240
		}
264
		}
241
	}
265
	}
242
243
	// if the binding declaring class is not visible, need special action
244
	// for runtime compatibility on 1.2 VMs : change the declaring class of the binding
245
	// NOTE: from target 1.2 on, method's declaring class is touched if any different from receiver type
246
	// and not from Object or implicit static method call.
247
	if (this.binding.declaringClass != this.actualReceiverType
248
			&& this.receiverGenericCast == null
249
			&& !this.actualReceiverType.isArrayType()) {
250
		CompilerOptions options = currentScope.compilerOptions();
251
		if ((options.targetJDK >= ClassFileConstants.JDK1_2
252
				&& (options.complianceLevel >= ClassFileConstants.JDK1_4 || !(this.receiver.isImplicitThis() && this.codegenBinding.isStatic()))
253
				&& this.binding.declaringClass.id != TypeIds.T_JavaLangObject) // no change for Object methods
254
			|| !this.binding.declaringClass.canBeSeenBy(currentScope)) {
255
256
			this.codegenBinding = currentScope.enclosingSourceType().getUpdatedMethodBinding(
257
			        										this.codegenBinding, (ReferenceBinding) this.actualReceiverType.erasure());
258
		}
259
		// Post 1.4.0 target, array clone() invocations are qualified with array type
260
		// This is handled in array type #clone method binding resolution (see Scope and UpdatedMethodBinding)
261
	}
262
}
266
}
263
public int nullStatus(FlowInfo flowInfo) {
267
public int nullStatus(FlowInfo flowInfo) {
264
	return FlowInfo.UNKNOWN;
268
	return FlowInfo.UNKNOWN;
Lines 507-517 Link Here
507
	if (isMethodUseDeprecated(this.binding, scope, true))
511
	if (isMethodUseDeprecated(this.binding, scope, true))
508
		scope.problemReporter().deprecatedMethod(this.binding, this);
512
		scope.problemReporter().deprecatedMethod(this.binding, this);
509
513
510
	// from 1.5 compliance on, array#clone() returns the array type (but binding still shows Object)
514
	// from 1.5 source level on, array#clone() returns the array type (but binding still shows Object)
511
	if (this.actualReceiverType.isArrayType()
515
	if (this.binding == scope.environment().arrayClone && compilerOptions.sourceLevel >= ClassFileConstants.JDK1_5) {
512
			&& this.binding.parameters == Binding.NO_PARAMETERS
513
			&& compilerOptions.complianceLevel >= ClassFileConstants.JDK1_5
514
			&& CharOperation.equals(this.binding.selector, TypeConstants.CLONE)) {
515
		this.resolvedType = this.actualReceiverType;
516
		this.resolvedType = this.actualReceiverType;
516
	} else {
517
	} else {
517
		TypeBinding returnType = this.binding.returnType;
518
		TypeBinding returnType = this.binding.returnType;
(-)compiler/org/eclipse/jdt/internal/compiler/ast/QualifiedNameReference.java (-7 / +7 lines)
Lines 401-407 Link Here
401
								codeStream.getfield(lastFieldBinding);
401
								codeStream.getfield(lastFieldBinding);
402
							}
402
							}
403
						} else {
403
						} else {
404
							codeStream.invokestatic(accessor);
404
							codeStream.invokestatic(accessor, null /* default declaringClass */);
405
						}
405
						}
406
						if (requiredGenericCast != null) codeStream.checkcast(requiredGenericCast);
406
						if (requiredGenericCast != null) codeStream.checkcast(requiredGenericCast);
407
						if (valueRequired) {
407
						if (valueRequired) {
Lines 452-465 Link Here
452
		if (accessor == null) {
452
		if (accessor == null) {
453
			codeStream.getstatic(lastFieldBinding);
453
			codeStream.getstatic(lastFieldBinding);
454
		} else {
454
		} else {
455
			codeStream.invokestatic(accessor);
455
			codeStream.invokestatic(accessor, null /* default declaringClass */);
456
		}
456
		}
457
	} else {
457
	} else {
458
		codeStream.dup();
458
		codeStream.dup();
459
		if (accessor == null) {
459
		if (accessor == null) {
460
			codeStream.getfield(lastFieldBinding);
460
			codeStream.getfield(lastFieldBinding);
461
		} else {
461
		} else {
462
			codeStream.invokestatic(accessor);
462
			codeStream.invokestatic(accessor, null /* default declaringClass */);
463
		}
463
		}
464
	}
464
	}
465
	// the last field access is a write access
465
	// the last field access is a write access
Lines 501-514 Link Here
501
		if (accessor == null) {
501
		if (accessor == null) {
502
			codeStream.getstatic(lastFieldBinding);
502
			codeStream.getstatic(lastFieldBinding);
503
		} else {
503
		} else {
504
			codeStream.invokestatic(accessor);
504
			codeStream.invokestatic(accessor, null /* default declaringClass */);
505
		}
505
		}
506
	} else {
506
	} else {
507
		codeStream.dup();
507
		codeStream.dup();
508
		if (accessor == null) {
508
		if (accessor == null) {
509
			codeStream.getfield(lastFieldBinding);
509
			codeStream.getfield(lastFieldBinding);
510
		} else {
510
		} else {
511
			codeStream.invokestatic(accessor);
511
			codeStream.invokestatic(accessor, null /* default declaringClass */);
512
		}
512
		}
513
	}
513
	}
514
	TypeBinding requiredGenericCast = getGenericCast(this.otherCodegenBindings == null ? 0 : this.otherCodegenBindings.length);
514
	TypeBinding requiredGenericCast = getGenericCast(this.otherCodegenBindings == null ? 0 : this.otherCodegenBindings.length);
Lines 628-634 Link Here
628
								codeStream.getfield(lastFieldBinding);
628
								codeStream.getfield(lastFieldBinding);
629
							}
629
							}
630
						} else {
630
						} else {
631
							codeStream.invokestatic(accessor);
631
							codeStream.invokestatic(accessor, null /* default declaringClass */);
632
						}
632
						}
633
						if (lastGenericCast != null) codeStream.checkcast(lastGenericCast);
633
						if (lastGenericCast != null) codeStream.checkcast(lastGenericCast);
634
						if (!needValue) codeStream.pop();
634
						if (!needValue) codeStream.pop();
Lines 641-647 Link Here
641
									if (accessor == null) {
641
									if (accessor == null) {
642
										codeStream.getstatic(lastFieldBinding);
642
										codeStream.getstatic(lastFieldBinding);
643
									} else {
643
									} else {
644
										codeStream.invokestatic(accessor);
644
										codeStream.invokestatic(accessor, null /* default declaringClass */);
645
									}
645
									}
646
									codeStream.pop();
646
									codeStream.pop();
647
								}
647
								}
(-)compiler/org/eclipse/jdt/internal/compiler/ast/ExplicitConstructorCall.java (-2 / +2 lines)
Lines 148-156 Link Here
148
					i++) {
148
					i++) {
149
					codeStream.aconst_null();
149
					codeStream.aconst_null();
150
				}
150
				}
151
				codeStream.invokespecial(this.syntheticAccessor);
151
				codeStream.invokespecial(this.syntheticAccessor, null /* default declaringClass */);
152
			} else {
152
			} else {
153
				codeStream.invokespecial(this.codegenBinding);
153
				codeStream.invokespecial(this.codegenBinding, null /* default declaringClass */);
154
			}
154
			}
155
			codeStream.recordPositionsFrom(pc, this.sourceStart);
155
			codeStream.recordPositionsFrom(pc, this.sourceStart);
156
		} finally {
156
		} finally {
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetReturnStatement.java (-1 / +1 lines)
Lines 83-89 Link Here
83
	}
83
	}
84
84
85
	// generate the invoke virtual to "setResult(Object,Class)"
85
	// generate the invoke virtual to "setResult(Object,Class)"
86
	codeStream.invokevirtual(this.setResultMethod);
86
	codeStream.invokevirtual(this.setResultMethod, null /* default declaringClass */);
87
}
87
}
88
/**
88
/**
89
 * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#genericTypeArguments()
89
 * @see org.eclipse.jdt.internal.compiler.lookup.InvocationSite#genericTypeArguments()
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetMessageSend.java (-11 / +10 lines)
Lines 32-38 Link Here
32
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
32
import org.eclipse.jdt.internal.compiler.lookup.TypeIds;
33
import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
33
import org.eclipse.jdt.internal.compiler.lookup.TypeVariableBinding;
34
34
35
public class CodeSnippetMessageSend extends MessageSend implements ProblemReasons, EvaluationConstants {
35
public class CodeSnippetMessageSend extends MessageSend {
36
	EvaluationContext evaluationContext;
36
	EvaluationContext evaluationContext;
37
	FieldBinding delegateThis;
37
	FieldBinding delegateThis;
38
/**
38
/**
Lines 78-94 Link Here
78
		// generate arguments
78
		// generate arguments
79
		generateArguments(this.binding, this.arguments, currentScope, codeStream);
79
		generateArguments(this.binding, this.arguments, currentScope, codeStream);
80
		// actual message invocation
80
		// actual message invocation
81
		TypeBinding constantPoolDeclaringClass = getConstantPoolDeclaringClass(currentScope);
81
		if (isStatic) {
82
		if (isStatic) {
82
			codeStream.invokestatic(this.codegenBinding);
83
			codeStream.invokestatic(this.codegenBinding, constantPoolDeclaringClass);
84
		} else if( (this.receiver.isSuper()) || this.codegenBinding.isPrivate()){
85
			codeStream.invokespecial(this.codegenBinding, constantPoolDeclaringClass);
83
		} else {
86
		} else {
84
			if (this.receiver.isSuper()) {
87
			if (constantPoolDeclaringClass.isInterface()) { // interface or annotation type
85
				codeStream.invokespecial(this.codegenBinding);
88
				codeStream.invokeinterface(this.codegenBinding, constantPoolDeclaringClass);
86
			} else {
89
			} else {
87
				if (this.codegenBinding.declaringClass.isInterface()) {
90
				codeStream.invokevirtual(this.codegenBinding, constantPoolDeclaringClass);
88
					codeStream.invokeinterface(this.codegenBinding);
89
				} else {
90
					codeStream.invokevirtual(this.codegenBinding);
91
				}
92
			}
91
			}
93
		}
92
		}
94
	} else {
93
	} else {
Lines 273-281 Link Here
273
			: scope.getMethod(this.actualReceiverType, this.selector, argumentTypes, this);
272
			: scope.getMethod(this.actualReceiverType, this.selector, argumentTypes, this);
274
	if (!this.binding.isValidBinding()) {
273
	if (!this.binding.isValidBinding()) {
275
		if (this.binding instanceof ProblemMethodBinding
274
		if (this.binding instanceof ProblemMethodBinding
276
			&& ((ProblemMethodBinding) this.binding).problemId() == NotVisible) {
275
			&& ((ProblemMethodBinding) this.binding).problemId() == ProblemReasons.NotVisible) {
277
			if (this.evaluationContext.declaringTypeName != null) {
276
			if (this.evaluationContext.declaringTypeName != null) {
278
				this.delegateThis = scope.getField(scope.enclosingSourceType(), DELEGATE_THIS, this);
277
				this.delegateThis = scope.getField(scope.enclosingSourceType(), EvaluationConstants.DELEGATE_THIS, this);
279
				if (this.delegateThis == null){ // if not found then internal error, field should have been found
278
				if (this.delegateThis == null){ // if not found then internal error, field should have been found
280
					this.constant = Constant.NotAConstant;
279
					this.constant = Constant.NotAConstant;
281
					scope.problemReporter().invalidMethod(this, this.binding);
280
					scope.problemReporter().invalidMethod(this, this.binding);
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetAllocationExpression.java (-1 / +1 lines)
Lines 73-79 Link Here
73
				this);
73
				this);
74
		}
74
		}
75
		// invoke constructor
75
		// invoke constructor
76
		codeStream.invokespecial(this.codegenBinding);
76
		codeStream.invokespecial(this.codegenBinding, null /* default declaringClass */);
77
	} else {
77
	} else {
78
		// private emulation using reflect
78
		// private emulation using reflect
79
		codeStream.generateEmulationForConstructor(currentScope, this.codegenBinding);
79
		codeStream.generateEmulationForConstructor(currentScope, this.codegenBinding);
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetQualifiedNameReference.java (-2 / +2 lines)
Lines 222-235 Link Here
222
			if (accessor == null) {
222
			if (accessor == null) {
223
				codeStream.getstatic(lastFieldBinding);
223
				codeStream.getstatic(lastFieldBinding);
224
			} else {
224
			} else {
225
				codeStream.invokestatic(accessor);
225
				codeStream.invokestatic(accessor, null /* default declaringClass */);
226
			}
226
			}
227
		} else {
227
		} else {
228
			codeStream.dup();
228
			codeStream.dup();
229
			if (accessor == null) {
229
			if (accessor == null) {
230
				codeStream.getfield(lastFieldBinding);
230
				codeStream.getfield(lastFieldBinding);
231
			} else {
231
			} else {
232
				codeStream.invokestatic(accessor);
232
				codeStream.invokestatic(accessor, null /* default declaringClass */);
233
			}
233
			}
234
		}
234
		}
235
235
(-)eval/org/eclipse/jdt/internal/eval/CodeSnippetScope.java (-3 / +3 lines)
Lines 271-277 Link Here
271
		if (!((ReferenceBinding)leafType).canBeSeenBy(this)) {
271
		if (!((ReferenceBinding)leafType).canBeSeenBy(this)) {
272
			return new ProblemFieldBinding((ReferenceBinding)leafType, fieldName, ProblemReasons.ReceiverTypeNotVisible);
272
			return new ProblemFieldBinding((ReferenceBinding)leafType, fieldName, ProblemReasons.ReceiverTypeNotVisible);
273
		}
273
		}
274
		if (CharOperation.equals(fieldName, LENGTH))
274
		if (CharOperation.equals(fieldName, TypeConstants.LENGTH))
275
			return ArrayBinding.ArrayLength;
275
			return ArrayBinding.ArrayLength;
276
		return null;
276
		return null;
277
	}
277
	}
Lines 371-378 Link Here
371
	MethodBinding methodBinding = object.getExactMethod(selector, argumentTypes, null);
371
	MethodBinding methodBinding = object.getExactMethod(selector, argumentTypes, null);
372
	if (methodBinding != null) {
372
	if (methodBinding != null) {
373
		// handle the method clone() specially... cannot be protected or throw exceptions
373
		// handle the method clone() specially... cannot be protected or throw exceptions
374
		if (argumentTypes == Binding.NO_PARAMETERS && CharOperation.equals(selector, CLONE))
374
		if (argumentTypes == Binding.NO_PARAMETERS && CharOperation.equals(selector, TypeConstants.CLONE))
375
			return new MethodBinding((methodBinding.modifiers & ~ClassFileConstants.AccProtected) | ClassFileConstants.AccPublic, CLONE, methodBinding.returnType, argumentTypes, null, object);
375
			return new MethodBinding((methodBinding.modifiers & ~ClassFileConstants.AccProtected) | ClassFileConstants.AccPublic, TypeConstants.CLONE, methodBinding.returnType, argumentTypes, null, object);
376
		if (canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this))
376
		if (canBeSeenByForCodeSnippet(methodBinding, receiverType, invocationSite, this))
377
			return methodBinding;
377
			return methodBinding;
378
	}
378
	}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/ArrayTest.java (+151 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.core.tests.compiler.regression;
11
package org.eclipse.jdt.core.tests.compiler.regression;
12
import java.io.File;
12
import java.io.File;
13
import java.util.Map;
13
14
14
import junit.framework.Test;
15
import junit.framework.Test;
15
16
Lines 393-396 Link Here
393
		"argument cannot be resolved\n" +
394
		"argument cannot be resolved\n" +
394
		"----------\n");
395
		"----------\n");
395
}
396
}
397
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247307
398
// Check return type of array#clone()
399
public void test014() throws Exception {
400
	Map optionsMap = getCompilerOptions();
401
	CompilerOptions options = new CompilerOptions(optionsMap);
402
	if (options.complianceLevel > ClassFileConstants.JDK1_4) {
403
		// check that #clone() return type is changed ONLY from -source 1.5 only (independant from compliance level)
404
		optionsMap.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_4);		
405
	}	
406
	this.runNegativeTest(
407
			new String[] {
408
				"X.java",
409
				"public class X {\n" + 
410
				"	void foo(long[] longs) throws Exception {\n" + 
411
				"		long[] other = longs.clone();\n" + 
412
				"	}\n" + 
413
				"}\n",
414
			},
415
			"----------\n" + 
416
			"1. ERROR in X.java (at line 3)\n" + 
417
			"	long[] other = longs.clone();\n" + 
418
			"	               ^^^^^^^^^^^^^\n" + 
419
			"Type mismatch: cannot convert from Object to long[]\n" + 
420
			"----------\n",
421
			null,
422
			true,
423
			optionsMap);
424
}
425
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247307 - variation
426
//Check return type of array#clone()
427
public void test015() throws Exception {
428
	if ( new CompilerOptions(getCompilerOptions()).sourceLevel < ClassFileConstants.JDK1_5) {
429
		return;
430
	}
431
	this.runConformTest(
432
		new String[] {
433
			"X.java",
434
			"public class X {\n" + 
435
			"	void foo(long[] longs) throws Exception {\n" + 
436
			"		long[] other = longs.clone();\n" + 
437
			"	}\n" + 
438
			"}\n",
439
		},
440
		"");
441
}
442
//https:bugs.eclipse.org/bugs/show_bug.cgi?id=247307 - variation
443
//Check constant pool declaring class of array#clone()
444
public void test016() throws Exception {
445
	this.runConformTest(
446
			new String[] {
447
				"X.java",
448
				"public class X {\n" + 
449
				"	void foo(long[] longs) throws Exception {\n" + 
450
				"		Object other = longs.clone();\n" + 
451
				"	}\n" + 
452
				"}\n",
453
			},
454
			"");
455
	ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
456
	byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(new File(OUTPUT_DIR + File.separator  +"X.class"));
457
	String actualOutput =
458
		disassembler.disassemble(
459
			classFileBytes,
460
			"\n",
461
			ClassFileBytesDisassembler.DETAILED);
462
463
	String expectedOutput =	new CompilerOptions(getCompilerOptions()).sourceLevel <= ClassFileConstants.JDK1_4
464
		?	"  // Method descriptor #15 ([J)V\n" + 
465
			"  // Stack: 1, Locals: 3\n" + 
466
			"  void foo(long[] longs) throws java.lang.Exception;\n" + 
467
			"    0  aload_1 [longs]\n" + 
468
			"    1  invokevirtual java.lang.Object.clone() : java.lang.Object [19]\n" + 
469
			"    4  astore_2 [other]\n" + 
470
			"    5  return\n" + 
471
			"      Line numbers:\n" + 
472
			"        [pc: 0, line: 3]\n" + 
473
			"        [pc: 5, line: 4]\n"
474
		:	"  // Method descriptor #15 ([J)V\n" + 
475
			"  // Stack: 1, Locals: 3\n" + 
476
			"  void foo(long[] longs) throws java.lang.Exception;\n" + 
477
			"    0  aload_1 [longs]\n" + 
478
			"    1  invokevirtual long[].clone() : java.lang.Object [19]\n" + 
479
			"    4  astore_2 [other]\n" + 
480
			"    5  return\n" + 
481
			"      Line numbers:\n" + 
482
			"        [pc: 0, line: 3]\n" + 
483
			"        [pc: 5, line: 4]\n";
484
485
	int index = actualOutput.indexOf(expectedOutput);
486
	if (index == -1 || expectedOutput.length() == 0) {
487
		System.out.println(Util.displayString(actualOutput, 3));
488
	}
489
	if (index == -1) {
490
		assertEquals("unexpected bytecode sequence", expectedOutput, actualOutput);
491
	}		
492
	return;
493
}
494
495
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=247307 - variation
496
//Check constant pool declaring class of array#clone()
497
public void test017() throws Exception {
498
	Map optionsMap = getCompilerOptions();
499
	CompilerOptions options = new CompilerOptions(optionsMap);
500
	if (options.complianceLevel > ClassFileConstants.JDK1_4) {
501
		// check that #clone() return type is changed ONLY from -source 1.5 only (independant from compliance level)
502
		optionsMap.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_4);		
503
	}
504
	this.runConformTest(
505
			new String[] {
506
				"X.java",
507
				"public class X {\n" + 
508
				"	void foo(long[] longs) throws Exception {\n" + 
509
				"		Object other = longs.clone();\n" + 
510
				"	}\n" + 
511
				"}\n",
512
			},
513
			"",
514
			null,
515
			true,
516
			null,
517
			optionsMap,
518
			null);
519
	ClassFileBytesDisassembler disassembler = ToolFactory.createDefaultClassFileBytesDisassembler();
520
	byte[] classFileBytes = org.eclipse.jdt.internal.compiler.util.Util.getFileByteContent(new File(OUTPUT_DIR + File.separator  +"X.class"));
521
	String actualOutput =
522
		disassembler.disassemble(
523
			classFileBytes,
524
			"\n",
525
			ClassFileBytesDisassembler.DETAILED);
526
527
	String expectedOutput =
528
		"  // Method descriptor #15 ([J)V\n" + 
529
		"  // Stack: 1, Locals: 3\n" + 
530
		"  void foo(long[] longs) throws java.lang.Exception;\n" + 
531
		"    0  aload_1 [longs]\n" + 
532
		"    1  invokevirtual java.lang.Object.clone() : java.lang.Object [19]\n" + 
533
		"    4  astore_2 [other]\n" + 
534
		"    5  return\n" + 
535
		"      Line numbers:\n" + 
536
		"        [pc: 0, line: 3]\n" + 
537
		"        [pc: 5, line: 4]\n";
538
539
	int index = actualOutput.indexOf(expectedOutput);
540
	if (index == -1 || expectedOutput.length() == 0) {
541
		System.out.println(Util.displayString(actualOutput, 3));
542
	}
543
	if (index == -1) {
544
		assertEquals("unexpected bytecode sequence", expectedOutput, actualOutput);
545
	}		
546
}
396
}
547
}
(-)src/org/eclipse/jdt/core/tests/compiler/regression/Compliance_1_4.java (-2 / +3 lines)
Lines 1423-1430 Link Here
1423
			"\n",
1423
			"\n",
1424
			ClassFileBytesDisassembler.DETAILED);
1424
			ClassFileBytesDisassembler.DETAILED);
1425
1425
1426
	String expectedOutput =
1426
	String expectedOutput = new CompilerOptions(getCompilerOptions()).sourceLevel <= ClassFileConstants.JDK1_4
1427
		"     1  invokevirtual java.lang.String[].clone() : java.lang.Object [16]\n";
1427
		?	"     1  invokevirtual java.lang.Object.clone() : java.lang.Object [16]\n"
1428
		:	"     1  invokevirtual java.lang.String[].clone() : java.lang.Object [16]\n";
1428
1429
1429
	int index = actualOutput.indexOf(expectedOutput);
1430
	int index = actualOutput.indexOf(expectedOutput);
1430
	if (index == -1 || expectedOutput.length() == 0) {
1431
	if (index == -1 || expectedOutput.length() == 0) {

Return to bug 247292