Lines 30-50
Link Here
|
30 |
null is NOT a valid value for a non-public field... it just means the field is not initialized. |
30 |
null is NOT a valid value for a non-public field... it just means the field is not initialized. |
31 |
*/ |
31 |
*/ |
32 |
|
32 |
|
33 |
public final class BinaryTypeBinding extends ReferenceBinding { |
33 |
public class BinaryTypeBinding extends ReferenceBinding { |
34 |
|
34 |
|
35 |
// all of these fields are ONLY guaranteed to be initialized if accessed using their public accessor method |
35 |
// all of these fields are ONLY guaranteed to be initialized if accessed using their public accessor method |
36 |
private ReferenceBinding superclass; |
36 |
protected ReferenceBinding superclass; |
37 |
private ReferenceBinding enclosingType; |
37 |
protected ReferenceBinding enclosingType; |
38 |
private ReferenceBinding[] superInterfaces; |
38 |
protected ReferenceBinding[] superInterfaces; |
39 |
private FieldBinding[] fields; |
39 |
protected FieldBinding[] fields; |
40 |
private MethodBinding[] methods; |
40 |
protected MethodBinding[] methods; |
41 |
private ReferenceBinding[] memberTypes; |
41 |
protected ReferenceBinding[] memberTypes; |
42 |
protected TypeVariableBinding[] typeVariables; |
42 |
protected TypeVariableBinding[] typeVariables; |
43 |
|
43 |
|
44 |
// For the link with the principle structure |
44 |
// For the link with the principle structure |
45 |
private LookupEnvironment environment; |
45 |
protected LookupEnvironment environment; |
46 |
|
46 |
|
47 |
private SimpleLookupTable storedAnnotations = null; // keys are this ReferenceBinding & its fields and methods, value is an AnnotationHolder |
47 |
protected SimpleLookupTable storedAnnotations = null; // keys are this ReferenceBinding & its fields and methods, value is an AnnotationHolder |
48 |
|
48 |
|
49 |
static Object convertMemberValue(Object binaryValue, LookupEnvironment env) { |
49 |
static Object convertMemberValue(Object binaryValue, LookupEnvironment env) { |
50 |
if (binaryValue == null) return null; |
50 |
if (binaryValue == null) return null; |
Lines 133-138
Link Here
|
133 |
return type; |
133 |
return type; |
134 |
} |
134 |
} |
135 |
|
135 |
|
|
|
136 |
/** |
137 |
* Default empty constructor for subclasses only. |
138 |
*/ |
139 |
protected BinaryTypeBinding() { |
140 |
// only for subclasses |
141 |
} |
142 |
|
143 |
/** |
144 |
* Standard constructor for creating binary type bindings from binary models (classfiles) |
145 |
* @param packageBinding |
146 |
* @param binaryType |
147 |
* @param environment |
148 |
*/ |
136 |
public BinaryTypeBinding(PackageBinding packageBinding, IBinaryType binaryType, LookupEnvironment environment) { |
149 |
public BinaryTypeBinding(PackageBinding packageBinding, IBinaryType binaryType, LookupEnvironment environment) { |
137 |
this.compoundName = CharOperation.splitOn('/', binaryType.getName()); |
150 |
this.compoundName = CharOperation.splitOn('/', binaryType.getName()); |
138 |
computeId(); |
151 |
computeId(); |
Lines 252-258
Link Here
|
252 |
if (superclassName != null) { |
265 |
if (superclassName != null) { |
253 |
// attempt to find the superclass if it exists in the cache (otherwise - resolve it when requested) |
266 |
// attempt to find the superclass if it exists in the cache (otherwise - resolve it when requested) |
254 |
this.superclass = environment.getTypeFromConstantPoolName(superclassName, 0, -1, false); |
267 |
this.superclass = environment.getTypeFromConstantPoolName(superclassName, 0, -1, false); |
255 |
this.tagBits |= TagBits.HasUnresolvedSuperclass; |
268 |
this.tagBits |= TagBits.HasUnresolvedSuperclass; |
256 |
} |
269 |
} |
257 |
|
270 |
|
258 |
this.superInterfaces = Binding.NO_SUPERINTERFACES; |
271 |
this.superInterfaces = Binding.NO_SUPERINTERFACES; |
Lines 264-270
Link Here
|
264 |
for (int i = 0; i < size; i++) |
277 |
for (int i = 0; i < size; i++) |
265 |
// attempt to find each superinterface if it exists in the cache (otherwise - resolve it when requested) |
278 |
// attempt to find each superinterface if it exists in the cache (otherwise - resolve it when requested) |
266 |
this.superInterfaces[i] = environment.getTypeFromConstantPoolName(interfaceNames[i], 0, -1, false); |
279 |
this.superInterfaces[i] = environment.getTypeFromConstantPoolName(interfaceNames[i], 0, -1, false); |
267 |
this.tagBits |= TagBits.HasUnresolvedSuperinterfaces; |
280 |
this.tagBits |= TagBits.HasUnresolvedSuperinterfaces; |
268 |
} |
281 |
} |
269 |
} |
282 |
} |
270 |
} else { |
283 |
} else { |
Lines 281-287
Link Here
|
281 |
|
294 |
|
282 |
// attempt to find the superclass if it exists in the cache (otherwise - resolve it when requested) |
295 |
// attempt to find the superclass if it exists in the cache (otherwise - resolve it when requested) |
283 |
this.superclass = (ReferenceBinding) environment.getTypeFromTypeSignature(wrapper, Binding.NO_TYPE_VARIABLES, this); |
296 |
this.superclass = (ReferenceBinding) environment.getTypeFromTypeSignature(wrapper, Binding.NO_TYPE_VARIABLES, this); |
284 |
this.tagBits |= TagBits.HasUnresolvedSuperclass; |
297 |
this.tagBits |= TagBits.HasUnresolvedSuperclass; |
285 |
|
298 |
|
286 |
this.superInterfaces = Binding.NO_SUPERINTERFACES; |
299 |
this.superInterfaces = Binding.NO_SUPERINTERFACES; |
287 |
if (!wrapper.atEnd()) { |
300 |
if (!wrapper.atEnd()) { |
Lines 292-298
Link Here
|
292 |
} while (!wrapper.atEnd()); |
305 |
} while (!wrapper.atEnd()); |
293 |
this.superInterfaces = new ReferenceBinding[types.size()]; |
306 |
this.superInterfaces = new ReferenceBinding[types.size()]; |
294 |
types.toArray(this.superInterfaces); |
307 |
types.toArray(this.superInterfaces); |
295 |
this.tagBits |= TagBits.HasUnresolvedSuperinterfaces; |
308 |
this.tagBits |= TagBits.HasUnresolvedSuperinterfaces; |
296 |
} |
309 |
} |
297 |
} |
310 |
} |
298 |
|
311 |
|
Lines 893-900
Link Here
|
893 |
} |
906 |
} |
894 |
return this.storedAnnotations; |
907 |
return this.storedAnnotations; |
895 |
} |
908 |
} |
|
|
909 |
|
896 |
/* Answer the receiver's superclass... null if the receiver is Object or an interface. |
910 |
/* Answer the receiver's superclass... null if the receiver is Object or an interface. |
897 |
* |
|
|
898 |
* NOTE: superclass of a binary type is resolved when needed |
911 |
* NOTE: superclass of a binary type is resolved when needed |
899 |
*/ |
912 |
*/ |
900 |
public ReferenceBinding superclass() { |
913 |
public ReferenceBinding superclass() { |
Lines 902-918
Link Here
|
902 |
return this.superclass; |
915 |
return this.superclass; |
903 |
|
916 |
|
904 |
// finish resolving the type |
917 |
// finish resolving the type |
905 |
this.superclass = resolveType(this.superclass, this.environment, true); |
918 |
ReferenceBinding superType = resolveType(this.superclass, this.environment, true); |
906 |
this.tagBits &= ~TagBits.HasUnresolvedSuperclass; |
919 |
this.tagBits &= ~TagBits.HasUnresolvedSuperclass; |
907 |
return this.superclass; |
920 |
if (superType.problemId() == ProblemReasons.NotFound) { |
|
|
921 |
this.tagBits |= TagBits.HierarchyHasProblems; // propagate type inconsistency |
922 |
} |
923 |
return this.superclass = superType; |
908 |
} |
924 |
} |
909 |
// NOTE: superInterfaces of binary types are resolved when needed |
925 |
// NOTE: superInterfaces of binary types are resolved when needed |
910 |
public ReferenceBinding[] superInterfaces() { |
926 |
public ReferenceBinding[] superInterfaces() { |
911 |
if ((this.tagBits & TagBits.HasUnresolvedSuperinterfaces) == 0) |
927 |
if ((this.tagBits & TagBits.HasUnresolvedSuperinterfaces) == 0) |
912 |
return this.superInterfaces; |
928 |
return this.superInterfaces; |
913 |
|
929 |
for (int i = this.superInterfaces.length; --i >= 0;) { |
914 |
for (int i = this.superInterfaces.length; --i >= 0;) |
930 |
ReferenceBinding superType = resolveType(this.superInterfaces[i], this.environment, true); |
915 |
this.superInterfaces[i] = resolveType(this.superInterfaces[i], this.environment, true); |
931 |
if (superType.problemId() == ProblemReasons.NotFound) { |
|
|
932 |
this.tagBits |= TagBits.HierarchyHasProblems; // propagate type inconsistency |
933 |
} |
934 |
this.superInterfaces[i] = superType; |
935 |
} |
916 |
this.tagBits &= ~TagBits.HasUnresolvedSuperinterfaces; |
936 |
this.tagBits &= ~TagBits.HasUnresolvedSuperinterfaces; |
917 |
return this.superInterfaces; |
937 |
return this.superInterfaces; |
918 |
} |
938 |
} |