From 2cd6d5d6ab024309a8cf35d95b3f6421a07eab55 Mon Sep 17 00:00:00 2001 From: wenytang-ms Date: Tue, 14 Jul 2026 11:02:21 +0800 Subject: [PATCH] refactor: use protected JUnit launch configuration API Replace the long-standing reflective access after eclipse-jdt/eclipse.jdt.ui#3079 exposed the launch configuration method to subclasses. Copilot-Session: c3cd113b-dad4-4d4d-90c2-60abfd204405 --- .../META-INF/MANIFEST.MF | 2 +- .../launchers/JUnitLaunchConfigurationDelegate.java | 12 ++---------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/java-extension/com.microsoft.java.test.plugin/META-INF/MANIFEST.MF b/java-extension/com.microsoft.java.test.plugin/META-INF/MANIFEST.MF index f9f385b5..6d0ba677 100644 --- a/java-extension/com.microsoft.java.test.plugin/META-INF/MANIFEST.MF +++ b/java-extension/com.microsoft.java.test.plugin/META-INF/MANIFEST.MF @@ -20,7 +20,7 @@ Require-Bundle: org.eclipse.jdt.core, org.eclipse.text, org.eclipse.ltk.core.refactoring, org.eclipse.debug.core, - org.eclipse.jdt.junit.core, + org.eclipse.jdt.junit.core;bundle-version="[3.15.0,4.0.0)", org.eclipse.jdt.junit.runtime, org.eclipse.jdt.junit4.runtime, org.eclipse.jdt.junit5.runtime, diff --git a/java-extension/com.microsoft.java.test.plugin/src/main/java/com/microsoft/java/test/plugin/launchers/JUnitLaunchConfigurationDelegate.java b/java-extension/com.microsoft.java.test.plugin/src/main/java/com/microsoft/java/test/plugin/launchers/JUnitLaunchConfigurationDelegate.java index c0711c5c..97f85a02 100644 --- a/java-extension/com.microsoft.java.test.plugin/src/main/java/com/microsoft/java/test/plugin/launchers/JUnitLaunchConfigurationDelegate.java +++ b/java-extension/com.microsoft.java.test.plugin/src/main/java/com/microsoft/java/test/plugin/launchers/JUnitLaunchConfigurationDelegate.java @@ -46,8 +46,6 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; @@ -96,13 +94,8 @@ public Response getJUnitLaunchArguments(ILaunchConfigurati IProgressMonitor monitor) { final ILaunch launch = new Launch(configuration, mode, null); - // TODO: Make the getVMRunnerConfiguration() in super class protected. try { - final Method getVMRunnerConfiguration = getClass().getSuperclass().getDeclaredMethod( - "getVMRunnerConfiguration", ILaunchConfiguration.class, ILaunch.class, String.class, - IProgressMonitor.class); - getVMRunnerConfiguration.setAccessible(true); - final VMRunnerConfiguration config = (VMRunnerConfiguration) getVMRunnerConfiguration.invoke(this, + final VMRunnerConfiguration config = getVMRunnerConfiguration( configuration, launch, mode, new NullProgressMonitor()); final IJavaProject javaProject = getJavaProject(configuration); final JUnitLaunchArguments launchArguments = new JUnitLaunchArguments(); @@ -115,8 +108,7 @@ public Response getJUnitLaunchArguments(ILaunchConfigurati launchArguments.programArguments = parseParameters(config.getProgramArguments()); return new Response<>(launchArguments, null); - } catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | - InvocationTargetException | CoreException e) { + } catch (CoreException e) { JUnitPlugin.logException("failed to resolve the classpath.", e); final String msg = e.getCause() != null ? e.getCause().getMessage() : e.getMessage(); return new Response<>(null, msg);