### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: dom/org/eclipse/jdt/core/dom/MethodBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodBinding.java,v retrieving revision 1.75.4.1 diff -u -r1.75.4.1 MethodBinding.java --- dom/org/eclipse/jdt/core/dom/MethodBinding.java 2 Jul 2006 10:11:41 -0000 1.75.4.1 +++ dom/org/eclipse/jdt/core/dom/MethodBinding.java 6 Feb 2007 21:04:07 -0000 @@ -108,8 +108,13 @@ if (annotations == null || (length = annotations.length) == 0) return AnnotationBinding.NoAnnotations; IAnnotationBinding[] domInstances = new AnnotationBinding[length]; - for (int i = 0; i < length; i++) - domInstances[i] = this.resolver.getAnnotationInstance(annotations[i]); + for (int i = 0; i < length; i++) { + IAnnotationBinding annotationInstance = this.resolver.getAnnotationInstance(annotations[i]); + if (annotationInstance == null) { + return AnnotationBinding.NoAnnotations; + } + domInstances[i] = annotationInstance; + } return domInstances; } @@ -128,9 +133,14 @@ int length; if (annotations == null || (length = annotations.length) == 0) return AnnotationBinding.NoAnnotations; - IAnnotationBinding[] domInstances =new AnnotationBinding[length]; - for (int i = 0; i < length; i++) - domInstances[i] = this.resolver.getAnnotationInstance(annotations[i]); + IAnnotationBinding[] domInstances = new AnnotationBinding[length]; + for (int i = 0; i < length; i++) { + IAnnotationBinding annotationInstance = this.resolver.getAnnotationInstance(annotations[i]); + if (annotationInstance == null) { + return AnnotationBinding.NoAnnotations; + } + domInstances[i] = annotationInstance; + } return domInstances; } @@ -142,16 +152,20 @@ return parameterTypes; } org.eclipse.jdt.internal.compiler.lookup.TypeBinding[] parameters = this.binding.parameters; - int length = parameters.length; + int length = parameters == null ? 0 : parameters.length; if (length == 0) { - this.parameterTypes = NO_TYPE_BINDINGS; + return this.parameterTypes = NO_TYPE_BINDINGS; } else { - this.parameterTypes = new ITypeBinding[length]; + ITypeBinding[] paramTypes = new ITypeBinding[length]; for (int i = 0; i < length; i++) { - this.parameterTypes[i] = this.resolver.getTypeBinding(parameters[i]); + ITypeBinding typeBinding = this.resolver.getTypeBinding(parameters[i]); + if (typeBinding == null) { + return this.parameterTypes = NO_TYPE_BINDINGS; + } + paramTypes[i] = typeBinding; } + return this.parameterTypes = paramTypes; } - return this.parameterTypes; } /** @@ -180,14 +194,18 @@ org.eclipse.jdt.internal.compiler.lookup.TypeBinding[] exceptions = this.binding.thrownExceptions; int length = exceptions.length; if (length == 0) { - this.exceptionTypes = NO_TYPE_BINDINGS; + return this.exceptionTypes = NO_TYPE_BINDINGS; } else { - this.exceptionTypes = new ITypeBinding[length]; + ITypeBinding[] exTypes = new ITypeBinding[length]; for (int i = 0; i < length; i++) { - this.exceptionTypes[i] = this.resolver.getTypeBinding(exceptions[i]); + ITypeBinding typeBinding = this.resolver.getTypeBinding(exceptions[i]); + if (typeBinding == null) { + return this.exceptionTypes = NO_TYPE_BINDINGS; + } + exTypes[i] = typeBinding; } + return this.exceptionTypes = exTypes; } - return this.exceptionTypes; } public IJavaElement getJavaElement() { @@ -339,17 +357,18 @@ if (typeVariableBindings != null) { int typeVariableBindingsLength = typeVariableBindings.length; if (typeVariableBindingsLength != 0) { - this.typeParameters = new ITypeBinding[typeVariableBindingsLength]; + ITypeBinding[] tParameters = new ITypeBinding[typeVariableBindingsLength]; for (int i = 0; i < typeVariableBindingsLength; i++) { - typeParameters[i] = this.resolver.getTypeBinding(typeVariableBindings[i]); + ITypeBinding typeBinding = this.resolver.getTypeBinding(typeVariableBindings[i]); + if (typeBinding == null) { + return this.typeParameters = NO_TYPE_BINDINGS; + } + tParameters[i] = typeBinding; } - } else { - this.typeParameters = NO_TYPE_BINDINGS; + return this.typeParameters = tParameters; } - } else { - this.typeParameters = NO_TYPE_BINDINGS; } - return this.typeParameters; + return this.typeParameters = NO_TYPE_BINDINGS; } /** @@ -379,20 +398,19 @@ if (typeArgumentsBindings != null) { int typeArgumentsLength = typeArgumentsBindings.length; if (typeArgumentsLength != 0) { - this.typeArguments = new ITypeBinding[typeArgumentsLength]; + ITypeBinding[] newTypeArguments = new ITypeBinding[typeArgumentsLength]; for (int i = 0; i < typeArgumentsLength; i++) { - this.typeArguments[i] = this.resolver.getTypeBinding(typeArgumentsBindings[i]); + ITypeBinding typeBinding = this.resolver.getTypeBinding(typeArgumentsBindings[i]); + if (typeBinding == null) { + return this.typeArguments = NO_TYPE_BINDINGS; + } + newTypeArguments[i] = typeBinding; } - } else { - this.typeArguments = NO_TYPE_BINDINGS; + return this.typeArguments = newTypeArguments; } - } else { - this.typeArguments = NO_TYPE_BINDINGS; } - } else { - this.typeArguments = NO_TYPE_BINDINGS; } - return this.typeArguments; + return this.typeArguments = NO_TYPE_BINDINGS; } /** Index: dom/org/eclipse/jdt/core/dom/TypeBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/TypeBinding.java,v retrieving revision 1.115.4.1 diff -u -r1.115.4.1 TypeBinding.java --- dom/org/eclipse/jdt/core/dom/TypeBinding.java 2 Jul 2006 10:11:41 -0000 1.115.4.1 +++ dom/org/eclipse/jdt/core/dom/TypeBinding.java 6 Feb 2007 21:04:07 -0000 @@ -69,6 +69,11 @@ private org.eclipse.jdt.internal.compiler.lookup.TypeBinding binding; private String key; private BindingResolver resolver; + private ITypeBinding[] members; + private ITypeBinding[] interfaces; + private ITypeBinding[] typeArguments; + private ITypeBinding[] typeParameters; + private ITypeBinding[] bounds; public TypeBinding(BindingResolver resolver, org.eclipse.jdt.internal.compiler.lookup.TypeBinding binding) { this.binding = binding; @@ -84,8 +89,13 @@ int length = internalAnnotations == null ? 0 : internalAnnotations.length; if (length > 0) { domInstances = new AnnotationBinding[length]; - for (int i = 0; i < length; i++) - domInstances[i] = this.resolver.getAnnotationInstance(internalAnnotations[i]); + for (int i = 0; i < length; i++) { + IAnnotationBinding annotationInstance = this.resolver.getAnnotationInstance(internalAnnotations[i]); + if (annotationInstance == null) { + return AnnotationBinding.NoAnnotations; + } + domInstances[i] = annotationInstance; + } } } return domInstances; @@ -234,16 +244,23 @@ * @see ITypeBinding#getDeclaredTypes() */ public ITypeBinding[] getDeclaredTypes() { + if (this.members != null) { + return this.members; + } try { if (isClass() || isInterface() || isEnum()) { ReferenceBinding referenceBinding = (ReferenceBinding) this.binding; - ReferenceBinding[] members = referenceBinding.memberTypes(); - int length = members.length; + ReferenceBinding[] referenceBindingMembers = referenceBinding.memberTypes(); + int length = referenceBindingMembers.length; ITypeBinding[] newMembers = new ITypeBinding[length]; for (int i = 0; i < length; i++) { - newMembers[i] = this.resolver.getTypeBinding(members[i]); + ITypeBinding typeBinding = this.resolver.getTypeBinding(referenceBindingMembers[i]); + if (typeBinding == null) { + return this.members = NO_TYPE_BINDINGS; + } + newMembers[i] = typeBinding; } - return newMembers; + return this.members = newMembers; } } catch (RuntimeException e) { /* in case a method cannot be resolvable due to missing jars on the classpath @@ -252,7 +269,7 @@ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=64299 */ } - return NO_TYPE_BINDINGS; + return this.members = NO_TYPE_BINDINGS; } /* @@ -365,17 +382,20 @@ } public ITypeBinding[] getInterfaces() { + if (this.interfaces != null) { + return this.interfaces; + } if (this.binding == null) - return NO_TYPE_BINDINGS; + return this.interfaces = NO_TYPE_BINDINGS; switch (this.binding.kind()) { case Binding.ARRAY_TYPE : case Binding.BASE_TYPE : - return NO_TYPE_BINDINGS; + return this.interfaces = NO_TYPE_BINDINGS; } ReferenceBinding referenceBinding = (ReferenceBinding) this.binding; - ReferenceBinding[] interfaces = null; + ReferenceBinding[] referenceBindingInterfaces = null; try { - interfaces = referenceBinding.superInterfaces(); + referenceBindingInterfaces = referenceBinding.superInterfaces(); } catch (RuntimeException e) { /* in case a method cannot be resolvable due to missing jars on the classpath * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=57871 @@ -383,18 +403,22 @@ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=64299 */ } - if (interfaces == null) { - return NO_TYPE_BINDINGS; + if (referenceBindingInterfaces == null) { + return this.interfaces = NO_TYPE_BINDINGS; } - int length = interfaces.length; + int length = referenceBindingInterfaces.length; if (length == 0) { - return NO_TYPE_BINDINGS; + return this.interfaces = NO_TYPE_BINDINGS; } else { ITypeBinding[] newInterfaces = new ITypeBinding[length]; for (int i = 0; i < length; i++) { - newInterfaces[i] = this.resolver.getTypeBinding(interfaces[i]); + ITypeBinding typeBinding = this.resolver.getTypeBinding(referenceBindingInterfaces[i]); + if (typeBinding == null) { + return this.interfaces = NO_TYPE_BINDINGS; + } + newInterfaces[i] = typeBinding; } - return newInterfaces; + return this.interfaces = newInterfaces; } } @@ -470,7 +494,9 @@ IMethod declaringMethod = (IMethod) declaringTypeBinding.getJavaElement(); return (JavaElement) declaringMethod.getTypeParameter(typeVariableName); } else { - declaringTypeBinding = this.resolver.getTypeBinding((org.eclipse.jdt.internal.compiler.lookup.TypeBinding) declaringElement); + ITypeBinding typeBinding2 = this.resolver.getTypeBinding((org.eclipse.jdt.internal.compiler.lookup.TypeBinding) declaringElement); + if (typeBinding2 == null) return null; + declaringTypeBinding = typeBinding2; IType declaringType = (IType) declaringTypeBinding.getJavaElement(); return (JavaElement) declaringType.getTypeParameter(typeVariableName); } @@ -576,15 +602,15 @@ ParameterizedTypeBinding parameterizedTypeBinding = (ParameterizedTypeBinding) this.binding; buffer = new StringBuffer(); buffer.append(parameterizedTypeBinding.sourceName()); - ITypeBinding[] typeArguments = getTypeArguments(); - final int typeArgumentsLength = typeArguments.length; + ITypeBinding[] tArguments = getTypeArguments(); + final int typeArgumentsLength = tArguments.length; if (typeArgumentsLength != 0) { buffer.append('<'); - for (int i = 0, max = typeArguments.length; i < max; i++) { + for (int i = 0, max = tArguments.length; i < max; i++) { if (i > 0) { buffer.append(','); } - buffer.append(typeArguments[i].getName()); + buffer.append(tArguments[i].getName()); } buffer.append('>'); } @@ -729,30 +755,30 @@ .append('.'); ParameterizedTypeBinding parameterizedTypeBinding = (ParameterizedTypeBinding) this.binding; buffer.append(parameterizedTypeBinding.sourceName()); - ITypeBinding[] typeArguments = getTypeArguments(); - final int typeArgumentsLength = typeArguments.length; + ITypeBinding[] tArguments = getTypeArguments(); + final int typeArgumentsLength = tArguments.length; if (typeArgumentsLength != 0) { buffer.append('<'); - for (int i = 0, max = typeArguments.length; i < max; i++) { + for (int i = 0, max = tArguments.length; i < max; i++) { if (i > 0) { buffer.append(','); } - buffer.append(typeArguments[i].getQualifiedName()); + buffer.append(tArguments[i].getQualifiedName()); } buffer.append('>'); } return String.valueOf(buffer); } buffer.append(getTypeDeclaration().getQualifiedName()); - ITypeBinding[] typeArguments = getTypeArguments(); - final int typeArgumentsLength = typeArguments.length; + ITypeBinding[] tArguments = getTypeArguments(); + final int typeArgumentsLength = tArguments.length; if (typeArgumentsLength != 0) { buffer.append('<'); - for (int i = 0, max = typeArguments.length; i < max; i++) { + for (int i = 0, max = tArguments.length; i < max; i++) { if (i > 0) { buffer.append(','); } - buffer.append(typeArguments[i].getQualifiedName()); + buffer.append(tArguments[i].getQualifiedName()); } buffer.append('>'); } @@ -820,25 +846,37 @@ * @see org.eclipse.jdt.core.dom.ITypeBinding#getTypeArguments() */ public ITypeBinding[] getTypeArguments() { + if (this.typeArguments != null) { + return this.typeArguments; + } if (this.binding.isParameterizedType()) { ParameterizedTypeBinding parameterizedTypeBinding = (ParameterizedTypeBinding) this.binding; final org.eclipse.jdt.internal.compiler.lookup.TypeBinding[] arguments = parameterizedTypeBinding.arguments; if (arguments != null) { int argumentsLength = arguments.length; - ITypeBinding[] typeArguments = new ITypeBinding[argumentsLength]; - for (int i = 0; i < argumentsLength; i++) { - typeArguments[i] = this.resolver.getTypeBinding(arguments[i]); + if (argumentsLength != 0) { + ITypeBinding[] tArguments = new ITypeBinding[argumentsLength]; + for (int i = 0; i < argumentsLength; i++) { + ITypeBinding typeBinding = this.resolver.getTypeBinding(arguments[i]); + if (typeBinding == null) { + return this.typeArguments = NO_TYPE_BINDINGS; + } + tArguments[i] = typeBinding; + } + return this.typeArguments = tArguments; } - return typeArguments; } } - return NO_TYPE_BINDINGS; + return this.typeArguments = NO_TYPE_BINDINGS; } /* (non-Javadoc) * @see org.eclipse.jdt.core.dom.ITypeBinding#getTypeBounds() */ public ITypeBinding[] getTypeBounds() { + if (this.bounds != null) { + return this.bounds; + } if (this.binding instanceof TypeVariableBinding) { TypeVariableBinding typeVariableBinding = (TypeVariableBinding) this.binding; ReferenceBinding varSuperclass = typeVariableBinding.superclass(); @@ -863,40 +901,55 @@ ITypeBinding[] typeBounds = new ITypeBinding[boundsLength]; int boundsIndex = 0; if (firstClassOrArrayBound != null) { - typeBounds[boundsIndex++] = this.resolver.getTypeBinding(firstClassOrArrayBound); + ITypeBinding typeBinding = this.resolver.getTypeBinding(firstClassOrArrayBound); + if (typeBinding == null) { + return this.bounds = NO_TYPE_BINDINGS; + } + typeBounds[boundsIndex++] = typeBinding; } if (superinterfaces != null) { for (int i = 0; i < superinterfacesLength; i++, boundsIndex++) { - typeBounds[boundsIndex] = this.resolver.getTypeBinding(superinterfaces[i]); + ITypeBinding typeBinding = this.resolver.getTypeBinding(superinterfaces[i]); + if (typeBinding == null) { + return this.bounds = NO_TYPE_BINDINGS; + } + typeBounds[boundsIndex] = typeBinding; } } - return typeBounds; + return this.bounds = typeBounds; } } - return NO_TYPE_BINDINGS; + return this.bounds = NO_TYPE_BINDINGS; } /* (non-Javadoc) * @see org.eclipse.jdt.core.dom.ITypeBinding#getTypeParameters() */ public ITypeBinding[] getTypeParameters() { + if (this.typeParameters != null) { + return this.typeParameters; + } switch(this.binding.kind()) { case Binding.RAW_TYPE : case Binding.PARAMETERIZED_TYPE : - return NO_TYPE_BINDINGS; + return this.typeParameters = NO_TYPE_BINDINGS; } TypeVariableBinding[] typeVariableBindings = this.binding.typeVariables(); if (typeVariableBindings != null) { int typeVariableBindingsLength = typeVariableBindings.length; if (typeVariableBindingsLength != 0) { - ITypeBinding[] typeParameters = new ITypeBinding[typeVariableBindingsLength]; + ITypeBinding[] tParameters = new ITypeBinding[typeVariableBindingsLength]; for (int i = 0; i < typeVariableBindingsLength; i++) { - typeParameters[i] = this.resolver.getTypeBinding(typeVariableBindings[i]); + ITypeBinding typeBinding = this.resolver.getTypeBinding(typeVariableBindings[i]); + if (typeBinding == null) { + return this.typeParameters = NO_TYPE_BINDINGS; + } + tParameters[i] = typeBinding; } - return typeParameters; + return this.typeParameters = tParameters; } } - return NO_TYPE_BINDINGS; + return this.typeParameters = NO_TYPE_BINDINGS; } /* (non-Javadoc) Index: dom/org/eclipse/jdt/core/dom/VariableBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/VariableBinding.java,v retrieving revision 1.50 diff -u -r1.50 VariableBinding.java --- dom/org/eclipse/jdt/core/dom/VariableBinding.java 9 Feb 2006 18:38:30 -0000 1.50 +++ dom/org/eclipse/jdt/core/dom/VariableBinding.java 6 Feb 2007 21:04:07 -0000 @@ -48,9 +48,14 @@ int length = internalAnnotations == null ? 0 : internalAnnotations.length; IAnnotationBinding[] domInstances = length == 0 ? AnnotationBinding.NoAnnotations : new AnnotationBinding[length]; - for (int i = 0; i < length; i++) - domInstances[i] = this.resolver.getAnnotationInstance(internalAnnotations[i]); - return domInstances; + for (int i = 0; i < length; i++) { + IAnnotationBinding annotationInstance = this.resolver.getAnnotationInstance(internalAnnotations[i]); + if (annotationInstance == null) { + return AnnotationBinding.NoAnnotations; + } + domInstances[i] = annotationInstance; + } + return domInstances; } /* (non-Javadoc) @@ -174,10 +179,10 @@ * @see IVariableBinding#getType() */ public ITypeBinding getType() { - if (type == null) { - type = this.resolver.getTypeBinding(this.binding.type); + if (this.type == null) { + this.type = this.resolver.getTypeBinding(this.binding.type); } - return type; + return this.type; } private JavaElement getUnresolvedJavaElement() {