Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.jdt.internal.launching;

import java.lang.Runtime.Version;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -283,7 +284,12 @@ public static String getCompilerCompliance(IVMInstall2 vMInstall) {
} else if (matchesMajorVersion(version, JavaCore.VERSION_1_1)) {
return JavaCore.VERSION_1_3;
}
return null;
try {
Version v = Version.parse(version);
return Integer.toString(v.feature());
} catch (IllegalArgumentException ex) {
return null;
}
}

private static boolean matchesMajorVersion(String currentVersion, String knownVersion) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.lang.Runtime.Version;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
Expand Down Expand Up @@ -854,6 +855,10 @@ public static URL getDefaultJavadocLocation(String version) {
} else if (version.startsWith(JavaCore.VERSION_1_3)) {
// archived: http://download.oracle.com/javase/1.3/docs/api/
return new URL("https://docs.oracle.com/javase/1.5.0/docs/api/"); //$NON-NLS-1$
} else {
// heurisitc for not-yet declared versions
var v = Version.parse(version);
return new URI("https://docs.oracle.com/en/java/javase/" + v.feature() + "/docs/api/").toURL(); //$NON-NLS-1$ //$NON-NLS-2$
}
} catch (URISyntaxException | MalformedURLException e) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.internal.launching.LaunchingPlugin;
Expand Down Expand Up @@ -253,6 +253,16 @@ private String getExecutionEnvironmentCompliance(IExecutionEnvironment execution
return JavaCore.VERSION_1_1;
} else if (desc.indexOf("1.0") != -1) { //$NON-NLS-1$
return "1.0"; //$NON-NLS-1$
} else {
// an optimistic strategy for not-yet-declared versions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That produces 1 from 25.0.1, and that is really guessing...
I'm not sure this is the right way to guess the version out of EE.
The entire method looks like a big hack.
Why can't we add an extra "JavaCompliance" attribute to org.eclipse.jdt.launching.executionEnvironments extension point and specify there all what we need?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That produces 1 from 25.0.1, and that is really guessing..

The current code would also return 24 for 1.0.24, so it's not so much worse...

Why can't we add an extra "JavaCompliance" attribute to org.eclipse.jdt.launching.executionEnvironments extension point and specify there all what we need?

We sure can, but usually, this happens on a branch that takes ages before it is merged...

int lastNumberIndex = desc.length() - 1;
while (lastNumberIndex >= 0 && Character.isDigit(desc.charAt(lastNumberIndex))) {
lastNumberIndex--;
}
lastNumberIndex++; // fix consumed non-digit char
if (lastNumberIndex < desc.length()) {
return desc.substring(lastNumberIndex, desc.length());
}
}
return JavaCore.VERSION_1_3;
}
Expand Down
Loading