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/ASTConverterBugsTestJLS3.java (+22 lines)
Lines 18-23 Link Here
18
import org.eclipse.jdt.core.ICompilationUnit;
18
import org.eclipse.jdt.core.ICompilationUnit;
19
import org.eclipse.jdt.core.JavaModelException;
19
import org.eclipse.jdt.core.JavaModelException;
20
import org.eclipse.jdt.core.dom.AST;
20
import org.eclipse.jdt.core.dom.AST;
21
import org.eclipse.jdt.core.dom.CompilationUnit;
22
import org.eclipse.jdt.core.dom.ExpressionStatement;
23
import org.eclipse.jdt.core.dom.IMethodBinding;
24
import org.eclipse.jdt.core.dom.MethodDeclaration;
25
import org.eclipse.jdt.core.dom.MethodInvocation;
21
26
22
/**
27
/**
23
 * Test suite to verify that DOM/AST bugs are fixed.
28
 * Test suite to verify that DOM/AST bugs are fixed.
Lines 1042-1045 Link Here
1042
			"Syntax error on token \",\", < expected\n",
1047
			"Syntax error on token \",\", < expected\n",
1043
			result);
1048
			result);
1044
}
1049
}
1050
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=300734
1051
public void testBug300734() throws JavaModelException {
1052
	this.workingCopies = new ICompilationUnit[1];
1053
	this.workingCopies[0] = getWorkingCopy("/Converter15/src/Bug300734.java",
1054
			"public class Bug300734 {\n" +
1055
			"	public void foo(String x) {\n" +
1056
			"		x.getClass();\n" +
1057
			"       x.getClass();\n" +
1058
			"	}\n" +
1059
			"}"
1060
	);
1061
	CompilationUnit unit = (CompilationUnit) runConversion(this.workingCopies[0], true/*bindings*/, false/*no statement recovery*/, true/*bindings recovery*/);
1062
	MethodDeclaration methodDeclaration = (MethodDeclaration) getASTNode(unit, 0, 0);
1063
	IMethodBinding methodBinding1 = ((MethodInvocation) ((ExpressionStatement) methodDeclaration.getBody().statements().get(0)).getExpression()).resolveMethodBinding();
1064
	IMethodBinding methodBinding2 = ((MethodInvocation) ((ExpressionStatement) methodDeclaration.getBody().statements().get(1)).getExpression()).resolveMethodBinding();
1065
	assertTrue("Bindings differ", methodBinding1 == methodBinding2);
1066
}
1045
}
1067
}

Return to bug 300734