diff --git a/java/ui/src/main/java/com/google/security/zynamics/bindiff/graph/layout/commands/GraphLayoutCalculator.java b/java/ui/src/main/java/com/google/security/zynamics/bindiff/graph/layout/commands/GraphLayoutCalculator.java index 42a2caf8..a4500dd3 100644 --- a/java/ui/src/main/java/com/google/security/zynamics/bindiff/graph/layout/commands/GraphLayoutCalculator.java +++ b/java/ui/src/main/java/com/google/security/zynamics/bindiff/graph/layout/commands/GraphLayoutCalculator.java @@ -38,6 +38,7 @@ import com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.helpers.ProximityHelper; import com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.layouters.ZyGraphLayouter; import com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.nodes.ZyGraphNode; +import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import java.util.Map; import java.util.concurrent.CountDownLatch; @@ -309,7 +310,7 @@ private void adoptSuperGraphLayout(final GraphLayout superLayout) { // internal layout threads! private void cancelLayoutCalculation() { if (superLayoutThread != null && superLayoutThread.isAlive()) { - superLayoutThread.stop(); + threadStop(superLayoutThread); superLayoutThread = null; doneLatch.countDown(); @@ -317,7 +318,7 @@ private void cancelLayoutCalculation() { if (combinedLayoutThread != null && combinedLayoutThread.isAlive()) { - combinedLayoutThread.stop(); + threadStop(combinedLayoutThread); combinedLayoutThread = null; doneLatch.countDown(); @@ -326,6 +327,22 @@ private void cancelLayoutCalculation() { setCanceled(); } + private static void threadStop(Thread thread) { + // TODO: b/447223240 - clean up obsolete references to Thread.stop. + // Thread#stop has been deprecated since JDK 1.2. Starting in JDK 20 it always throws + // UnsupportedOperationException, and in JDK 26 the method has been removed. + try { + Thread.class.getMethod("stop").invoke(thread); + } catch (InvocationTargetException e) { + if (e.getCause() instanceof UnsupportedOperationException) { + throw (UnsupportedOperationException) e.getCause(); + } + throw new UnsupportedOperationException(e); + } catch (ReflectiveOperationException e) { + throw new UnsupportedOperationException(e); + } + } + private CanonicMultiStageLayouter createSecondThreadLayouter( final CanonicMultiStageLayouter layouter, final GraphLayoutSettings settings) { if (layouter instanceof CircularLayouter) { diff --git a/java/zylib/src/main/java/com/google/security/zynamics/zylib/gui/ProgressDialogs/CEndlessHelperThread.java b/java/zylib/src/main/java/com/google/security/zynamics/zylib/gui/ProgressDialogs/CEndlessHelperThread.java index e8598741..678c4f1f 100644 --- a/java/zylib/src/main/java/com/google/security/zynamics/zylib/gui/ProgressDialogs/CEndlessHelperThread.java +++ b/java/zylib/src/main/java/com/google/security/zynamics/zylib/gui/ProgressDialogs/CEndlessHelperThread.java @@ -15,6 +15,7 @@ package com.google.security.zynamics.zylib.gui.ProgressDialogs; import com.google.security.zynamics.zylib.general.ListenerProvider; +import java.lang.reflect.InvocationTargetException; /** * This class is a helper thread to use with the CEndlessProgressDialog class. To use this class do @@ -48,7 +49,23 @@ protected void finish() { // within // the threads // run routine, and when true, return from thread function) - stop(); + threadStop(this); + } + + private static void threadStop(Thread thread) { + // TODO: b/447223240 - clean up obsolete references to Thread.stop. + // Thread#stop has been deprecated since JDK 1.2. Starting in JDK 20 it always throws + // UnsupportedOperationException, and in JDK 26 the method has been removed. + try { + Thread.class.getMethod("stop").invoke(thread); + } catch (InvocationTargetException e) { + if (e.getCause() instanceof UnsupportedOperationException) { + throw (UnsupportedOperationException) e.getCause(); + } + throw new UnsupportedOperationException(e); + } catch (ReflectiveOperationException e) { + throw new UnsupportedOperationException(e); + } } protected abstract void runExpensiveCommand() throws Exception; diff --git a/java/zylib/src/main/java/com/google/security/zynamics/zylib/gui/ProgressDialogs/CStandardHelperThread.java b/java/zylib/src/main/java/com/google/security/zynamics/zylib/gui/ProgressDialogs/CStandardHelperThread.java index bf54f730..ba1c77a4 100644 --- a/java/zylib/src/main/java/com/google/security/zynamics/zylib/gui/ProgressDialogs/CStandardHelperThread.java +++ b/java/zylib/src/main/java/com/google/security/zynamics/zylib/gui/ProgressDialogs/CStandardHelperThread.java @@ -15,6 +15,7 @@ package com.google.security.zynamics.zylib.gui.ProgressDialogs; import com.google.security.zynamics.zylib.general.ListenerProvider; +import java.lang.reflect.InvocationTargetException; /** * This class is a helper thread to use with the CEndlessProgressDialog class. To use this class do @@ -42,7 +43,23 @@ private void notifyListeners() { protected void finish() { notifyListeners(); - stop(); + threadStop(this); + } + + private static void threadStop(Thread thread) { + // TODO: b/447223240 - clean up obsolete references to Thread.stop. + // Thread#stop has been deprecated since JDK 1.2. Starting in JDK 20 it always throws + // UnsupportedOperationException, and in JDK 26 the method has been removed. + try { + Thread.class.getMethod("stop").invoke(thread); + } catch (InvocationTargetException e) { + if (e.getCause() instanceof UnsupportedOperationException) { + throw (UnsupportedOperationException) e.getCause(); + } + throw new UnsupportedOperationException(e); + } catch (ReflectiveOperationException e) { + throw new UnsupportedOperationException(e); + } } protected abstract void runExpensiveCommand() throws Exception;