### 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.109 diff -u -r1.109 BinaryMethod.java --- model/org/eclipse/jdt/internal/core/BinaryMethod.java 29 Nov 2010 05:24:37 -0000 1.109 +++ model/org/eclipse/jdt/internal/core/BinaryMethod.java 30 Nov 2010 10:16:42 -0000 @@ -304,8 +304,8 @@ return this.parameterNames = names; } } - // if still no parameter names, produce fake ones - return this.parameterNames = getRawParameterNames(paramCount); + // If still no parameter names, produce fake ones, but don't cache them (https://bugs.eclipse.org/bugs/show_bug.cgi?id=329671) + return getRawParameterNames(paramCount); } private char[][] splitParameters(char[] parametersSource, int paramCount) { // we have generic types as one of the parameter types #P org.eclipse.jdt.core.tests.model Index: src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java,v retrieving revision 1.38 diff -u -r1.38 AttachedJavadocTests.java --- src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java 9 Aug 2010 09:35:30 -0000 1.38 +++ src/org/eclipse/jdt/core/tests/model/AttachedJavadocTests.java 30 Nov 2010 10:16:44 -0000 @@ -22,6 +22,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; import org.eclipse.jdt.core.IClassFile; import org.eclipse.jdt.core.IClasspathAttribute; import org.eclipse.jdt.core.IClasspathEntry; @@ -34,6 +35,9 @@ import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.internal.core.BinaryType; +import org.eclipse.jdt.internal.core.JavaModelManager; +import org.eclipse.jdt.internal.core.JavaModelManager.PerProjectInfo; public class AttachedJavadocTests extends ModifyingResourceTests { private static final String DEFAULT_DOC_FOLDER = "doc"; @@ -718,4 +722,65 @@ setJavadocLocationAttribute(DEFAULT_DOC_FOLDER); } } + //https://bugs.eclipse.org/bugs/show_bug.cgi?id=329671 + public void testBug329671() throws CoreException, IOException { + Map options = this.project.getOptions(true); + Object timeout = options.get(JavaCore.TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC); + options.put(JavaCore.TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC, "1"); //$NON-NLS-1$ + this.project.setOptions(options); + IClasspathEntry[] entries = this.project.getRawClasspath(); + + try { + IClasspathAttribute attribute = + JavaCore.newClasspathAttribute( + IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, + "jar:platform:/resource/AttachedJavadocProject/bug329671_doc.zip!/"); + IClasspathEntry newEntry = JavaCore.newLibraryEntry(new Path("/AttachedJavadocProject/bug329671.jar"), null, null, null, new IClasspathAttribute[] { attribute}, false); + this.project.setRawClasspath(new IClasspathEntry[]{newEntry}, null); + this.project.getResolvedClasspath(false); + + IPackageFragmentRoot jarRoot = this.project.getPackageFragmentRoot(getFile("/AttachedJavadocProject/bug329671.jar")); + final IType type = jarRoot.getPackageFragment("bug").getClassFile("X.class").getType(); + IMethod method = type.getMethod("foo", new String[]{"Ljava.lang.Object;"}); + assertNotNull(method); + + String[] paramNames = method.getParameterNames(); + assertStringsEqual("Parameter names", new String[]{"arg0"}, paramNames); + final PerProjectInfo projectInfo = JavaModelManager.getJavaModelManager().getPerProjectInfoCheckExistence(this.project.getProject()); + final Object varThis = this; + Thread thread = new Thread(){ + public void run() { + Object javadocContent = projectInfo.javadocCache.get(type); + while(javadocContent == null || javadocContent == BinaryType.EMPTY_JAVADOC) { + try { + Thread.sleep(50); + javadocContent = projectInfo.javadocCache.get(type); + } catch (InterruptedException e) { + } + synchronized (varThis) { + varThis.notify(); + } + } + } + }; + thread.start(); + synchronized (varThis) { + try { + varThis.wait(5000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + projectInfo.javadocCache.flush(); + options.put(JavaCore.TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC, "5000"); //$NON-NLS-1$ + this.project.setOptions(options); + paramNames = method.getParameterNames(); + assertStringsEqual("Parameter names", new String[]{"param"}, paramNames); + } finally { + this.project.setRawClasspath(entries, null); + if (timeout != null) + options.put(JavaCore.TIMEOUT_FOR_PARAMETER_NAME_FROM_ATTACHED_JAVADOC, timeout); + this.project.setOptions(options); + } + } }