From 0b00fc8f9c9f983a6dc903f2207ba395d9f2472a Mon Sep 17 00:00:00 2001 From: Hannes Wellmann Date: Sun, 24 Mar 2024 17:51:39 +0100 Subject: [PATCH] Enforce encapsulation of equinox-launcher Constants and JNIBridge --- .../org.eclipse.equinox.launcher/META-INF/MANIFEST.MF | 1 - .../equinox/{internal => }/launcher/Constants.java | 6 +++--- .../src/org/eclipse/equinox/launcher/JNIBridge.java | 5 ++--- .../src/org/eclipse/equinox/launcher/Main.java | 4 +--- .../library/org.eclipse.launcher.tests/pom.xml | 2 +- .../eclipse/equinox/launcher}/TestLauncherApp.java | 11 +++++------ .../equinox/launcher}/TestLauncherConstants.java | 2 +- .../src/test/java/LauncherTests.java | 3 +-- 8 files changed, 14 insertions(+), 20 deletions(-) rename bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/{internal => }/launcher/Constants.java (97%) rename features/org.eclipse.equinox.executable.feature/library/org.eclipse.launcher.tests/src/{main => org/eclipse/equinox/launcher}/TestLauncherApp.java (97%) rename features/org.eclipse.equinox.executable.feature/library/org.eclipse.launcher.tests/src/{main => org/eclipse/equinox/launcher}/TestLauncherConstants.java (96%) diff --git a/bundles/org.eclipse.equinox.launcher/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.launcher/META-INF/MANIFEST.MF index bda318f306d..d7b8d590155 100644 --- a/bundles/org.eclipse.equinox.launcher/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.launcher/META-INF/MANIFEST.MF @@ -8,6 +8,5 @@ Bundle-Vendor: %providerName Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-Localization: launcher Export-Package: org.eclipse.core.launcher;x-internal:=true, - org.eclipse.equinox.internal.launcher;x-internal:=true, org.eclipse.equinox.launcher;x-internal:=true Automatic-Module-Name: org.eclipse.equinox.launcher diff --git a/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/internal/launcher/Constants.java b/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Constants.java similarity index 97% rename from bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/internal/launcher/Constants.java rename to bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Constants.java index 5544c822bf2..a5be5611dee 100644 --- a/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/internal/launcher/Constants.java +++ b/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Constants.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 IBM Corporation and others. + * Copyright (c) 2006, 2024 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -11,12 +11,12 @@ * Contributors: * Andrew Niefer - IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.equinox.internal.launcher; +package org.eclipse.equinox.launcher; /** * @author aniefer */ -public class Constants { +class Constants { public static final String INTERNAL_AMD64 = "amd64"; //$NON-NLS-1$ public static final String INTERNAL_OS_SUNOS = "SunOS"; //$NON-NLS-1$ public static final String INTERNAL_OS_LINUX = "Linux"; //$NON-NLS-1$ diff --git a/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/JNIBridge.java b/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/JNIBridge.java index 9eba8fd37e2..724249e24b5 100644 --- a/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/JNIBridge.java +++ b/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/JNIBridge.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2015 IBM Corporation and others. + * Copyright (c) 2006, 2024 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -23,8 +23,7 @@ * @noextend This class is not intended to be subclassed by clients. * @noinstantiate This class is not intended to be instantiated by clients. */ -public class JNIBridge { - //TODO: This class should not be public +class JNIBridge { private native void _set_exit_data(String sharedId, String data); private native void _set_launcher_info(String launcher, String name); diff --git a/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java b/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java index 8c51b9eb231..680bde24171 100644 --- a/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java +++ b/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2018 IBM Corporation and others. + * Copyright (c) 2000, 2024 IBM Corporation and others. * * This program and the accompanying materials * are made available under the terms of the Eclipse Public License 2.0 @@ -59,8 +59,6 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; -import org.eclipse.equinox.internal.launcher.Constants; - /** * The launcher for Eclipse. * diff --git a/features/org.eclipse.equinox.executable.feature/library/org.eclipse.launcher.tests/pom.xml b/features/org.eclipse.equinox.executable.feature/library/org.eclipse.launcher.tests/pom.xml index 1d7aa527df1..d58f6a61579 100644 --- a/features/org.eclipse.equinox.executable.feature/library/org.eclipse.launcher.tests/pom.xml +++ b/features/org.eclipse.equinox.executable.feature/library/org.eclipse.launcher.tests/pom.xml @@ -37,7 +37,7 @@ - main.TestLauncherApp + org.eclipse.equinox.launcher.TestLauncherApp diff --git a/features/org.eclipse.equinox.executable.feature/library/org.eclipse.launcher.tests/src/main/TestLauncherApp.java b/features/org.eclipse.equinox.executable.feature/library/org.eclipse.launcher.tests/src/org/eclipse/equinox/launcher/TestLauncherApp.java similarity index 97% rename from features/org.eclipse.equinox.executable.feature/library/org.eclipse.launcher.tests/src/main/TestLauncherApp.java rename to features/org.eclipse.equinox.executable.feature/library/org.eclipse.launcher.tests/src/org/eclipse/equinox/launcher/TestLauncherApp.java index 0e868cd21a1..4619d4d73c2 100644 --- a/features/org.eclipse.equinox.executable.feature/library/org.eclipse.launcher.tests/src/main/TestLauncherApp.java +++ b/features/org.eclipse.equinox.executable.feature/library/org.eclipse.launcher.tests/src/org/eclipse/equinox/launcher/TestLauncherApp.java @@ -11,7 +11,7 @@ * Contributors: * Umair Sair - initial API and implementation *******************************************************************************/ -package main; +package org.eclipse.equinox.launcher; import java.io.BufferedReader; import java.io.DataOutputStream; @@ -21,8 +21,6 @@ import java.util.ArrayList; import java.util.List; -import org.eclipse.equinox.launcher.JNIBridge; - /** * Dummy test application used for eclipse launcher testing. JUnit tests * launches the eclipse launcher with startup application pointing to the jar file @@ -31,11 +29,11 @@ * port and accepts following queries * - -args - returns the arguments passed to this application. Test verify if the * arguments are passed to application correctly by the launcher. - * + * * And accepts following information * - -exitdata - The exit data this application should set before exiting * - -exitcode - The exit code with which this application should exit - * + * * @author umairsair * */ @@ -98,8 +96,9 @@ private static void communicateToServer() throws Exception { out.flush(); } else if (TestLauncherConstants.EXITDATA_PARAMETER.equals(line)) { while ((line = in.readLine()) != null) { - if (TestLauncherConstants.MULTILINE_ARG_VALUE_TERMINATOR.equals(line)) + if (TestLauncherConstants.MULTILINE_ARG_VALUE_TERMINATOR.equals(line)) { break; + } exitData.add(line); } } else if (TestLauncherConstants.EXITCODE_PARAMETER.equals(line)) { diff --git a/features/org.eclipse.equinox.executable.feature/library/org.eclipse.launcher.tests/src/main/TestLauncherConstants.java b/features/org.eclipse.equinox.executable.feature/library/org.eclipse.launcher.tests/src/org/eclipse/equinox/launcher/TestLauncherConstants.java similarity index 96% rename from features/org.eclipse.equinox.executable.feature/library/org.eclipse.launcher.tests/src/main/TestLauncherConstants.java rename to features/org.eclipse.equinox.executable.feature/library/org.eclipse.launcher.tests/src/org/eclipse/equinox/launcher/TestLauncherConstants.java index 5bd1e0bed41..ac87e42833e 100644 --- a/features/org.eclipse.equinox.executable.feature/library/org.eclipse.launcher.tests/src/main/TestLauncherConstants.java +++ b/features/org.eclipse.equinox.executable.feature/library/org.eclipse.launcher.tests/src/org/eclipse/equinox/launcher/TestLauncherConstants.java @@ -11,7 +11,7 @@ * Contributors: * Umair Sair - initial API and implementation *******************************************************************************/ -package main; +package org.eclipse.equinox.launcher; public interface TestLauncherConstants { public static final String ARGS_PARAMETER = "-args"; //$NON-NLS-1$ diff --git a/features/org.eclipse.equinox.executable.feature/library/org.eclipse.launcher.tests/src/test/java/LauncherTests.java b/features/org.eclipse.equinox.executable.feature/library/org.eclipse.launcher.tests/src/test/java/LauncherTests.java index 702aaf120ec..859eb91b76e 100644 --- a/features/org.eclipse.equinox.executable.feature/library/org.eclipse.launcher.tests/src/test/java/LauncherTests.java +++ b/features/org.eclipse.equinox.executable.feature/library/org.eclipse.launcher.tests/src/test/java/LauncherTests.java @@ -32,12 +32,11 @@ import java.util.List; import java.util.concurrent.TimeUnit; +import org.eclipse.equinox.launcher.TestLauncherConstants; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import main.TestLauncherConstants; - public class LauncherTests { private static final String ECLIPSE_INI_PATH_KEY = "ECLIPSE_INI_PATH"; // eclipse ini file name is relative to eclipse binary. e.g., in mac, it is ../Eclipse/eclipse.ini