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

Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/core/BinaryMethod.java (-3 / +10 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 183-190 Link Here
183
	IBinaryMethod info = (IBinaryMethod) getElementInfo();
183
	IBinaryMethod info = (IBinaryMethod) getElementInfo();
184
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=316937
184
	// https://bugs.eclipse.org/bugs/show_bug.cgi?id=316937
185
	// Use Signature#getParameterCount() only if the argument names are not already available.
185
	// Use Signature#getParameterCount() only if the argument names are not already available.
186
	final int paramCount = info.getArgumentNames() == null ? info.getArgumentNames().length : 
186
	int paramCount = Signature.getParameterCount(new String(info.getMethodDescriptor()));
187
										Signature.getParameterCount(new String(info.getMethodDescriptor()));
187
	if (this.isConstructor()) {
188
		final IType declaringType = this.getDeclaringType();
189
		if (declaringType.isMember()
190
				&& !Flags.isStatic(declaringType.getFlags())) {
191
			paramCount--; // remove synthetic argument from constructor param count
192
		}
193
	}
194
188
	if (paramCount != 0) {
195
	if (paramCount != 0) {
189
		// don't try to look for javadoc for synthetic methods
196
		// don't try to look for javadoc for synthetic methods
190
		int modifiers = getFlags();
197
		int modifiers = getFlags();
(-)src/org/eclipse/jdt/core/tests/model/ClassFileTests.java (-1 / +52 lines)
Lines 21-26 Link Here
21
import org.eclipse.jdt.core.search.IJavaSearchConstants;
21
import org.eclipse.jdt.core.search.IJavaSearchConstants;
22
import org.eclipse.jdt.core.search.IJavaSearchScope;
22
import org.eclipse.jdt.core.search.IJavaSearchScope;
23
import org.eclipse.jdt.core.search.SearchEngine;
23
import org.eclipse.jdt.core.search.SearchEngine;
24
import org.eclipse.jdt.internal.core.ClasspathEntry;
24
25
25
import junit.framework.Test;
26
import junit.framework.Test;
26
27
Lines 1543-1547 Link Here
1543
		assertStringsEqual("Type parameter bounds signatures", 
1544
		assertStringsEqual("Type parameter bounds signatures", 
1544
							"TT;\n", typeParam.getBoundsSignatures());
1545
							"TT;\n", typeParam.getBoundsSignatures());
1545
	}
1546
	}
1546
1547
	//https://bugs.eclipse.org/bugs/show_bug.cgi?id=316937
1548
	public void testBug316937() throws Exception {
1549
		try {
1550
			IJavaProject project = getJavaProject("P");
1551
			String[] pathAndContents = new String[] {
1552
					"bug316937/Foo.java",
1553
					"package bug316937;\n" + "public class Foo {\n"
1554
							+ "	class Bar {\n"
1555
							+ "		public Bar(int a, int b) {}\n" + "	}\n"
1556
							+ "}\n" };
1557
			addLibrary(project, "lib316937.jar", "src316937.zip",
1558
					pathAndContents, JavaCore.VERSION_1_5);
1559
			IPackageFragmentRoot packageFragRoot = project
1560
					.getPackageFragmentRoot(getFile("/P/lib316937.jar"));
1561
1562
			IType type = packageFragRoot.getPackageFragment("bug316937")
1563
					.getClassFile("Foo.class").getType();
1564
			IType subType = type.getType("Bar");
1565
			IMethod[] methods = subType.getMethods();
1566
			assertEquals("Constructros", 1, methods.length);
1567
			IMethod method = methods[0];
1568
			String[] paramNames = method.getParameterNames();
1569
			assertStringsEqual("Type parameter names", "a\n" + "b\n",
1570
					paramNames);
1571
1572
			// Remove the source attachment
1573
			IClasspathEntry[] rawClasspath = project.getRawClasspath();
1574
			for (int index = 0; index < rawClasspath.length; index++) {
1575
				IClasspathEntry entry = rawClasspath[index];
1576
				if (entry.getPath().toString().endsWith("lib316937.jar")) {
1577
					((ClasspathEntry) entry).sourceAttachmentPath = null;
1578
				}
1579
			}
1580
			project.setRawClasspath(rawClasspath, null);
1581
1582
			packageFragRoot = project
1583
					.getPackageFragmentRoot(getFile("/P/lib316937.jar"));
1584
			type = packageFragRoot.getPackageFragment("bug316937")
1585
					.getClassFile("Foo.class").getType();
1586
			subType = type.getType("Bar");
1587
			methods = subType.getMethods();
1588
			assertEquals("Constructros", 1, methods.length);
1589
			method = methods[0];
1590
			paramNames = method.getParameterNames();
1591
			assertStringsEqual("Type parameter names", "a\n" + "b\n",
1592
					paramNames);
1593
		} finally {
1594
			removeLibrary(getJavaProject("P"), "lib316937.jar", "src316937.zip");
1595
		}
1596
	}
1597
	
1547
}
1598
}

Return to bug 316937