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 new 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, |
1319 |
(methodBinding.modifiers & ~ClassFileConstants.AccProtected) | ClassFileConstants.AccPublic, |
1321 |
CLONE, |
1320 |
TypeConstants.CLONE, |
1322 |
methodBinding.returnType, |
1321 |
methodBinding.returnType, |
1323 |
argumentTypes, |
1322 |
argumentTypes, |
1324 |
null, |
1323 |
Binding.NO_EXCEPTIONS, |
1325 |
object); |
1324 |
object); |
1326 |
} |
1325 |
} |
1327 |
break; |
1326 |
break; |
1328 |
case 'g': |
1327 |
case 'g': |
1329 |
if (CharOperation.equals(selector, GETCLASS) && methodBinding.returnType.isParameterizedType()/*1.5*/) { |
1328 |
if (CharOperation.equals(selector, TypeConstants.GETCLASS) && methodBinding.returnType.isParameterizedType()/*1.5*/) { |
1330 |
return ParameterizedMethodBinding.instantiateGetClass(receiverType, methodBinding, this); |
1329 |
return ParameterizedMethodBinding.instantiateGetClass(receiverType, methodBinding, this); |
1331 |
} |
1330 |
} |
1332 |
break; |
1331 |
break; |
Lines 1854-1860
Link Here
|
1854 |
} |
1853 |
} |
1855 |
// special treatment for Object.getClass() in 1.5 mode (substitute parameterized return type) |
1854 |
// special treatment for Object.getClass() in 1.5 mode (substitute parameterized return type) |
1856 |
if (argumentTypes == Binding.NO_PARAMETERS |
1855 |
if (argumentTypes == Binding.NO_PARAMETERS |
1857 |
&& CharOperation.equals(selector, GETCLASS) |
1856 |
&& CharOperation.equals(selector, TypeConstants.GETCLASS) |
1858 |
&& methodBinding.returnType.isParameterizedType()/*1.5*/) { |
1857 |
&& methodBinding.returnType.isParameterizedType()/*1.5*/) { |
1859 |
return ParameterizedMethodBinding.instantiateGetClass(receiverType, methodBinding, this); |
1858 |
return ParameterizedMethodBinding.instantiateGetClass(receiverType, methodBinding, this); |
1860 |
} |
1859 |
} |
Lines 2014-2078
Link Here
|
2014 |
|
2013 |
|
2015 |
public final ReferenceBinding getJavaIoSerializable() { |
2014 |
public final ReferenceBinding getJavaIoSerializable() { |
2016 |
CompilationUnitScope unitScope = compilationUnitScope(); |
2015 |
CompilationUnitScope unitScope = compilationUnitScope(); |
2017 |
unitScope.recordQualifiedReference(JAVA_IO_SERIALIZABLE); |
2016 |
unitScope.recordQualifiedReference(TypeConstants.JAVA_IO_SERIALIZABLE); |
2018 |
return unitScope.environment.getResolvedType(JAVA_IO_SERIALIZABLE, this); |
2017 |
return unitScope.environment.getResolvedType(TypeConstants.JAVA_IO_SERIALIZABLE, this); |
2019 |
} |
2018 |
} |
2020 |
|
2019 |
|
2021 |
public final ReferenceBinding getJavaLangAnnotationAnnotation() { |
2020 |
public final ReferenceBinding getJavaLangAnnotationAnnotation() { |
2022 |
CompilationUnitScope unitScope = compilationUnitScope(); |
2021 |
CompilationUnitScope unitScope = compilationUnitScope(); |
2023 |
unitScope.recordQualifiedReference(JAVA_LANG_ANNOTATION_ANNOTATION); |
2022 |
unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_ANNOTATION_ANNOTATION); |
2024 |
return unitScope.environment.getResolvedType(JAVA_LANG_ANNOTATION_ANNOTATION, this); |
2023 |
return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_ANNOTATION_ANNOTATION, this); |
2025 |
} |
2024 |
} |
2026 |
|
2025 |
|
2027 |
public final ReferenceBinding getJavaLangAssertionError() { |
2026 |
public final ReferenceBinding getJavaLangAssertionError() { |
2028 |
CompilationUnitScope unitScope = compilationUnitScope(); |
2027 |
CompilationUnitScope unitScope = compilationUnitScope(); |
2029 |
unitScope.recordQualifiedReference(JAVA_LANG_ASSERTIONERROR); |
2028 |
unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_ASSERTIONERROR); |
2030 |
return unitScope.environment.getResolvedType(JAVA_LANG_ASSERTIONERROR, this); |
2029 |
return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_ASSERTIONERROR, this); |
2031 |
} |
2030 |
} |
2032 |
|
2031 |
|
2033 |
public final ReferenceBinding getJavaLangClass() { |
2032 |
public final ReferenceBinding getJavaLangClass() { |
2034 |
CompilationUnitScope unitScope = compilationUnitScope(); |
2033 |
CompilationUnitScope unitScope = compilationUnitScope(); |
2035 |
unitScope.recordQualifiedReference(JAVA_LANG_CLASS); |
2034 |
unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_CLASS); |
2036 |
return unitScope.environment.getResolvedType(JAVA_LANG_CLASS, this); |
2035 |
return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_CLASS, this); |
2037 |
} |
2036 |
} |
2038 |
|
2037 |
|
2039 |
public final ReferenceBinding getJavaLangCloneable() { |
2038 |
public final ReferenceBinding getJavaLangCloneable() { |
2040 |
CompilationUnitScope unitScope = compilationUnitScope(); |
2039 |
CompilationUnitScope unitScope = compilationUnitScope(); |
2041 |
unitScope.recordQualifiedReference(JAVA_LANG_CLONEABLE); |
2040 |
unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_CLONEABLE); |
2042 |
return unitScope.environment.getResolvedType(JAVA_LANG_CLONEABLE, this); |
2041 |
return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_CLONEABLE, this); |
2043 |
} |
2042 |
} |
2044 |
public final ReferenceBinding getJavaLangEnum() { |
2043 |
public final ReferenceBinding getJavaLangEnum() { |
2045 |
CompilationUnitScope unitScope = compilationUnitScope(); |
2044 |
CompilationUnitScope unitScope = compilationUnitScope(); |
2046 |
unitScope.recordQualifiedReference(JAVA_LANG_ENUM); |
2045 |
unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_ENUM); |
2047 |
return unitScope.environment.getResolvedType(JAVA_LANG_ENUM, this); |
2046 |
return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_ENUM, this); |
2048 |
} |
2047 |
} |
2049 |
|
2048 |
|
2050 |
public final ReferenceBinding getJavaLangIterable() { |
2049 |
public final ReferenceBinding getJavaLangIterable() { |
2051 |
CompilationUnitScope unitScope = compilationUnitScope(); |
2050 |
CompilationUnitScope unitScope = compilationUnitScope(); |
2052 |
unitScope.recordQualifiedReference(JAVA_LANG_ITERABLE); |
2051 |
unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_ITERABLE); |
2053 |
return unitScope.environment.getResolvedType(JAVA_LANG_ITERABLE, this); |
2052 |
return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_ITERABLE, this); |
2054 |
} |
2053 |
} |
2055 |
public final ReferenceBinding getJavaLangObject() { |
2054 |
public final ReferenceBinding getJavaLangObject() { |
2056 |
CompilationUnitScope unitScope = compilationUnitScope(); |
2055 |
CompilationUnitScope unitScope = compilationUnitScope(); |
2057 |
unitScope.recordQualifiedReference(JAVA_LANG_OBJECT); |
2056 |
unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_OBJECT); |
2058 |
return unitScope.environment.getResolvedType(JAVA_LANG_OBJECT, this); |
2057 |
return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_OBJECT, this); |
2059 |
} |
2058 |
} |
2060 |
|
2059 |
|
2061 |
public final ReferenceBinding getJavaLangString() { |
2060 |
public final ReferenceBinding getJavaLangString() { |
2062 |
CompilationUnitScope unitScope = compilationUnitScope(); |
2061 |
CompilationUnitScope unitScope = compilationUnitScope(); |
2063 |
unitScope.recordQualifiedReference(JAVA_LANG_STRING); |
2062 |
unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_STRING); |
2064 |
return unitScope.environment.getResolvedType(JAVA_LANG_STRING, this); |
2063 |
return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_STRING, this); |
2065 |
} |
2064 |
} |
2066 |
|
2065 |
|
2067 |
public final ReferenceBinding getJavaLangThrowable() { |
2066 |
public final ReferenceBinding getJavaLangThrowable() { |
2068 |
CompilationUnitScope unitScope = compilationUnitScope(); |
2067 |
CompilationUnitScope unitScope = compilationUnitScope(); |
2069 |
unitScope.recordQualifiedReference(JAVA_LANG_THROWABLE); |
2068 |
unitScope.recordQualifiedReference(TypeConstants.JAVA_LANG_THROWABLE); |
2070 |
return unitScope.environment.getResolvedType(JAVA_LANG_THROWABLE, this); |
2069 |
return unitScope.environment.getResolvedType(TypeConstants.JAVA_LANG_THROWABLE, this); |
2071 |
} |
2070 |
} |
2072 |
public final ReferenceBinding getJavaUtilIterator() { |
2071 |
public final ReferenceBinding getJavaUtilIterator() { |
2073 |
CompilationUnitScope unitScope = compilationUnitScope(); |
2072 |
CompilationUnitScope unitScope = compilationUnitScope(); |
2074 |
unitScope.recordQualifiedReference(JAVA_UTIL_ITERATOR); |
2073 |
unitScope.recordQualifiedReference(TypeConstants.JAVA_UTIL_ITERATOR); |
2075 |
return unitScope.environment.getResolvedType(JAVA_UTIL_ITERATOR, this); |
2074 |
return unitScope.environment.getResolvedType(TypeConstants.JAVA_UTIL_ITERATOR, this); |
2076 |
} |
2075 |
} |
2077 |
|
2076 |
|
2078 |
/* Answer the type binding corresponding to the typeName argument, relative to the enclosingType. |
2077 |
/* Answer the type binding corresponding to the typeName argument, relative to the enclosingType. |
Lines 2114-2120
Link Here
|
2114 |
|
2113 |
|
2115 |
// special treatment for Object.getClass() in 1.5 mode (substitute parameterized return type) |
2114 |
// special treatment for Object.getClass() in 1.5 mode (substitute parameterized return type) |
2116 |
if (argumentTypes == Binding.NO_PARAMETERS |
2115 |
if (argumentTypes == Binding.NO_PARAMETERS |
2117 |
&& CharOperation.equals(selector, GETCLASS) |
2116 |
&& CharOperation.equals(selector, TypeConstants.GETCLASS) |
2118 |
&& methodBinding.returnType.isParameterizedType()/*1.5*/) { |
2117 |
&& methodBinding.returnType.isParameterizedType()/*1.5*/) { |
2119 |
return ParameterizedMethodBinding.instantiateGetClass(receiverType, methodBinding, this); |
2118 |
return ParameterizedMethodBinding.instantiateGetClass(receiverType, methodBinding, this); |
2120 |
} |
2119 |
} |
Lines 3038-3045
Link Here
|
3038 |
case 0 : return TypeBinding.VOID; |
3037 |
case 0 : return TypeBinding.VOID; |
3039 |
case 1 : return mecs[0]; |
3038 |
case 1 : return mecs[0]; |
3040 |
case 2 : |
3039 |
case 2 : |
3041 |
if ((commonDim == 0 ? mecs[1].id : mecs[1].leafComponentType().id) == T_JavaLangObject) return mecs[0]; |
3040 |
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]; |
3041 |
if ((commonDim == 0 ? mecs[0].id : mecs[0].leafComponentType().id) == TypeIds.T_JavaLangObject) return mecs[1]; |
3043 |
} |
3042 |
} |
3044 |
TypeBinding[] otherBounds = new TypeBinding[count - 1]; |
3043 |
TypeBinding[] otherBounds = new TypeBinding[count - 1]; |
3045 |
int rank = 0; |
3044 |
int rank = 0; |
Lines 3118-3124
Link Here
|
3118 |
if (dim > 0) { |
3117 |
if (dim > 0) { |
3119 |
leafType = typeToVisit.leafComponentType(); |
3118 |
leafType = typeToVisit.leafComponentType(); |
3120 |
switch(leafType.id) { |
3119 |
switch(leafType.id) { |
3121 |
case T_JavaLangObject: |
3120 |
case TypeIds.T_JavaLangObject: |
3122 |
if (dim > 1) { // Object[][] supertype is Object[] |
3121 |
if (dim > 1) { // Object[][] supertype is Object[] |
3123 |
TypeBinding elementType = ((ArrayBinding)typeToVisit).elementsType(); |
3122 |
TypeBinding elementType = ((ArrayBinding)typeToVisit).elementsType(); |
3124 |
if (!typesToVisit.contains(elementType)) { |
3123 |
if (!typesToVisit.contains(elementType)) { |
Lines 3128-3141
Link Here
|
3128 |
continue; |
3127 |
continue; |
3129 |
} |
3128 |
} |
3130 |
//$FALL-THROUGH$ |
3129 |
//$FALL-THROUGH$ |
3131 |
case T_byte: |
3130 |
case TypeIds.T_byte: |
3132 |
case T_short: |
3131 |
case TypeIds.T_short: |
3133 |
case T_char: |
3132 |
case TypeIds.T_char: |
3134 |
case T_boolean: |
3133 |
case TypeIds.T_boolean: |
3135 |
case T_int: |
3134 |
case TypeIds.T_int: |
3136 |
case T_long: |
3135 |
case TypeIds.T_long: |
3137 |
case T_float: |
3136 |
case TypeIds.T_float: |
3138 |
case T_double: |
3137 |
case TypeIds.T_double: |
3139 |
TypeBinding superType = getJavaIoSerializable(); |
3138 |
TypeBinding superType = getJavaIoSerializable(); |
3140 |
if (!typesToVisit.contains(superType)) { |
3139 |
if (!typesToVisit.contains(superType)) { |
3141 |
typesToVisit.add(superType); |
3140 |
typesToVisit.add(superType); |
Lines 3254-3260
Link Here
|
3254 |
TypeBinding erasedSuperType = erasedSuperTypes[j]; |
3253 |
TypeBinding erasedSuperType = erasedSuperTypes[j]; |
3255 |
if (erasedSuperType == null) continue nextSuperType; |
3254 |
if (erasedSuperType == null) continue nextSuperType; |
3256 |
TypeBinding match; |
3255 |
TypeBinding match; |
3257 |
if (erasedSuperType == otherType || erasedSuperType.id == T_JavaLangObject && otherType.isInterface()) { |
3256 |
if (erasedSuperType == otherType || erasedSuperType.id == TypeIds.T_JavaLangObject && otherType.isInterface()) { |
3258 |
match = erasedSuperType; |
3257 |
match = erasedSuperType; |
3259 |
} else { |
3258 |
} else { |
3260 |
if (erasedSuperType.isArrayType()) { |
3259 |
if (erasedSuperType.isArrayType()) { |
Lines 3302-3315
Link Here
|
3302 |
TypeBinding otherType = erasedSuperTypes[j]; |
3301 |
TypeBinding otherType = erasedSuperTypes[j]; |
3303 |
if (otherType == null) continue nextOtherType; |
3302 |
if (otherType == null) continue nextOtherType; |
3304 |
if (erasedSuperType instanceof ReferenceBinding) { |
3303 |
if (erasedSuperType instanceof ReferenceBinding) { |
3305 |
if (otherType.id == T_JavaLangObject && erasedSuperType.isInterface()) continue nextOtherType; // keep Object for an interface |
3304 |
if (otherType.id == TypeIds.T_JavaLangObject && erasedSuperType.isInterface()) continue nextOtherType; // keep Object for an interface |
3306 |
if (erasedSuperType.findSuperTypeOriginatingFrom(otherType) != null) { |
3305 |
if (erasedSuperType.findSuperTypeOriginatingFrom(otherType) != null) { |
3307 |
erasedSuperTypes[j] = null; // discard non minimal supertype |
3306 |
erasedSuperTypes[j] = null; // discard non minimal supertype |
3308 |
remaining--; |
3307 |
remaining--; |
3309 |
} |
3308 |
} |
3310 |
} else if (erasedSuperType.isArrayType()) { |
3309 |
} else if (erasedSuperType.isArrayType()) { |
3311 |
if (otherType.isArrayType() // keep Object[...] for an interface array (same dimensions) |
3310 |
if (otherType.isArrayType() // keep Object[...] for an interface array (same dimensions) |
3312 |
&& otherType.leafComponentType().id == T_JavaLangObject |
3311 |
&& otherType.leafComponentType().id == TypeIds.T_JavaLangObject |
3313 |
&& otherType.dimensions() == erasedSuperType.dimensions() |
3312 |
&& otherType.dimensions() == erasedSuperType.dimensions() |
3314 |
&& erasedSuperType.leafComponentType().isInterface()) continue nextOtherType; |
3313 |
&& erasedSuperType.leafComponentType().isInterface()) continue nextOtherType; |
3315 |
if (erasedSuperType.findSuperTypeOriginatingFrom(otherType) != null) { |
3314 |
if (erasedSuperType.findSuperTypeOriginatingFrom(otherType) != null) { |