View | Details | Raw Unified | Return to bug 300734 | Differences between
and this patch

Collapse All | Expand All

(-)compiler/org/eclipse/jdt/internal/compiler/lookup/ParameterizedMethodBinding.java (-2 / +20 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.compiler.lookup;
11
package org.eclipse.jdt.internal.compiler.lookup;
12
12
13
import java.lang.ref.WeakReference;
14
import java.util.Map;
15
import java.util.WeakHashMap;
13
import org.eclipse.jdt.internal.compiler.ast.Wildcard;
16
import org.eclipse.jdt.internal.compiler.ast.Wildcard;
14
17
15
/**
18
/**
Lines 20-25 Link Here
20
 */
23
 */
21
public class ParameterizedMethodBinding extends MethodBinding {
24
public class ParameterizedMethodBinding extends MethodBinding {
22
25
26
	private static Map getClassMethodBindingCache; // https://bugs.eclipse.org/bugs/show_bug.cgi?id=300734
23
	protected MethodBinding originalMethod;
27
	protected MethodBinding originalMethod;
24
28
25
	/**
29
	/**
Lines 249-255 Link Here
249
	 * The type of x.getClass() is substituted from 'Class<? extends Object>' into: 'Class<? extends raw(X)>
253
	 * The type of x.getClass() is substituted from 'Class<? extends Object>' into: 'Class<? extends raw(X)>
250
	 */
254
	 */
251
	public static ParameterizedMethodBinding instantiateGetClass(TypeBinding receiverType, MethodBinding originalMethod, Scope scope) {
255
	public static ParameterizedMethodBinding instantiateGetClass(TypeBinding receiverType, MethodBinding originalMethod, Scope scope) {
252
		ParameterizedMethodBinding method = new ParameterizedMethodBinding();
256
		ParameterizedMethodBinding method;
257
		if (getClassMethodBindingCache != null) {
258
			WeakReference w = (WeakReference) getClassMethodBindingCache.get(receiverType);
259
			if (w != null) {
260
				method = (ParameterizedMethodBinding) w.get();
261
				if (method != null) {
262
					return method;
263
				}
264
			}
265
		}
266
		method = new ParameterizedMethodBinding();
253
		method.modifiers = originalMethod.modifiers;
267
		method.modifiers = originalMethod.modifiers;
254
		method.selector = originalMethod.selector;
268
		method.selector = originalMethod.selector;
255
		method.declaringClass = originalMethod.declaringClass;
269
		method.declaringClass = originalMethod.declaringClass;
Lines 268-273 Link Here
268
		if ((method.returnType.tagBits & TagBits.HasMissingType) != 0) {
282
		if ((method.returnType.tagBits & TagBits.HasMissingType) != 0) {
269
			method.tagBits |=  TagBits.HasMissingType;
283
			method.tagBits |=  TagBits.HasMissingType;
270
		}
284
		}
285
		if (getClassMethodBindingCache == null) {
286
			getClassMethodBindingCache = new WeakHashMap();
287
		}
288
		getClassMethodBindingCache.put(receiverType, new WeakReference(method));  // method refers back to key
271
		return method;
289
		return method;
272
	}
290
	}
273
291
(-)src/org/eclipse/jdt/core/tests/dom/ASTConverter15Test.java (-2 / +23 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 IBM Corporation and others.
2
 * Copyright (c) 2000, 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 47-53 Link Here
47
	}
47
	}
48
48
49
	static {
49
	static {
50
//		TESTS_NUMBERS = new int[] { 340 };
50
//		TESTS_NUMBERS = new int[] { 341 };
51
//		TESTS_RANGE = new int[] { 325, -1 };
51
//		TESTS_RANGE = new int[] { 325, -1 };
52
//		TESTS_NAMES = new String[] {"test0204"};
52
//		TESTS_NAMES = new String[] {"test0204"};
53
	}
53
	}
Lines 10915-10918 Link Here
10915
		assertEquals("Wrong size", "@goto", ((TagElement) tags.get(1)).getTagName());
10915
		assertEquals("Wrong size", "@goto", ((TagElement) tags.get(1)).getTagName());
10916
		checkSourceRange((TagElement) tags.get(1), "@goto new position", contents);
10916
		checkSourceRange((TagElement) tags.get(1), "@goto new position", contents);
10917
	}
10917
	}
10918
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=300734
10919
	public void test341() throws JavaModelException {
10920
		String contents =
10921
			"public class Bug300734 {\n" +
10922
			"	public void foo(String x) {\n" +
10923
			"		x.getClass();\n" +
10924
			"       x.getClass();\n" +
10925
			"	}\n" +
10926
			"}";
10927
		this.workingCopy = getWorkingCopy("/Converter15/src/Bug300734.java", true/*resolve*/);
10928
		CompilationUnit unit= (CompilationUnit) buildAST(
10929
			contents,
10930
			this.workingCopy,
10931
			true,
10932
			false,
10933
			true);
10934
		MethodDeclaration methodDeclaration = (MethodDeclaration) getASTNode(unit, 0, 0);
10935
		IMethodBinding methodBinding1 = ((MethodInvocation) ((ExpressionStatement) methodDeclaration.getBody().statements().get(0)).getExpression()).resolveMethodBinding();
10936
		IMethodBinding methodBinding2 = ((MethodInvocation) ((ExpressionStatement) methodDeclaration.getBody().statements().get(1)).getExpression()).resolveMethodBinding();
10937
		assertTrue("Bindings differ", methodBinding1 == methodBinding2);
10938
	}
10918
}
10939
}

Return to bug 300734