Lines 243-333
Link Here
|
243 |
return availableMethods; |
243 |
return availableMethods; |
244 |
} |
244 |
} |
245 |
void cachePartsFrom(IBinaryType binaryType, boolean needFieldsAndMethods) { |
245 |
void cachePartsFrom(IBinaryType binaryType, boolean needFieldsAndMethods) { |
246 |
// default initialization for super-interfaces early, in case some aborting compilation error occurs, |
246 |
try { |
247 |
// and still want to use binaries passed that point (e.g. type hierarchy resolver, see bug 63748). |
247 |
// default initialization for super-interfaces early, in case some aborting compilation error occurs, |
248 |
this.typeVariables = Binding.NO_TYPE_VARIABLES; |
248 |
// and still want to use binaries passed that point (e.g. type hierarchy resolver, see bug 63748). |
249 |
this.superInterfaces = Binding.NO_SUPERINTERFACES; |
249 |
this.typeVariables = Binding.NO_TYPE_VARIABLES; |
250 |
|
|
|
251 |
// must retrieve member types in case superclass/interfaces need them |
252 |
this.memberTypes = Binding.NO_MEMBER_TYPES; |
253 |
IBinaryNestedType[] memberTypeStructures = binaryType.getMemberTypes(); |
254 |
if (memberTypeStructures != null) { |
255 |
int size = memberTypeStructures.length; |
256 |
if (size > 0) { |
257 |
this.memberTypes = new ReferenceBinding[size]; |
258 |
for (int i = 0; i < size; i++) |
259 |
// attempt to find each member type if it exists in the cache (otherwise - resolve it when requested) |
260 |
this.memberTypes[i] = environment.getTypeFromConstantPoolName(memberTypeStructures[i].getName(), 0, -1, false, null /* could not be missing */); |
261 |
this.tagBits |= TagBits.HasUnresolvedMemberTypes; |
262 |
} |
263 |
} |
264 |
|
265 |
|
266 |
long sourceLevel = environment.globalOptions.sourceLevel; |
267 |
char[] typeSignature = null; |
268 |
if (sourceLevel >= ClassFileConstants.JDK1_5) { |
269 |
typeSignature = binaryType.getGenericSignature(); |
270 |
this.tagBits |= binaryType.getTagBits(); |
271 |
} |
272 |
char[][][] missingTypeNames = binaryType.getMissingTypeNames(); |
273 |
if (typeSignature == null) { |
274 |
char[] superclassName = binaryType.getSuperclassName(); |
275 |
if (superclassName != null) { |
276 |
// attempt to find the superclass if it exists in the cache (otherwise - resolve it when requested) |
277 |
this.superclass = environment.getTypeFromConstantPoolName(superclassName, 0, -1, false, missingTypeNames); |
278 |
this.tagBits |= TagBits.HasUnresolvedSuperclass; |
279 |
} |
280 |
|
281 |
this.superInterfaces = Binding.NO_SUPERINTERFACES; |
250 |
this.superInterfaces = Binding.NO_SUPERINTERFACES; |
282 |
char[][] interfaceNames = binaryType.getInterfaceNames(); |
251 |
|
283 |
if (interfaceNames != null) { |
252 |
// must retrieve member types in case superclass/interfaces need them |
284 |
int size = interfaceNames.length; |
253 |
this.memberTypes = Binding.NO_MEMBER_TYPES; |
|
|
254 |
IBinaryNestedType[] memberTypeStructures = binaryType.getMemberTypes(); |
255 |
if (memberTypeStructures != null) { |
256 |
int size = memberTypeStructures.length; |
285 |
if (size > 0) { |
257 |
if (size > 0) { |
286 |
this.superInterfaces = new ReferenceBinding[size]; |
258 |
this.memberTypes = new ReferenceBinding[size]; |
287 |
for (int i = 0; i < size; i++) |
259 |
for (int i = 0; i < size; i++) |
288 |
// attempt to find each superinterface if it exists in the cache (otherwise - resolve it when requested) |
260 |
// attempt to find each member type if it exists in the cache (otherwise - resolve it when requested) |
289 |
this.superInterfaces[i] = environment.getTypeFromConstantPoolName(interfaceNames[i], 0, -1, false, missingTypeNames); |
261 |
this.memberTypes[i] = environment.getTypeFromConstantPoolName(memberTypeStructures[i].getName(), 0, -1, false, null /* could not be missing */); |
290 |
this.tagBits |= TagBits.HasUnresolvedSuperinterfaces; |
262 |
this.tagBits |= TagBits.HasUnresolvedMemberTypes; |
291 |
} |
263 |
} |
292 |
} |
264 |
} |
293 |
} else { |
|
|
294 |
// ClassSignature = ParameterPart(optional) super_TypeSignature interface_signature |
295 |
SignatureWrapper wrapper = new SignatureWrapper(typeSignature); |
296 |
if (wrapper.signature[wrapper.start] == '<') { |
297 |
// ParameterPart = '<' ParameterSignature(s) '>' |
298 |
wrapper.start++; // skip '<' |
299 |
this.typeVariables = createTypeVariables(wrapper, true, missingTypeNames); |
300 |
wrapper.start++; // skip '>' |
301 |
this.tagBits |= TagBits.HasUnresolvedTypeVariables; |
302 |
this.modifiers |= ExtraCompilerModifiers.AccGenericSignature; |
303 |
} |
304 |
|
265 |
|
305 |
// attempt to find the superclass if it exists in the cache (otherwise - resolve it when requested) |
266 |
long sourceLevel = environment.globalOptions.sourceLevel; |
306 |
this.superclass = (ReferenceBinding) environment.getTypeFromTypeSignature(wrapper, Binding.NO_TYPE_VARIABLES, this, missingTypeNames); |
267 |
char[] typeSignature = null; |
307 |
this.tagBits |= TagBits.HasUnresolvedSuperclass; |
268 |
if (sourceLevel >= ClassFileConstants.JDK1_5) { |
|
|
269 |
typeSignature = binaryType.getGenericSignature(); |
270 |
this.tagBits |= binaryType.getTagBits(); |
271 |
} |
272 |
char[][][] missingTypeNames = binaryType.getMissingTypeNames(); |
273 |
if (typeSignature == null) { |
274 |
char[] superclassName = binaryType.getSuperclassName(); |
275 |
if (superclassName != null) { |
276 |
// attempt to find the superclass if it exists in the cache (otherwise - resolve it when requested) |
277 |
this.superclass = environment.getTypeFromConstantPoolName(superclassName, 0, -1, false, missingTypeNames); |
278 |
this.tagBits |= TagBits.HasUnresolvedSuperclass; |
279 |
} |
280 |
|
281 |
this.superInterfaces = Binding.NO_SUPERINTERFACES; |
282 |
char[][] interfaceNames = binaryType.getInterfaceNames(); |
283 |
if (interfaceNames != null) { |
284 |
int size = interfaceNames.length; |
285 |
if (size > 0) { |
286 |
this.superInterfaces = new ReferenceBinding[size]; |
287 |
for (int i = 0; i < size; i++) |
288 |
// attempt to find each superinterface if it exists in the cache (otherwise - resolve it when requested) |
289 |
this.superInterfaces[i] = environment.getTypeFromConstantPoolName(interfaceNames[i], 0, -1, false, missingTypeNames); |
290 |
this.tagBits |= TagBits.HasUnresolvedSuperinterfaces; |
291 |
} |
292 |
} |
293 |
} else { |
294 |
// ClassSignature = ParameterPart(optional) super_TypeSignature interface_signature |
295 |
SignatureWrapper wrapper = new SignatureWrapper(typeSignature); |
296 |
if (wrapper.signature[wrapper.start] == '<') { |
297 |
// ParameterPart = '<' ParameterSignature(s) '>' |
298 |
wrapper.start++; // skip '<' |
299 |
this.typeVariables = createTypeVariables(wrapper, true, missingTypeNames); |
300 |
wrapper.start++; // skip '>' |
301 |
this.tagBits |= TagBits.HasUnresolvedTypeVariables; |
302 |
this.modifiers |= ExtraCompilerModifiers.AccGenericSignature; |
303 |
} |
304 |
TypeVariableBinding[] typeVars = Binding.NO_TYPE_VARIABLES; |
305 |
char[] methodDescriptor = binaryType.getEnclosingMethod(); |
306 |
if (methodDescriptor != null) { |
307 |
MethodBinding enclosingMethod = findMethod(methodDescriptor, missingTypeNames); |
308 |
typeVars = enclosingMethod.typeVariables; |
309 |
} |
308 |
|
310 |
|
309 |
this.superInterfaces = Binding.NO_SUPERINTERFACES; |
311 |
// attempt to find the superclass if it exists in the cache (otherwise - resolve it when requested) |
310 |
if (!wrapper.atEnd()) { |
312 |
this.superclass = (ReferenceBinding) environment.getTypeFromTypeSignature(wrapper, typeVars, this, missingTypeNames); |
311 |
// attempt to find each superinterface if it exists in the cache (otherwise - resolve it when requested) |
313 |
this.tagBits |= TagBits.HasUnresolvedSuperclass; |
312 |
java.util.ArrayList types = new java.util.ArrayList(2); |
314 |
|
313 |
do { |
315 |
this.superInterfaces = Binding.NO_SUPERINTERFACES; |
314 |
types.add(environment.getTypeFromTypeSignature(wrapper, Binding.NO_TYPE_VARIABLES, this, missingTypeNames)); |
316 |
if (!wrapper.atEnd()) { |
315 |
} while (!wrapper.atEnd()); |
317 |
// attempt to find each superinterface if it exists in the cache (otherwise - resolve it when requested) |
316 |
this.superInterfaces = new ReferenceBinding[types.size()]; |
318 |
java.util.ArrayList types = new java.util.ArrayList(2); |
317 |
types.toArray(this.superInterfaces); |
319 |
do { |
318 |
this.tagBits |= TagBits.HasUnresolvedSuperinterfaces; |
320 |
types.add(environment.getTypeFromTypeSignature(wrapper, typeVars, this, missingTypeNames)); |
|
|
321 |
} while (!wrapper.atEnd()); |
322 |
this.superInterfaces = new ReferenceBinding[types.size()]; |
323 |
types.toArray(this.superInterfaces); |
324 |
this.tagBits |= TagBits.HasUnresolvedSuperinterfaces; |
325 |
} |
319 |
} |
326 |
} |
320 |
} |
|
|
321 |
|
327 |
|
322 |
if (needFieldsAndMethods) { |
328 |
if (needFieldsAndMethods) { |
323 |
createFields(binaryType.getFields(), sourceLevel, missingTypeNames); |
329 |
createFields(binaryType.getFields(), sourceLevel, missingTypeNames); |
324 |
createMethods(binaryType.getMethods(), sourceLevel, missingTypeNames); |
330 |
createMethods(binaryType.getMethods(), sourceLevel, missingTypeNames); |
325 |
} else { // protect against incorrect use of the needFieldsAndMethods flag, see 48459 |
331 |
} |
326 |
this.fields = Binding.NO_FIELDS; |
332 |
if (this.environment.globalOptions.storeAnnotations) |
327 |
this.methods = Binding.NO_METHODS; |
333 |
setAnnotations(createAnnotations(binaryType.getAnnotations(), this.environment, missingTypeNames)); |
328 |
} |
334 |
} finally { |
329 |
if (this.environment.globalOptions.storeAnnotations) |
335 |
// protect against incorrect use of the needFieldsAndMethods flag, see 48459 |
330 |
setAnnotations(createAnnotations(binaryType.getAnnotations(), this.environment, missingTypeNames)); |
336 |
if (this.fields == null) |
|
|
337 |
this.fields = Binding.NO_FIELDS; |
338 |
if (this.methods == null) |
339 |
this.methods = Binding.NO_METHODS; |
340 |
} |
331 |
} |
341 |
} |
332 |
private void createFields(IBinaryField[] iFields, long sourceLevel, char[][][] missingTypeNames) { |
342 |
private void createFields(IBinaryField[] iFields, long sourceLevel, char[][][] missingTypeNames) { |
333 |
this.fields = Binding.NO_FIELDS; |
343 |
this.fields = Binding.NO_FIELDS; |
Lines 647-652
Link Here
|
647 |
this.tagBits |= TagBits.AreFieldsComplete; |
657 |
this.tagBits |= TagBits.AreFieldsComplete; |
648 |
return fields; |
658 |
return fields; |
649 |
} |
659 |
} |
|
|
660 |
private MethodBinding findMethod(char[] methodDescriptor, char[][][] missingTypeNames) { |
661 |
int index = -1; |
662 |
while (methodDescriptor[++index] != '(') { |
663 |
// empty |
664 |
} |
665 |
char[] selector = new char[index]; |
666 |
System.arraycopy(methodDescriptor, 0, selector, 0, index); |
667 |
TypeBinding[] parameters = Binding.NO_PARAMETERS; |
668 |
int numOfParams = 0; |
669 |
char nextChar; |
670 |
while ((nextChar = methodDescriptor[++index]) != ')') { |
671 |
if (nextChar != '[') { |
672 |
numOfParams++; |
673 |
if (nextChar == 'L') |
674 |
while ((nextChar = methodDescriptor[++index]) != ';'){/*empty*/} |
675 |
} |
676 |
} |
677 |
|
678 |
int startIndex = 0; |
679 |
if (numOfParams > 0) { |
680 |
parameters = new TypeBinding[numOfParams]; |
681 |
index = 1; |
682 |
int end = 0; // first character is always '(' so skip it |
683 |
for (int i = 0; i < numOfParams; i++) { |
684 |
while ((nextChar = methodDescriptor[++end]) == '['){/*empty*/} |
685 |
if (nextChar == 'L') |
686 |
while ((nextChar = methodDescriptor[++end]) != ';'){/*empty*/} |
687 |
|
688 |
if (i >= startIndex) { // skip the synthetic arg if necessary |
689 |
parameters[i - startIndex] = this.environment.getTypeFromSignature(methodDescriptor, index, end, false, this, missingTypeNames); |
690 |
} |
691 |
index = end + 1; |
692 |
} |
693 |
} |
694 |
|
695 |
return CharOperation.equals(selector, TypeConstants.INIT) |
696 |
? this.enclosingType.getExactConstructor(parameters) |
697 |
: this.enclosingType.getExactMethod(selector, parameters, null); |
698 |
} |
650 |
/** |
699 |
/** |
651 |
* @see org.eclipse.jdt.internal.compiler.lookup.TypeBinding#genericTypeSignature() |
700 |
* @see org.eclipse.jdt.internal.compiler.lookup.TypeBinding#genericTypeSignature() |
652 |
*/ |
701 |
*/ |