### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/BinaryMethod.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/BinaryMethod.java,v retrieving revision 1.106 diff -u -r1.106 BinaryMethod.java --- model/org/eclipse/jdt/internal/core/BinaryMethod.java 28 Jun 2010 13:07:11 -0000 1.106 +++ model/org/eclipse/jdt/internal/core/BinaryMethod.java 31 Aug 2010 07:11:00 -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 @@ -183,8 +183,15 @@ IBinaryMethod info = (IBinaryMethod) getElementInfo(); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=316937 // Use Signature#getParameterCount() only if the argument names are not already available. - final int paramCount = info.getArgumentNames() == null ? info.getArgumentNames().length : - Signature.getParameterCount(new String(info.getMethodDescriptor())); + int paramCount = Signature.getParameterCount(new String(info.getMethodDescriptor())); + if (this.isConstructor()) { + final IType declaringType = this.getDeclaringType(); + if (declaringType.isMember() + && !Flags.isStatic(declaringType.getFlags())) { + paramCount--; // remove synthetic argument from constructor param count + } + } + if (paramCount != 0) { // don't try to look for javadoc for synthetic methods int modifiers = getFlags(); #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/ClassFileTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/ClassFileTests.java,v retrieving revision 1.49 diff -u -r1.49 ClassFileTests.java --- src/org/eclipse/jdt/core/tests/model/ClassFileTests.java 24 Feb 2010 10:44:34 -0000 1.49 +++ src/org/eclipse/jdt/core/tests/model/ClassFileTests.java 31 Aug 2010 07:11:07 -0000 @@ -21,6 +21,7 @@ import org.eclipse.jdt.core.search.IJavaSearchConstants; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.core.search.SearchEngine; +import org.eclipse.jdt.internal.core.ClasspathEntry; import junit.framework.Test; @@ -1543,5 +1544,55 @@ assertStringsEqual("Type parameter bounds signatures", "TT;\n", typeParam.getBoundsSignatures()); } - + //https://bugs.eclipse.org/bugs/show_bug.cgi?id=316937 + public void testBug316937() throws Exception { + try { + IJavaProject project = getJavaProject("P"); + String[] pathAndContents = new String[] { + "bug316937/Foo.java", + "package bug316937;\n" + "public class Foo {\n" + + " class Bar {\n" + + " public Bar(int a, int b) {}\n" + " }\n" + + "}\n" }; + addLibrary(project, "lib316937.jar", "src316937.zip", + pathAndContents, JavaCore.VERSION_1_5); + IPackageFragmentRoot packageFragRoot = project + .getPackageFragmentRoot(getFile("/P/lib316937.jar")); + + IType type = packageFragRoot.getPackageFragment("bug316937") + .getClassFile("Foo.class").getType(); + IType subType = type.getType("Bar"); + IMethod[] methods = subType.getMethods(); + assertEquals("Constructros", 1, methods.length); + IMethod method = methods[0]; + String[] paramNames = method.getParameterNames(); + assertStringsEqual("Type parameter names", "a\n" + "b\n", + paramNames); + + // Remove the source attachment + IClasspathEntry[] rawClasspath = project.getRawClasspath(); + for (int index = 0; index < rawClasspath.length; index++) { + IClasspathEntry entry = rawClasspath[index]; + if (entry.getPath().toString().endsWith("lib316937.jar")) { + ((ClasspathEntry) entry).sourceAttachmentPath = null; + } + } + project.setRawClasspath(rawClasspath, null); + + packageFragRoot = project + .getPackageFragmentRoot(getFile("/P/lib316937.jar")); + type = packageFragRoot.getPackageFragment("bug316937") + .getClassFile("Foo.class").getType(); + subType = type.getType("Bar"); + methods = subType.getMethods(); + assertEquals("Constructros", 1, methods.length); + method = methods[0]; + paramNames = method.getParameterNames(); + assertStringsEqual("Type parameter names", "a\n" + "b\n", + paramNames); + } finally { + removeLibrary(getJavaProject("P"), "lib316937.jar", "src316937.zip"); + } + } + }