|
12 | 12 | *******************************************************************************/
|
13 | 13 | package org.eclipse.jdt.ls.core.internal;
|
14 | 14 |
|
| 15 | +import static org.eclipse.jdt.ls.core.internal.ProjectUtils.getJavaSourceLevel; |
15 | 16 | import static org.junit.Assert.assertEquals;
|
16 | 17 | import static org.junit.Assert.assertNotEquals;
|
17 | 18 | import static org.junit.Assert.assertNotNull;
|
|
30 | 31 | import org.eclipse.core.runtime.CoreException;
|
31 | 32 | import org.eclipse.core.runtime.FileLocator;
|
32 | 33 | import org.eclipse.core.runtime.IStatus;
|
| 34 | +import org.eclipse.core.runtime.NullProgressMonitor; |
33 | 35 | import org.eclipse.core.runtime.Platform;
|
34 | 36 | import org.eclipse.core.runtime.URIUtil;
|
35 | 37 | import org.eclipse.jdt.core.IJavaProject;
|
|
42 | 44 | import org.eclipse.jdt.launching.JavaRuntime;
|
43 | 45 | import org.eclipse.jdt.launching.LibraryLocation;
|
44 | 46 | import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
|
| 47 | +import org.eclipse.jdt.ls.core.internal.handlers.WorkspaceSymbolHandler; |
45 | 48 | import org.eclipse.jdt.ls.core.internal.managers.AbstractInvisibleProjectBasedTest;
|
46 | 49 | import org.eclipse.jdt.ls.core.internal.preferences.ClientPreferences;
|
47 | 50 | import org.eclipse.jdt.ls.core.internal.preferences.Preferences;
|
48 | 51 | import org.eclipse.lsp4j.MessageParams;
|
49 | 52 | import org.eclipse.lsp4j.MessageType;
|
| 53 | +import org.eclipse.lsp4j.SymbolInformation; |
50 | 54 | import org.junit.After;
|
51 | 55 | import org.junit.Before;
|
52 | 56 | import org.junit.Test;
|
@@ -246,6 +250,19 @@ public void testInvalidRuntime() throws Exception {
|
246 | 250 | assertEquals("Invalid runtime for " + runtime.getName() + ": 'bin' should be removed from the path (" + runtime.getPath() + ").", notification.getMessage());
|
247 | 251 | }
|
248 | 252 |
|
| 253 | + // https://github.com/redhat-developer/vscode-java/issues/3452 |
| 254 | + @Test |
| 255 | + public void testJavaRuntimesDoNotLeak() throws Exception { |
| 256 | + importProjects("maven/salut-java11"); |
| 257 | + IProject project = WorkspaceHelper.getProject("salut-java11"); |
| 258 | + assertIsJavaProject(project); |
| 259 | + assertEquals("11", getJavaSourceLevel(project)); |
| 260 | + JVMConfigurator.configureJVMs(preferences, javaClient); |
| 261 | + List<SymbolInformation> results = WorkspaceSymbolHandler.search("java.lang.Object", new NullProgressMonitor()); |
| 262 | + int numOfObjectSymbols = results.stream().filter(s -> "java.lang".equals(s.getContainerName()) && "Object".equals(s.getName())).toList().size(); |
| 263 | + assertEquals(1, numOfObjectSymbols); |
| 264 | + } |
| 265 | + |
249 | 266 | private void assertComplianceAndPreviewSupport(IJavaProject javaProject, String compliance, boolean previewEnabled) {
|
250 | 267 | assertEquals(previewEnabled ? JavaCore.ENABLED : JavaCore.DISABLED, javaProject.getOption(JavaCore.COMPILER_PB_ENABLE_PREVIEW_FEATURES, true));
|
251 | 268 | assertEquals(compliance, javaProject.getOption(JavaCore.COMPILER_COMPLIANCE, true));
|
|
0 commit comments