### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java,v retrieving revision 1.104 diff -u -r1.104 LookupEnvironment.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java 17 Sep 2009 17:52:13 -0000 1.104 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/LookupEnvironment.java 8 Feb 2010 06:20:25 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -55,6 +55,7 @@ private SimpleLookupTable uniqueRawTypeBindings; private SimpleLookupTable uniqueWildcardBindings; private SimpleLookupTable uniqueParameterizedGenericMethodBindings; + private SimpleLookupTable uniqueGetClassMethodBinding; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=300734 public CompilationUnitDeclaration unitBeingCompleted = null; // only set while completing units public Object missingClassFileLocation = null; // only set when resolving certain references, to help locating problems @@ -811,6 +812,21 @@ return parameterizedGenericMethod; } +public ParameterizedMethodBinding createGetClassMethod(TypeBinding receiverType, MethodBinding originalMethod, Scope scope) { + // see if we have already cached this method for the given receiver type. + ParameterizedMethodBinding retVal = null; + if (this.uniqueGetClassMethodBinding == null) { + this.uniqueGetClassMethodBinding = new SimpleLookupTable(3); + } else { + retVal = (ParameterizedMethodBinding)this.uniqueGetClassMethodBinding.get(receiverType); + } + if (retVal == null) { + retVal = ParameterizedMethodBinding.instantiateGetClass(receiverType, originalMethod, scope); + this.uniqueGetClassMethodBinding.put(receiverType, retVal); + } + return retVal; +} + public ParameterizedTypeBinding createParameterizedType(ReferenceBinding genericType, TypeBinding[] typeArguments, ReferenceBinding enclosingType) { // cached info is array of already created parameterized types for this type ParameterizedTypeBinding[] cachedInfo = (ParameterizedTypeBinding[])this.uniqueParameterizedTypeBindings.get(genericType); @@ -1330,6 +1346,7 @@ this.uniqueRawTypeBindings = new SimpleLookupTable(3); this.uniqueWildcardBindings = new SimpleLookupTable(3); this.uniqueParameterizedGenericMethodBindings = new SimpleLookupTable(3); + this.uniqueGetClassMethodBinding = null; this.missingTypes = null; for (int i = this.units.length; --i >= 0;) Index: compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedMethodBinding.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedMethodBinding.java,v retrieving revision 1.29 diff -u -r1.29 ParameterizedMethodBinding.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedMethodBinding.java 5 Feb 2010 06:38:28 -0000 1.29 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedMethodBinding.java 8 Feb 2010 06:20:25 -0000 @@ -10,9 +10,6 @@ *******************************************************************************/ package org.eclipse.jdt.internal.compiler.lookup; -import java.lang.ref.WeakReference; -import java.util.Map; -import java.util.WeakHashMap; import org.eclipse.jdt.internal.compiler.ast.Wildcard; /** @@ -23,7 +20,6 @@ */ public class ParameterizedMethodBinding extends MethodBinding { - private static Map getClassMethodBindingCache; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=300734 protected MethodBinding originalMethod; /** @@ -253,17 +249,7 @@ * The type of x.getClass() is substituted from 'Class' into: 'Class */ public static ParameterizedMethodBinding instantiateGetClass(TypeBinding receiverType, MethodBinding originalMethod, Scope scope) { - ParameterizedMethodBinding method; - if (getClassMethodBindingCache != null) { - WeakReference w = (WeakReference) getClassMethodBindingCache.get(receiverType); - if (w != null) { - method = (ParameterizedMethodBinding) w.get(); - if (method != null) { - return method; - } - } - } - method = new ParameterizedMethodBinding(); + ParameterizedMethodBinding method = new ParameterizedMethodBinding(); method.modifiers = originalMethod.modifiers; method.selector = originalMethod.selector; method.declaringClass = originalMethod.declaringClass; @@ -282,10 +268,6 @@ if ((method.returnType.tagBits & TagBits.HasMissingType) != 0) { method.tagBits |= TagBits.HasMissingType; } - if (getClassMethodBindingCache == null) { - getClassMethodBindingCache = new WeakHashMap(); - } - getClassMethodBindingCache.put(receiverType, new WeakReference(method)); // method refers back to key return method; } Index: compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java,v retrieving revision 1.365 diff -u -r1.365 Scope.java --- compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 2 Dec 2009 18:34:39 -0000 1.365 +++ compiler/org/eclipse/jdt/internal/compiler/lookup/Scope.java 8 Feb 2010 06:20:27 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -906,7 +906,7 @@ if (argumentTypes == Binding.NO_PARAMETERS && CharOperation.equals(selector, TypeConstants.GETCLASS) && exactMethod.returnType.isParameterizedType()/*1.5*/) { - return ParameterizedMethodBinding.instantiateGetClass(receiverType, exactMethod, this); + return environment().createGetClassMethod(receiverType, exactMethod, this); } // targeting a generic method could find an exact match with variable return type if (invocationSite.genericTypeArguments() != null) { @@ -1457,7 +1457,7 @@ break; case 'g': if (CharOperation.equals(selector, TypeConstants.GETCLASS) && methodBinding.returnType.isParameterizedType()/*1.5*/) { - return ParameterizedMethodBinding.instantiateGetClass(receiverType, methodBinding, this); + return environment().createGetClassMethod(receiverType, methodBinding, this); } break; } @@ -1987,7 +1987,7 @@ if (argumentTypes == Binding.NO_PARAMETERS && CharOperation.equals(selector, TypeConstants.GETCLASS) && methodBinding.returnType.isParameterizedType()/*1.5*/) { - return ParameterizedMethodBinding.instantiateGetClass(receiverType, methodBinding, this); + return environment().createGetClassMethod(receiverType, methodBinding, this); } return methodBinding; } @@ -2247,7 +2247,7 @@ if (argumentTypes == Binding.NO_PARAMETERS && CharOperation.equals(selector, TypeConstants.GETCLASS) && methodBinding.returnType.isParameterizedType()/*1.5*/) { - return ParameterizedMethodBinding.instantiateGetClass(receiverType, methodBinding, this); + return environment().createGetClassMethod(receiverType, methodBinding, this); } return methodBinding; } catch (AbortCompilation e) {