Skip to content

Commit 99b7af4

Browse files
committed
Fix warnings due Java 21 deprecations in o.e.debug.tests
Do not create new URL but fetch it directly from bundle. Minor cleanup to specify type of collections which allows the forech cleanup to kick up too.
1 parent fd5c8ce commit 99b7af4

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/TestsPlugin.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2009, 2013 Wind River Systems and others.
2+
* Copyright (c) 2009, 2025 Wind River Systems and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -24,7 +24,6 @@
2424
import org.eclipse.core.resources.ResourcesPlugin;
2525
import org.eclipse.core.runtime.CoreException;
2626
import org.eclipse.core.runtime.FileLocator;
27-
import org.eclipse.core.runtime.IPath;
2827
import org.osgi.framework.Bundle;
2928
import org.osgi.framework.FrameworkUtil;
3029

@@ -38,15 +37,17 @@ public class TestsPlugin {
3837
public static final String PLUGIN_ID = "org.eclipse.debug.tests"; //$NON-NLS-1$
3938

4039
/**
41-
* Returns the file corresponding to the specified path from within this bundle
42-
* @return the file corresponding to the specified path from within this bundle, or
43-
* <code>null</code> if not found
40+
* Returns the file corresponding to the specified path from within this
41+
* bundle
42+
*
43+
* @return the file corresponding to the specified path from within this
44+
* bundle, or <code>null</code> if not found
4445
*/
45-
public static File getFileInPlugin(IPath path) {
46+
public static File getFileInPlugin(String path) {
4647
try {
4748
Bundle bundle = FrameworkUtil.getBundle(TestsPlugin.class);
48-
URL installURL = new URL(bundle.getEntry("/"), path.toString()); //$NON-NLS-1$
49-
URL localURL= FileLocator.toFileURL(installURL);//Platform.asLocalURL(installURL);
49+
URL installURL = bundle.getEntry("/" + path); //$NON-NLS-1$
50+
URL localURL = FileLocator.toFileURL(installURL);
5051
return new File(localURL.getFile());
5152
} catch (IOException e) {
5253
return null;
@@ -55,6 +56,7 @@ public static File getFileInPlugin(IPath path) {
5556

5657
/**
5758
* Creates a new project with the specified name
59+
*
5860
* @return a new project with the specified name
5961
*/
6062
public static IProject createProject(String projectName) throws CoreException {

debug/org.eclipse.debug.tests/src/org/eclipse/debug/tests/launching/LaunchConfigurationTests.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2021 IBM Corporation and others.
2+
* Copyright (c) 2000, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -38,7 +38,6 @@
3838
import java.util.Collections;
3939
import java.util.HashMap;
4040
import java.util.HashSet;
41-
import java.util.Iterator;
4241
import java.util.List;
4342
import java.util.Map;
4443
import java.util.Set;
@@ -1213,7 +1212,7 @@ public void testImport() throws Exception {
12131212
ILaunchConfiguration handle = wc.doSave();
12141213
assertTrue("Configuration should exist", handle.exists()); //$NON-NLS-1$
12151214

1216-
File dir = TestsPlugin.getFileInPlugin(IPath.fromOSString("test-import")); //$NON-NLS-1$
1215+
File dir = TestsPlugin.getFileInPlugin("test-import"); //$NON-NLS-1$
12171216
assertTrue("Import directory does not exist", dir.exists()); //$NON-NLS-1$
12181217
LaunchManager manager = (LaunchManager) getLaunchManager();
12191218

@@ -1231,12 +1230,10 @@ public void testImport() throws Exception {
12311230
assertTrue("Import4 should be removed", removed.contains(handle)); //$NON-NLS-1$
12321231

12331232
// should be 5 added
1234-
List<?> added = listener.getAdded();
1233+
List<ILaunchConfiguration> added = listener.getAdded();
12351234
assertEquals("Should be 5 added configs", 5, added.size()); //$NON-NLS-1$
12361235
Set<String> names = new HashSet<>();
1237-
Iterator<?> iterator = added.iterator();
1238-
while (iterator.hasNext()) {
1239-
ILaunchConfiguration lc = (ILaunchConfiguration) iterator.next();
1236+
for (ILaunchConfiguration lc : added) {
12401237
names.add(lc.getName());
12411238
}
12421239
assertTrue("Missing Name", names.contains("Import1")); //$NON-NLS-1$ //$NON-NLS-2$

0 commit comments

Comments
 (0)