Skip to content

Commit 2f623a3

Browse files
committed
Java 21 deprecation fixes
1 parent 91c8dbf commit 2f623a3

File tree

6 files changed

+40
-32
lines changed

6 files changed

+40
-32
lines changed

ant/org.eclipse.ant.tests.core/tests/org/eclipse/ant/tests/core/tests/FrameworkTests.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2016 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
@@ -22,6 +22,8 @@
2222

2323
import java.io.File;
2424
import java.net.MalformedURLException;
25+
import java.net.URI;
26+
import java.net.URISyntaxException;
2527
import java.net.URL;
2628

2729
import org.eclipse.ant.core.AntCorePlugin;
@@ -270,15 +272,16 @@ public void testGetTargets() throws CoreException {
270272
}
271273

272274
/**
273-
* Tests bug 389564 for a class path entry as a url representing a remote file system location
275+
* Tests bug 389564 for a class path entry as a url representing a remote file
276+
* system location
274277
*/
275278
@Test
276-
public void testAntClasspathEntryFromUrl() throws MalformedURLException {
279+
public void testAntClasspathEntryFromUrl() throws MalformedURLException, URISyntaxException {
277280

278281
AntCorePreferences prefs = AntCorePlugin.getPlugin().getPreferences();
279282

280283
String path = "//hub/home/tom/.eclipse/3.8/configuration/org.eclipse.osgi/bundles/21/2/.cp/lib/remote.jar"; //$NON-NLS-1$
281-
URL url = new URL(IAntCoreConstants.FILE_PROTOCOL + path);
284+
URL url = new URI(IAntCoreConstants.FILE_PROTOCOL + path).toURL();
282285
IAntClasspathEntry entry = new AntClasspathEntry(url);
283286

284287
IAntClasspathEntry[] entries = prefs.getAntHomeClasspathEntries();

debug/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/SelectedResourceManager.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2018 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
@@ -292,11 +292,11 @@ private static void reportTimeout() {
292292
MultiStatus main = new MultiStatus(DebugUIPlugin.getUniqueIdentifier(), IStatus.ERROR, msg, null);
293293

294294
ThreadInfo[] threads = ManagementFactory.getThreadMXBean().getThreadInfo(
295-
new long[] { nonUiThread.getId(), Display.getDefault().getThread().getId() }, true, true);
295+
new long[] { nonUiThread.threadId(), Display.getDefault().getThread().threadId() }, true, true);
296296

297297
for (ThreadInfo info : threads) {
298298
String childMsg;
299-
if (info.getThreadId() == nonUiThread.getId()) {
299+
if (info.getThreadId() == nonUiThread.threadId()) {
300300
childMsg = nonUiThread.getName() + " thread probably holding a lock and trying to acquire UI lock"; //$NON-NLS-1$
301301
} else {
302302
childMsg = "UI thread waiting on a job or lock."; //$NON-NLS-1$

team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/LineReaderTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2005, 2018 IBM Corporation and others.
2+
* Copyright (c) 2005, 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
@@ -70,7 +70,7 @@ public void testReadUnterminatedLastLine() throws IOException {
7070

7171
private BufferedReader getReader(String name) throws IOException {
7272
IPath path = IPath.fromOSString("linereaderdata/" + name);
73-
URL url = new URL(CompareTestPlugin.getDefault().getBundle().getEntry("/"), path.toString());
73+
URL url = CompareTestPlugin.getDefault().getBundle().getEntry("/" + path.toString());
7474
InputStream resourceAsStream = url.openStream();
7575
InputStreamReader reader2 = new InputStreamReader(resourceAsStream);
7676
return new BufferedReader(reader2);

team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/PatchTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2018 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
@@ -243,7 +243,7 @@ public void testWorkspacePatch_Delete_Reverse() {
243243

244244
@Test
245245
public void testPatchdataSubfolders() throws IOException, CoreException {
246-
URL patchdataUrl = new URL(PatchUtils.getBundle().getEntry("/"), IPath.fromOSString(PatchUtils.PATCHDATA).toString());
246+
URL patchdataUrl = PatchUtils.getBundle().getEntry("/" + IPath.fromOSString(PatchUtils.PATCHDATA).toString());
247247
patchdataUrl = FileLocator.resolve(patchdataUrl);
248248

249249
Map<String, PatchTestConfiguration> map = null;

team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/TextMergeViewerTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2006, 2023 IBM Corporation and others.
2+
* Copyright (c) 2006, 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
@@ -571,10 +571,10 @@ public String getType() {
571571
public void testToolbarLabelContribution() throws Exception {
572572

573573
IPath path = IPath.fromOSString("labelContributionData/" + "file1.java");
574-
URL url = new URL(CompareTestPlugin.getDefault().getBundle().getEntry("/"), path.toString());
574+
URL url = CompareTestPlugin.getDefault().getBundle().getEntry("/" + path.toString());
575575

576576
IPath path1= IPath.fromOSString("labelContributionData/" + "file2.java");
577-
URL url1 = new URL(CompareTestPlugin.getDefault().getBundle().getEntry("/"), path1.toString());
577+
URL url1 = CompareTestPlugin.getDefault().getBundle().getEntry("/" + path1.toString());
578578

579579
DiffNode parentNode = new DiffNode(new ParentTestElement(), new ParentTestElement());
580580
DiffNode testNode = new DiffNode(parentNode, Differencer.CHANGE, null, new EditableTestElement(url.openStream().readAllBytes()), new EditableTestElement(url1.openStream().readAllBytes()));

ua/org.eclipse.tips.tests/src/org/eclipse/tips/core/TipImageURLTest.java

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2018 Remain Software
2+
* Copyright (c) 2018, 2025 Remain Software
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -17,7 +17,8 @@
1717
import static org.junit.jupiter.api.Assertions.assertThrows;
1818

1919
import java.io.IOException;
20-
import java.net.MalformedURLException;
20+
import java.net.URI;
21+
import java.net.URISyntaxException;
2122
import java.net.URL;
2223

2324
import org.eclipse.core.runtime.AssertionFailedException;
@@ -34,73 +35,77 @@ public void testTipImage() {
3435

3536
@Test
3637
public void testTipImage3() {
37-
assertThrows(MalformedURLException.class, () -> new TipImage(new URL("0gl kjfslkfjsl dkfjsldkfjl")));
38+
assertThrows(URISyntaxException.class, () -> new TipImage(new URI("0gl kjfslkfjsl dkfjsldkfjl").toURL()));
3839
}
3940

4041
@Test
41-
public void testTipImage2() throws IOException {
42+
public void testTipImage2() throws IOException, URISyntaxException {
4243
getTipImage();
4344
}
4445

45-
private TipImage getTipImage() throws IOException {
46-
return new TipImage(new URL(URL));
46+
private TipImage getTipImage() throws IOException, URISyntaxException {
47+
return new TipImage(new URI(URL).toURL());
4748
}
4849

4950
@Test
50-
public void testSetMaxHeight() throws IOException {
51-
String imgAttributes = new TipImage(new URL(URL)).setAspectRatio(2).setMaxHeight(300).getIMGAttributes(200,
51+
public void testSetMaxHeight() throws IOException, URISyntaxException {
52+
String imgAttributes = new TipImage(new URI(URL).toURL()).setAspectRatio(2).setMaxHeight(300)
53+
.getIMGAttributes(200,
5254
200);
5355
assertThat(imgAttributes.trim()).isEqualToIgnoringCase("width=\"200\" height=\"100\"");
5456
}
5557

5658
@Test
57-
public void testSetMaxWidth() throws IOException {
58-
String imgAttributes = new TipImage(new URL(URL)).setAspectRatio(1.6).setMaxWidth(200).getIMGAttributes(400,
59+
public void testSetMaxWidth() throws IOException, URISyntaxException {
60+
String imgAttributes = new TipImage(new URI(URL).toURL()).setAspectRatio(1.6).setMaxWidth(200)
61+
.getIMGAttributes(400,
5962
300);
6063
assertThat(imgAttributes.trim()).isEqualToIgnoringCase("width=\"200\" height=\"125\"");
6164
}
6265

6366
@Test
6467
public void testAssertWidth() {
65-
assertThrows(AssertionFailedException.class, () -> new TipImage(new URL(URL)).setAspectRatio(0, 100, false));
68+
assertThrows(AssertionFailedException.class,
69+
() -> new TipImage(new URI(URL).toURL()).setAspectRatio(0, 100, false));
6670
}
6771

6872
@Test
6973
public void testAssertHeight() {
70-
assertThrows(AssertionFailedException.class, () -> new TipImage(new URL(URL)).setAspectRatio(1000, 0, false));
74+
assertThrows(AssertionFailedException.class,
75+
() -> new TipImage(new URI(URL).toURL()).setAspectRatio(1000, 0, false));
7176
}
7277

7378
@Test
74-
public void testSetAspectRatioIntIntFalse() throws IOException {
79+
public void testSetAspectRatioIntIntFalse() throws IOException, URISyntaxException {
7580
String result = getTipImage().setAspectRatio(200, 50, false).getIMGAttributes(100, 100).trim();
7681
assertThat(result).isEqualToIgnoringCase("width=\"100\" height=\"25\"");
7782
}
7883

7984
@Test
80-
public void testSetAspectRatioIntIntTrue() throws IOException {
85+
public void testSetAspectRatioIntIntTrue() throws IOException, URISyntaxException {
8186
String result = getTipImage().setAspectRatio(400, 300, true).getIMGAttributes(740, 370).trim();
8287
assertThat(result).isEqualToIgnoringCase("width=\"400\" height=\"300\"");
8388
}
8489

8590
@Test
86-
public void testSetAspectRatioDouble() throws IOException {
91+
public void testSetAspectRatioDouble() throws IOException, URISyntaxException {
8792
String result = getTipImage().setAspectRatio(1.5).getIMGAttributes(740, 370).trim();
8893
assertThat(result).isEqualToIgnoringCase("width=\"555\" height=\"370\"");
8994
}
9095

9196
@Test
92-
public void testGetIMGAttributes() throws IOException {
97+
public void testGetIMGAttributes() throws IOException, URISyntaxException {
9398
String result = getTipImage().setAspectRatio(1.5).getIMGAttributes(740, 370).trim();
9499
assertThat(result).isEqualToIgnoringCase("width=\"555\" height=\"370\"");
95100
}
96101

97102
@Test
98-
public void testSetExtension() throws IOException {
103+
public void testSetExtension() throws IOException, URISyntaxException {
99104
assertThat(getTipImage().getBase64Image()).contains("png");
100105
}
101106

102107
@Test
103-
public void testSetExtension2() throws IOException {
108+
public void testSetExtension2() throws IOException, URISyntaxException {
104109
assertThat(getTipImage().setExtension("bmp").getBase64Image()).contains("bmp");
105110
}
106111
}

0 commit comments

Comments
 (0)