### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core 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.51 diff -u -r1.51 VariableBinding.java --- dom/org/eclipse/jdt/core/dom/VariableBinding.java 14 Aug 2006 21:44:29 -0000 1.51 +++ dom/org/eclipse/jdt/core/dom/VariableBinding.java 6 Feb 2007 21:04:16 -0000 @@ -55,7 +55,7 @@ } domInstances[i] = annotationInstance; } - return domInstances; + return domInstances; } /* (non-Javadoc) @@ -179,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() { 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.119 diff -u -r1.119 TypeBinding.java --- dom/org/eclipse/jdt/core/dom/TypeBinding.java 15 Aug 2006 15:59:12 -0000 1.119 +++ dom/org/eclipse/jdt/core/dom/TypeBinding.java 6 Feb 2007 21:04:16 -0000 @@ -69,7 +69,12 @@ org.eclipse.jdt.internal.compiler.lookup.TypeBinding binding; private String key; private BindingResolver resolver; - + private ITypeBinding[] interfaces; + private ITypeBinding[] typeParameters; + private ITypeBinding[] typeArguments; + private ITypeBinding[] typeBounds; + private ITypeBinding[] members; + public TypeBinding(BindingResolver resolver, org.eclipse.jdt.internal.compiler.lookup.TypeBinding binding) { this.binding = binding; this.resolver = resolver; @@ -248,16 +253,25 @@ * @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; - ITypeBinding[] newMembers = new ITypeBinding[length]; - for (int i = 0; i < length; i++) { - newMembers[i] = this.resolver.getTypeBinding(members[i]); + ReferenceBinding[] referenceBindingMembers = referenceBinding.memberTypes(); + int length = referenceBindingMembers == null ? 0 : referenceBindingMembers.length; + if (length != 0) { + ITypeBinding[] newMembers = new ITypeBinding[length]; + for (int i = 0; i < length; i++) { + ITypeBinding typeBinding = this.resolver.getTypeBinding(referenceBindingMembers[i]); + if (typeBinding == null) { + return this.members = NO_TYPE_BINDINGS; + } + newMembers[i] = typeBinding; + } + return this.members = newMembers; } - return newMembers; } } catch (RuntimeException e) { /* in case a method cannot be resolvable due to missing jars on the classpath @@ -266,7 +280,7 @@ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=64299 */ } - return NO_TYPE_BINDINGS; + return this.members = NO_TYPE_BINDINGS; } /* @@ -379,17 +393,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[] interfacesBinding = null; try { - interfaces = referenceBinding.superInterfaces(); + interfacesBinding = 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 @@ -397,18 +414,22 @@ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=64299 */ } - if (interfaces == null) { - return NO_TYPE_BINDINGS; + if (interfacesBinding == null) { + return this.interfaces = NO_TYPE_BINDINGS; } - int length = interfaces.length; + int length = interfacesBinding.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(interfacesBinding[i]); + if (typeBinding == null) { + return this.interfaces = NO_TYPE_BINDINGS; + } + newInterfaces[i] = typeBinding; } - return newInterfaces; + return this.interfaces = newInterfaces; } } @@ -484,7 +505,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); } @@ -590,15 +613,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('>'); } @@ -743,30 +766,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('>'); } @@ -827,32 +850,42 @@ if (superclass == null) { return null; } - return this.resolver.getTypeBinding(superclass); + return this.resolver.getTypeBinding(superclass); } /* (non-Javadoc) * @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]; + ITypeBinding[] newTypeArguments = new ITypeBinding[argumentsLength]; for (int i = 0; i < argumentsLength; i++) { - typeArguments[i] = this.resolver.getTypeBinding(arguments[i]); + ITypeBinding typeBinding = this.resolver.getTypeBinding(arguments[i]); + if (typeBinding == null) { + return this.typeArguments = NO_TYPE_BINDINGS; + } + newTypeArguments[i] = typeBinding; } - return typeArguments; + return this.typeArguments = newTypeArguments; } } - 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.typeBounds != null) { + return this.typeBounds; + } if (this.binding instanceof TypeVariableBinding) { TypeVariableBinding typeVariableBinding = (TypeVariableBinding) this.binding; ReferenceBinding varSuperclass = typeVariableBinding.superclass(); @@ -874,43 +907,58 @@ boundsLength += superinterfacesLength; } if (boundsLength != 0) { - ITypeBinding[] typeBounds = new ITypeBinding[boundsLength]; + ITypeBinding[] newTypeBounds = 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.typeBounds = NO_TYPE_BINDINGS; + } + newTypeBounds[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.typeBounds = NO_TYPE_BINDINGS; + } + newTypeBounds[boundsIndex] = typeBinding; } } - return typeBounds; + return this.typeBounds = newTypeBounds; } } - return NO_TYPE_BINDINGS; + return this.typeBounds = 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/MethodBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/dom/org/eclipse/jdt/core/dom/MethodBinding.java,v retrieving revision 1.79 diff -u -r1.79 MethodBinding.java --- dom/org/eclipse/jdt/core/dom/MethodBinding.java 24 Nov 2006 01:32:03 -0000 1.79 +++ dom/org/eclipse/jdt/core/dom/MethodBinding.java 6 Feb 2007 21:04:16 -0000 @@ -152,15 +152,19 @@ 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++) { final TypeBinding parameterBinding = parameters[i]; if (parameterBinding != null) { - this.parameterTypes[i] = this.resolver.getTypeBinding(parameterBinding); + ITypeBinding typeBinding = this.resolver.getTypeBinding(parameterBinding); + if (typeBinding == null) { + return this.parameterTypes = NO_TYPE_BINDINGS; + } + paramTypes[i] = typeBinding; } else { // log error StringBuffer message = new StringBuffer("Report method binding where a parameter is null:\n"); //$NON-NLS-1$ @@ -170,8 +174,8 @@ return this.parameterTypes = NO_TYPE_BINDINGS; } } + return this.parameterTypes = paramTypes; } - return this.parameterTypes; } /** @@ -200,14 +204,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[] newExceptionTypes = 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; + } + newExceptionTypes[i] = typeBinding; } + return this.exceptionTypes = newExceptionTypes; } - return this.exceptionTypes; } public IJavaElement getJavaElement() { @@ -359,17 +367,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; } /** @@ -399,20 +408,19 @@ if (typeArgumentsBindings != null) { int typeArgumentsLength = typeArgumentsBindings.length; if (typeArgumentsLength != 0) { - this.typeArguments = new ITypeBinding[typeArgumentsLength]; + ITypeBinding[] tArguments = 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; + } + tArguments[i] = typeBinding; } - } else { - this.typeArguments = NO_TYPE_BINDINGS; + return this.typeArguments = tArguments; } - } else { - this.typeArguments = NO_TYPE_BINDINGS; } - } else { - this.typeArguments = NO_TYPE_BINDINGS; } - return this.typeArguments; + return this.typeArguments = NO_TYPE_BINDINGS; } /**