Bug 575016: [javadoc] Method JavaDoc URL format varies with Java
versions

Change-Id: I8a1c0c1283f175413978286f3aa167edbf8b82c8
Reviewed-on: https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/183426
Tested-by: JDT Bot <jdt-bot@eclipse.org>
Reviewed-by: Noopur Gupta <noopur_gupta@in.ibm.com>
diff --git a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java
index 0c33010..a50255a 100644
--- a/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java
+++ b/org.eclipse.jdt.core.manipulation/core extension/org/eclipse/jdt/internal/corext/util/JavaModelUtil.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2020 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -974,7 +974,7 @@
 		return is16OrHigher(getSourceCompliance(project));
 	}
 
-	private static String getSourceCompliance(IJavaProject project) {
+	public static String getSourceCompliance(IJavaProject project) {
 		return project != null ? project.getOption(JavaCore.COMPILER_SOURCE, true) : JavaCore.getOption(JavaCore.COMPILER_SOURCE);
 	}
 
diff --git a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/javadoc/JavaDocLocations.java b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/javadoc/JavaDocLocations.java
index 2e4d092..a1acd97 100644
--- a/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/javadoc/JavaDocLocations.java
+++ b/org.eclipse.jdt.ui/core extension/org/eclipse/jdt/internal/corext/javadoc/JavaDocLocations.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2018 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
  *
  * This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License 2.0
@@ -410,15 +410,26 @@
 		 * This breaks all clients that directly create such URLs.
 		 * We can't know what format is required, so we just guess by the project's compiler compliance.
 		 */
-		boolean is18OrHigher= JavaModelUtil.is1d8OrHigher(meth.getJavaProject());
-		buf.append(is18OrHigher ? '-' : '(');
+		IJavaProject javaProject= meth.getJavaProject();
+		String compliance= JavaModelUtil.getSourceCompliance(javaProject);
+		boolean is1d8Or9= JavaCore.compareJavaVersions(compliance, JavaCore.VERSION_1_8) == 0 || JavaCore.compareJavaVersions(compliance, JavaCore.VERSION_9) == 0;
+		boolean is10OrHigher= JavaModelUtil.is10OrHigher(javaProject);
+		buf.append(is1d8Or9 ? '-' : '(');
 		String[] params= meth.getParameterTypes();
 		IType declaringType= meth.getDeclaringType();
 		boolean isVararg= Flags.isVarargs(meth.getFlags());
 		int lastParam= params.length - 1;
 		for (int i= 0; i <= lastParam; i++) {
 			if (i != 0) {
-				buf.append(is18OrHigher ? "-" : ", "); //$NON-NLS-1$ //$NON-NLS-2$
+				String paramDelim;
+				if (is1d8Or9) {
+					paramDelim= "-"; //$NON-NLS-1$
+				} else if (is10OrHigher) {
+					paramDelim= ","; //$NON-NLS-1$
+				} else {
+					paramDelim= ", "; //$NON-NLS-1$
+				}
+				buf.append(paramDelim);
 			}
 			String curr= Signature.getTypeErasure(params[i]);
 			String fullName= JavaModelUtil.getResolvedTypeName(curr, declaringType);
@@ -432,7 +443,7 @@
 					dim--;
 				}
 				while (dim > 0) {
-					buf.append(is18OrHigher ? ":A" : "[]"); //$NON-NLS-1$ //$NON-NLS-2$
+					buf.append(is1d8Or9 ? ":A" : "[]"); //$NON-NLS-1$ //$NON-NLS-2$
 					dim--;
 				}
 				if (i == lastParam && isVararg) {
@@ -440,7 +451,7 @@
 				}
 			}
 		}
-		buf.append(is18OrHigher ? '-' : ')');
+		buf.append(is1d8Or9 ? '-' : ')');
 	}
 
 	/**