Skip to content

Commit 05ab890

Browse files
cushoncopybara-github
authored andcommitted
Automated Code Change
PiperOrigin-RevId: 817589000 Change-Id: I74e65db292edd281fb66433d6d036547e4eb9e68
1 parent b3ba8f8 commit 05ab890

File tree

3 files changed

+55
-4
lines changed

3 files changed

+55
-4
lines changed

java/ui/src/main/java/com/google/security/zynamics/bindiff/graph/layout/commands/GraphLayoutCalculator.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.helpers.ProximityHelper;
3939
import com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.layouters.ZyGraphLayouter;
4040
import com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.nodes.ZyGraphNode;
41+
import java.lang.reflect.InvocationTargetException;
4142
import java.util.HashMap;
4243
import java.util.Map;
4344
import java.util.concurrent.CountDownLatch;
@@ -309,15 +310,15 @@ private void adoptSuperGraphLayout(final GraphLayout superLayout) {
309310
// internal layout threads!
310311
private void cancelLayoutCalculation() {
311312
if (superLayoutThread != null && superLayoutThread.isAlive()) {
312-
superLayoutThread.stop();
313+
threadStop(superLayoutThread);
313314
superLayoutThread = null;
314315

315316
doneLatch.countDown();
316317
}
317318

318319
if (combinedLayoutThread != null && combinedLayoutThread.isAlive()) {
319320

320-
combinedLayoutThread.stop();
321+
threadStop(combinedLayoutThread);
321322
combinedLayoutThread = null;
322323

323324
doneLatch.countDown();
@@ -326,6 +327,22 @@ private void cancelLayoutCalculation() {
326327
setCanceled();
327328
}
328329

330+
private static void threadStop(Thread thread) {
331+
// TODO: b/447223240 - clean up obsolete references to Thread.stop.
332+
// Thread#stop has been deprecated since JDK 1.2. Starting in JDK 20 it always throws
333+
// UnsupportedOperationException, and in JDK 26 the method has been removed.
334+
try {
335+
Thread.class.getMethod("stop").invoke(thread);
336+
} catch (InvocationTargetException e) {
337+
if (e.getCause() instanceof UnsupportedOperationException) {
338+
throw (UnsupportedOperationException) e.getCause();
339+
}
340+
throw new UnsupportedOperationException(e);
341+
} catch (ReflectiveOperationException e) {
342+
throw new UnsupportedOperationException(e);
343+
}
344+
}
345+
329346
private CanonicMultiStageLayouter createSecondThreadLayouter(
330347
final CanonicMultiStageLayouter layouter, final GraphLayoutSettings settings) {
331348
if (layouter instanceof CircularLayouter) {

java/zylib/src/main/java/com/google/security/zynamics/zylib/gui/ProgressDialogs/CEndlessHelperThread.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package com.google.security.zynamics.zylib.gui.ProgressDialogs;
1616

1717
import com.google.security.zynamics.zylib.general.ListenerProvider;
18+
import java.lang.reflect.InvocationTargetException;
1819

1920
/**
2021
* This class is a helper thread to use with the CEndlessProgressDialog class. To use this class do
@@ -48,7 +49,23 @@ protected void finish() {
4849
// within
4950
// the threads
5051
// run routine, and when true, return from thread function)
51-
stop();
52+
threadStop(this);
53+
}
54+
55+
private static void threadStop(Thread thread) {
56+
// TODO: b/447223240 - clean up obsolete references to Thread.stop.
57+
// Thread#stop has been deprecated since JDK 1.2. Starting in JDK 20 it always throws
58+
// UnsupportedOperationException, and in JDK 26 the method has been removed.
59+
try {
60+
Thread.class.getMethod("stop").invoke(thread);
61+
} catch (InvocationTargetException e) {
62+
if (e.getCause() instanceof UnsupportedOperationException) {
63+
throw (UnsupportedOperationException) e.getCause();
64+
}
65+
throw new UnsupportedOperationException(e);
66+
} catch (ReflectiveOperationException e) {
67+
throw new UnsupportedOperationException(e);
68+
}
5269
}
5370

5471
protected abstract void runExpensiveCommand() throws Exception;

java/zylib/src/main/java/com/google/security/zynamics/zylib/gui/ProgressDialogs/CStandardHelperThread.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
package com.google.security.zynamics.zylib.gui.ProgressDialogs;
1616

1717
import com.google.security.zynamics.zylib.general.ListenerProvider;
18+
import java.lang.reflect.InvocationTargetException;
1819

1920
/**
2021
* This class is a helper thread to use with the CEndlessProgressDialog class. To use this class do
@@ -42,7 +43,23 @@ private void notifyListeners() {
4243
protected void finish() {
4344
notifyListeners();
4445

45-
stop();
46+
threadStop(this);
47+
}
48+
49+
private static void threadStop(Thread thread) {
50+
// TODO: b/447223240 - clean up obsolete references to Thread.stop.
51+
// Thread#stop has been deprecated since JDK 1.2. Starting in JDK 20 it always throws
52+
// UnsupportedOperationException, and in JDK 26 the method has been removed.
53+
try {
54+
Thread.class.getMethod("stop").invoke(thread);
55+
} catch (InvocationTargetException e) {
56+
if (e.getCause() instanceof UnsupportedOperationException) {
57+
throw (UnsupportedOperationException) e.getCause();
58+
}
59+
throw new UnsupportedOperationException(e);
60+
} catch (ReflectiveOperationException e) {
61+
throw new UnsupportedOperationException(e);
62+
}
4663
}
4764

4865
protected abstract void runExpensiveCommand() throws Exception;

0 commit comments

Comments
 (0)