diff --git a/bundles/org.eclipse.equinox.api/.classpath b/bundles/org.eclipse.equinox.api/.classpath new file mode 100644 index 00000000000..81fe078c20c --- /dev/null +++ b/bundles/org.eclipse.equinox.api/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/bundles/org.eclipse.equinox.api/.project b/bundles/org.eclipse.equinox.api/.project new file mode 100644 index 00000000000..f2407e76cbc --- /dev/null +++ b/bundles/org.eclipse.equinox.api/.project @@ -0,0 +1,28 @@ + + + org.eclipse.equinox.api + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/bundles/org.eclipse.equinox.api/.settings/org.eclipse.core.resources.prefs b/bundles/org.eclipse.equinox.api/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 00000000000..99f26c0203a --- /dev/null +++ b/bundles/org.eclipse.equinox.api/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/bundles/org.eclipse.equinox.api/.settings/org.eclipse.jdt.core.prefs b/bundles/org.eclipse.equinox.api/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..62ef3488cc0 --- /dev/null +++ b/bundles/org.eclipse.equinox.api/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,9 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/bundles/org.eclipse.equinox.api/.settings/org.eclipse.pde.core.prefs b/bundles/org.eclipse.equinox.api/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 00000000000..e8ff8be0bab --- /dev/null +++ b/bundles/org.eclipse.equinox.api/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +pluginProject.equinox=false +pluginProject.extensions=false +resolve.requirebundle=false diff --git a/bundles/org.eclipse.equinox.api/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.api/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..367f2d32c34 --- /dev/null +++ b/bundles/org.eclipse.equinox.api/META-INF/MANIFEST.MF @@ -0,0 +1,17 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.eclipse.equinox.api +Bundle-Version: 1.0.0.qualifier +Export-Package: org.eclipse.core.runtime;version="3.7.0" +Automatic-Module-Name: org.eclipse.equinox.api +Bundle-RequiredExecutionEnvironment: JavaSE-17 +Bundle-ActivationPolicy: lazy +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Import-Package: org.eclipse.osgi.service.debug;version="[1.2.0,2.0.0)", + org.eclipse.osgi.service.urlconversion;version="[1.0.0,2.0.0)", + org.eclipse.osgi.util;version="[1.2.0,2.0.0)", + org.osgi.framework;version="[1.10.0,2.0.0)", + org.osgi.service.packageadmin;version="[1.2.0,2.0.0)", + org.osgi.util.tracker;version="[1.5.0,2.0.0)" diff --git a/bundles/org.eclipse.equinox.api/about.html b/bundles/org.eclipse.equinox.api/about.html new file mode 100644 index 00000000000..142e0aeda64 --- /dev/null +++ b/bundles/org.eclipse.equinox.api/about.html @@ -0,0 +1,68 @@ + + + + +About + + +

About This Content

+ +

November 30, 2017

+

License

+ +

+ The Eclipse Foundation makes available all content in this plug-in + ("Content"). Unless otherwise indicated below, the Content + is provided to you under the terms and conditions of the Eclipse + Public License Version 2.0 ("EPL"). A copy of the EPL is + available at http://www.eclipse.org/legal/epl-2.0. + For purposes of the EPL, "Program" will mean the Content. +

+ +

+ If you did not receive this Content directly from the Eclipse + Foundation, the Content is being redistributed by another party + ("Redistributor") and different terms and conditions may + apply to your use of any object code in the Content. Check the + Redistributor's license that was provided with the Content. If no such + license exists, contact the Redistributor. Unless otherwise indicated + below, the terms and conditions of the EPL still apply to any source + code in the Content and such source code may be obtained at http://www.eclipse.org. +

+ +

Third Party Content

+ +

The Content includes items that have been sourced from third parties as set out below. If you +did not receive this Content directly from the Eclipse Foundation, the following is provided +for informational purposes only, and you should look to the Redistributor’s license for +terms and conditions of use.

+ +

Jakarta Commons Collections

+

The plug-in includes software developed by The Apache Software Foundation as part of the Jakarta Commons Collections project.

+ +

The Jakarta Commons Collections binary code can be found in the plug-in JAR in the following files:

+ + + +

The Jakarta Commons Collections source code can be found in src.zip in the following files:

+ + + +

Your use of the Jakarta Commons Collections code is subject to the terms and conditions of the Apache License, Version 2.0. A copy of the license is contained +in the file LICENSE-2.0.txt and is also available at http://www.apache.org/licenses/LICENSE-2.0.html.

+ +

The Apache attribution notice file NOTICE.txt is included with the Content in accordance with 4d of the Apache License, Version 2.0 + +

The names "Jakarta" and "Apache Software Foundation" must not be used to endorse or promote products derived from this +software without prior written permission. For written permission, please contact apache@apache.org.

+ +Java and all Java-based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. + + + diff --git a/bundles/org.eclipse.equinox.api/about_files/LICENSE-2.0.txt b/bundles/org.eclipse.equinox.api/about_files/LICENSE-2.0.txt new file mode 100644 index 00000000000..d6456956733 --- /dev/null +++ b/bundles/org.eclipse.equinox.api/about_files/LICENSE-2.0.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/bundles/org.eclipse.equinox.api/about_files/NOTICE.txt b/bundles/org.eclipse.equinox.api/about_files/NOTICE.txt new file mode 100644 index 00000000000..3f59805ce43 --- /dev/null +++ b/bundles/org.eclipse.equinox.api/about_files/NOTICE.txt @@ -0,0 +1,2 @@ +This product includes software developed by +The Apache Software Foundation (http://www.apache.org/). diff --git a/bundles/org.eclipse.equinox.api/build.properties b/bundles/org.eclipse.equinox.api/build.properties new file mode 100644 index 00000000000..70877deb46f --- /dev/null +++ b/bundles/org.eclipse.equinox.api/build.properties @@ -0,0 +1,6 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.properties +pom.model.property.tycho.baseline.skip=false \ No newline at end of file diff --git a/bundles/org.eclipse.equinox.api/forceQualifierUpdate.txt b/bundles/org.eclipse.equinox.api/forceQualifierUpdate.txt new file mode 100644 index 00000000000..2bf05bb79e9 --- /dev/null +++ b/bundles/org.eclipse.equinox.api/forceQualifierUpdate.txt @@ -0,0 +1,8 @@ +# To force a version qualifier update add the bug here +Bug 403352 - Update all parent versions to match our build stream +Bug 462431 - New certificate conflict +Bug 531640 - New certificate conflict +Bug 527899 [9] Implement JEP 280: Indify String Concatenation #1139 +https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/issues/1659 +https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/issues/1923 +https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/issues/2044 \ No newline at end of file diff --git a/bundles/org.eclipse.equinox.api/plugin.properties b/bundles/org.eclipse.equinox.api/plugin.properties new file mode 100644 index 00000000000..d65cd0bae06 --- /dev/null +++ b/bundles/org.eclipse.equinox.api/plugin.properties @@ -0,0 +1,15 @@ +############################################################################### +# Copyright (c) 2005, 2009 IBM Corporation and others. +# +# This program and the accompanying materials +# are made available under the terms of the Eclipse Public License 2.0 +# which accompanies this distribution, and is available at +# https://www.eclipse.org/legal/epl-2.0/ +# +# SPDX-License-Identifier: EPL-2.0 +# +# Contributors: +# IBM Corporation - initial API and implementation +############################################################################### +pluginName = Equinox API +providerName = Eclipse.org - Equinox diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/AdapterTypes.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/AdapterTypes.java similarity index 100% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/AdapterTypes.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/AdapterTypes.java diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Adapters.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/Adapters.java similarity index 93% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Adapters.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/Adapters.java index 9bccf2e021f..3bc1afc8fc5 100644 --- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Adapters.java +++ b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/Adapters.java @@ -17,7 +17,9 @@ import java.util.Objects; import java.util.Optional; -import org.eclipse.core.internal.runtime.*; + +import org.eclipse.equinox.api.internal.APISupport; +import org.eclipse.equinox.api.internal.LocalizationUtils; import org.eclipse.osgi.util.NLS; /** @@ -136,8 +138,8 @@ public static Optional of(Object sourceObject, Class adapter) { try { return Optional.ofNullable(adapt(sourceObject, adapter)); } catch (AssertionFailedException e) { - RuntimeLog.log(Status.error( - NLS.bind(CommonMessages.adapters_internal_error_of, new Object[] { + APISupport.log(Status.error( + NLS.bind(LocalizationUtils.safeLocalize("adapters_internal_error_of"), new Object[] { sourceObject.getClass().getName(), adapter.getClass().getName(), e.getLocalizedMessage() }), e)); return Optional.empty(); @@ -147,9 +149,9 @@ public static Optional of(Object sourceObject, Class adapter) { private static Object queryAdapterManager(Object sourceObject, String adapterId, boolean allowActivation) { Object result; if (allowActivation) { - result = AdapterManager.getDefault().loadAdapter(sourceObject, adapterId); + result = APISupport.getAdapterManager().loadAdapter(sourceObject, adapterId); } else { - result = AdapterManager.getDefault().getAdapter(sourceObject, adapterId); + result = APISupport.getAdapterManager().getAdapter(sourceObject, adapterId); } return result; } diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Assert.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/Assert.java similarity index 100% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Assert.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/Assert.java diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/AssertionFailedException.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/AssertionFailedException.java similarity index 100% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/AssertionFailedException.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/AssertionFailedException.java diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/CoreException.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/CoreException.java similarity index 98% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/CoreException.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/CoreException.java index e55a7066994..e1e806a0b0c 100644 --- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/CoreException.java +++ b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/CoreException.java @@ -15,7 +15,8 @@ import java.io.PrintStream; import java.io.PrintWriter; -import org.eclipse.core.internal.runtime.PrintStackUtil; + +import org.eclipse.equinox.api.internal.PrintStackUtil; /** * A checked exception representing a failure. diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/FileLocator.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/FileLocator.java similarity index 97% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/FileLocator.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/FileLocator.java index dbea0ba292e..40693656c86 100644 --- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/FileLocator.java +++ b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/FileLocator.java @@ -16,12 +16,15 @@ *******************************************************************************/ package org.eclipse.core.runtime; -import java.io.*; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; import java.net.URL; import java.util.Map; import java.util.Optional; -import org.eclipse.core.internal.runtime.Activator; -import org.eclipse.core.internal.runtime.FindSupport; + +import org.eclipse.equinox.api.internal.APISupport; +import org.eclipse.equinox.api.internal.FindSupport; import org.eclipse.osgi.service.urlconversion.URLConverter; import org.osgi.framework.Bundle; @@ -273,7 +276,7 @@ public static InputStream openStream(Bundle bundle, IPath file, boolean substitu * @throws IOException if an error occurs during the conversion */ public static URL toFileURL(URL url) throws IOException { - URLConverter converter = Activator.getURLConverter(url); + URLConverter converter = APISupport.getURLConverter(url); return converter == null ? url : converter.toFileURL(url); } @@ -297,7 +300,7 @@ public static URL toFileURL(URL url) throws IOException { * @throws IOException if an error occurs during the resolution */ public static URL resolve(URL url) throws IOException { - URLConverter converter = Activator.getURLConverter(url); + URLConverter converter = APISupport.getURLConverter(url); return converter == null ? url : converter.resolve(url); } diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdaptable.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IAdaptable.java similarity index 100% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdaptable.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IAdaptable.java diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdapterFactory.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IAdapterFactory.java similarity index 100% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdapterFactory.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IAdapterFactory.java diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdapterManager.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IAdapterManager.java similarity index 100% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IAdapterManager.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IAdapterManager.java diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IBundleGroup.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IBundleGroup.java similarity index 100% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IBundleGroup.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IBundleGroup.java diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IBundleGroupProvider.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IBundleGroupProvider.java similarity index 100% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IBundleGroupProvider.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IBundleGroupProvider.java diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IConfigurationElement.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IConfigurationElement.java similarity index 100% rename from bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IConfigurationElement.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IConfigurationElement.java diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IContributor.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IContributor.java similarity index 100% rename from bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IContributor.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IContributor.java diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ICoreRunnable.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/ICoreRunnable.java similarity index 100% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ICoreRunnable.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/ICoreRunnable.java diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExecutableExtension.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IExecutableExtension.java similarity index 100% rename from bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExecutableExtension.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IExecutableExtension.java diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExecutableExtensionFactory.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IExecutableExtensionFactory.java similarity index 100% rename from bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExecutableExtensionFactory.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IExecutableExtensionFactory.java diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExtension.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IExtension.java similarity index 100% rename from bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExtension.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IExtension.java diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExtensionDelta.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IExtensionDelta.java similarity index 100% rename from bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExtensionDelta.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IExtensionDelta.java diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExtensionPoint.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IExtensionPoint.java similarity index 100% rename from bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExtensionPoint.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IExtensionPoint.java diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExtensionRegistry.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IExtensionRegistry.java similarity index 100% rename from bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IExtensionRegistry.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IExtensionRegistry.java diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ILogListener.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/ILogListener.java similarity index 100% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ILogListener.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/ILogListener.java diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IPath.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IPath.java similarity index 100% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IPath.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IPath.java diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitor.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IProgressMonitor.java similarity index 100% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitor.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IProgressMonitor.java diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitorWithBlocking.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IProgressMonitorWithBlocking.java similarity index 100% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IProgressMonitorWithBlocking.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IProgressMonitorWithBlocking.java diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IRegistryChangeEvent.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IRegistryChangeEvent.java similarity index 100% rename from bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IRegistryChangeEvent.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IRegistryChangeEvent.java diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IRegistryChangeListener.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IRegistryChangeListener.java similarity index 100% rename from bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IRegistryChangeListener.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IRegistryChangeListener.java diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IRegistryEventListener.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IRegistryEventListener.java similarity index 100% rename from bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/IRegistryEventListener.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IRegistryEventListener.java diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ISafeRunnable.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/ISafeRunnable.java similarity index 100% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ISafeRunnable.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/ISafeRunnable.java diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ISafeRunnableWithResult.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/ISafeRunnableWithResult.java similarity index 100% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ISafeRunnableWithResult.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/ISafeRunnableWithResult.java diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IStatus.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IStatus.java similarity index 100% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/IStatus.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/IStatus.java diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/InvalidRegistryObjectException.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/InvalidRegistryObjectException.java similarity index 100% rename from bundles/org.eclipse.equinox.registry/src/org/eclipse/core/runtime/InvalidRegistryObjectException.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/InvalidRegistryObjectException.java diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ListenerList.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/ListenerList.java similarity index 100% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ListenerList.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/ListenerList.java diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/MultiStatus.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/MultiStatus.java similarity index 100% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/MultiStatus.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/MultiStatus.java diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/NullProgressMonitor.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/NullProgressMonitor.java similarity index 100% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/NullProgressMonitor.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/NullProgressMonitor.java diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/OperationCanceledException.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/OperationCanceledException.java similarity index 100% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/OperationCanceledException.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/OperationCanceledException.java diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Path.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/Path.java similarity index 100% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Path.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/Path.java diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/PlatformObject.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/PlatformObject.java similarity index 95% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/PlatformObject.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/PlatformObject.java index cb6ed7c0917..cdc0b665559 100644 --- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/PlatformObject.java +++ b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/PlatformObject.java @@ -14,7 +14,7 @@ *******************************************************************************/ package org.eclipse.core.runtime; -import org.eclipse.core.internal.runtime.AdapterManager; +import org.eclipse.equinox.api.internal.APISupport; /** * An abstract superclass implementing the IAdaptable interface. @@ -70,6 +70,6 @@ public PlatformObject() { */ @Override public T getAdapter(Class adapter) { - return AdapterManager.getDefault().getAdapter(this, adapter); + return APISupport.getAdapterManager().getAdapter(this, adapter); } } diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ProgressMonitorWrapper.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/ProgressMonitorWrapper.java similarity index 100% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ProgressMonitorWrapper.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/ProgressMonitorWrapper.java diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/QualifiedName.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/QualifiedName.java similarity index 100% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/QualifiedName.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/QualifiedName.java diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SafeRunner.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/SafeRunner.java similarity index 81% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SafeRunner.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/SafeRunner.java index 9d87716e939..a8d3afb7768 100644 --- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SafeRunner.java +++ b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/SafeRunner.java @@ -13,7 +13,8 @@ *******************************************************************************/ package org.eclipse.core.runtime; -import org.eclipse.core.internal.runtime.*; +import org.eclipse.equinox.api.internal.APISupport; +import org.eclipse.equinox.api.internal.LocalizationUtils; import org.eclipse.osgi.util.NLS; /** @@ -83,36 +84,25 @@ private static void handleException(ISafeRunnable code, Throwable exception) { if (!(exception instanceof OperationCanceledException)) { String pluginId = getBundleIdOfSafeRunnable(code); IStatus status = convertToStatus(exception, pluginId); - makeSureUserSeesException(exception, status); + APISupport.log(status); } code.handleException(exception); } - private static void makeSureUserSeesException(Throwable exception, IStatus status) { - if (RuntimeLog.isEmpty()) { - exception.printStackTrace(); - } else { - RuntimeLog.log(status); - } - } - private static String getBundleIdOfSafeRunnable(ISafeRunnable code) { - Activator activator = Activator.getDefault(); - String pluginId = null; - if (activator != null) - pluginId = activator.getBundleId(code); + String pluginId = APISupport.getBundleId(code); if (pluginId == null) - return IRuntimeConstants.PI_COMMON; + return APISupport.PI_COMMON; return pluginId; } private static IStatus convertToStatus(Throwable exception, String pluginId) { - String message = NLS.bind(CommonMessages.meta_pluginProblems, pluginId); + String message = NLS.bind(LocalizationUtils.safeLocalize("meta_pluginProblems"), pluginId); if (exception instanceof CoreException) { - MultiStatus status = new MultiStatus(pluginId, IRuntimeConstants.PLUGIN_ERROR, message, exception); + MultiStatus status = new MultiStatus(pluginId, APISupport.PLUGIN_ERROR, message, exception); status.merge(((CoreException) exception).getStatus()); return status; } - return new Status(IStatus.ERROR, pluginId, IRuntimeConstants.PLUGIN_ERROR, message, exception); + return new Status(IStatus.ERROR, pluginId, APISupport.PLUGIN_ERROR, message, exception); } } diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ServiceCaller.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/ServiceCaller.java similarity index 100% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/ServiceCaller.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/ServiceCaller.java diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SlicedProgressMonitor.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/SlicedProgressMonitor.java similarity index 100% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SlicedProgressMonitor.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/SlicedProgressMonitor.java diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Status.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/Status.java similarity index 99% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Status.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/Status.java index d3117eb6eb0..8e3c16ab657 100644 --- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/Status.java +++ b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/Status.java @@ -15,7 +15,8 @@ package org.eclipse.core.runtime; import java.util.Optional; -import org.eclipse.core.internal.runtime.LocalizationUtils; + +import org.eclipse.equinox.api.internal.LocalizationUtils; import org.osgi.framework.FrameworkUtil; /** diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SubMonitor.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/SubMonitor.java similarity index 99% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SubMonitor.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/SubMonitor.java index 7cd1e6960d4..8039f18e03e 100644 --- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SubMonitor.java +++ b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/SubMonitor.java @@ -22,8 +22,9 @@ import java.util.HashSet; import java.util.Set; -import org.eclipse.core.internal.runtime.RuntimeLog; -import org.eclipse.core.internal.runtime.TracingOptions; + +import org.eclipse.equinox.api.internal.APISupport; +import org.eclipse.equinox.api.internal.TracingOptions; /** *

@@ -1184,7 +1185,7 @@ private static void logProblem(String message) { return; } } - RuntimeLog.log(new Status(IStatus.WARNING, "org.eclipse.core.runtime", message, new Throwable())); //$NON-NLS-1$ + APISupport.log(new Status(IStatus.WARNING, "org.eclipse.core.runtime", message, new Throwable())); //$NON-NLS-1$ } @Override diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SubProgressMonitor.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/SubProgressMonitor.java similarity index 100% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/SubProgressMonitor.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/SubProgressMonitor.java diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/URIUtil.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/URIUtil.java similarity index 100% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/runtime/URIUtil.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/core/runtime/URIUtil.java diff --git a/bundles/org.eclipse.equinox.api/src/org/eclipse/equinox/api/internal/APISupport.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/equinox/api/internal/APISupport.java new file mode 100644 index 00000000000..6c932652c79 --- /dev/null +++ b/bundles/org.eclipse.equinox.api/src/org/eclipse/equinox/api/internal/APISupport.java @@ -0,0 +1,186 @@ +/******************************************************************************* + * Copyright (c) 2024 Christoph Läubrich and others. + * + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Christoph Läubrich - initial API and implementation + * Methods migrated from org.eclipse.core.internal.runtime.Activator contributed by: + * IBM Corporation - initial API and implementation + * Sergey Prigogin (Google) - use parameterized types (bug 442021) + * Christoph Laeubrich - Bug 567344 - Support registration of IAdapterFactory as OSGi Service + *******************************************************************************/ +package org.eclipse.equinox.api.internal; + +import java.lang.reflect.Method; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +import org.eclipse.core.runtime.IAdapterManager; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.osgi.service.debug.DebugOptions; +import org.eclipse.osgi.service.debug.DebugOptionsListener; +import org.eclipse.osgi.service.urlconversion.URLConverter; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.Filter; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.InvalidSyntaxException; +import org.osgi.service.packageadmin.PackageAdmin; +import org.osgi.util.tracker.ServiceTracker; + +/** + * API Bundle activator that is used to provide API service support and backward + * compatibility + */ +public class APISupport implements BundleActivator { + + static final String PI_RUNTIME = "org.eclipse.core.runtime"; //$NON-NLS-1$ + public static final String PI_COMMON = "org.eclipse.equinox.common"; //$NON-NLS-1$ + public static final int PLUGIN_ERROR = 2; + + private static volatile ServiceTracker adapterMangerTracker; + private static volatile BundleContext bundleContext; + private static final Map> urlTrackers = new HashMap<>(); + static volatile Bundle equinoxCommonBundle; + private static ServiceTracker adminTracker; + + @Override + public void start(BundleContext context) throws Exception { + context.registerService(DebugOptionsListener.class, TracingOptions.DEBUG_OPTIONS_LISTENER, + FrameworkUtil.asDictionary(Map.of(DebugOptions.LISTENER_SYMBOLICNAME, PI_COMMON))); + APISupport.bundleContext = context; + for (Bundle bundle : context.getBundles()) { + if (PI_COMMON.equals(bundle.getSymbolicName())) { + // this emulates the previous behavior that when loading any class now in the + // API bundle has activated equinox.common bundle + bundle.start(); + equinoxCommonBundle = bundle; + } + } + } + + @Override + public void stop(BundleContext context) throws Exception { + bundleContext = null; + equinoxCommonBundle = null; + } + + /** + * Returns a property either from the bundle or the system properties + * + * @param property the property to fetch + * @return the value of the property + */ + public static String getProperty(String property) { + BundleContext ctx = bundleContext; + if (ctx != null) { + return ctx.getProperty(property); + } + return System.getProperty(property); + } + + /** + * @return the IAdapterManager service + */ + public static IAdapterManager getAdapterManager() { + BundleContext context = Objects.requireNonNull(bundleContext, "bundle not started!"); + synchronized (APISupport.class) { + if (adapterMangerTracker == null) { + adapterMangerTracker = new ServiceTracker(context, + IAdapterManager.class, null); + adapterMangerTracker.open(); + } + } + return Objects.requireNonNull(adapterMangerTracker.getService(), + "No IAdapterManager service found in the OSGi registry!"); + } + + /** + * Log the given status to the runtime log + * + * @param status the status to log + */ + public static void log(IStatus status) { + if (equinoxCommonBundle != null) { + try { + Class clazz = equinoxCommonBundle.loadClass("org.eclipse.core.internal.runtime.RuntimeLog"); + Method method = clazz.getMethod("log", IStatus.class); + method.invoke(null, status); + return; + } catch (Exception e) { + } + } + System.out.println(status); + } + + /* + * Return the URL Converter for the given URL. Return null if we can't find one. + */ + public static URLConverter getURLConverter(URL url) { + BundleContext ctx = bundleContext; + if (url == null || ctx == null) { + return null; + } + String protocol = url.getProtocol(); + synchronized (urlTrackers) { + ServiceTracker tracker = urlTrackers.get(protocol); + if (tracker == null) { + // get the right service based on the protocol + String FILTER_PREFIX = "(&(objectClass=" + URLConverter.class.getName() + ")(protocol="; //$NON-NLS-1$ //$NON-NLS-2$ + String FILTER_POSTFIX = "))"; //$NON-NLS-1$ + Filter filter = null; + try { + filter = ctx.createFilter(FILTER_PREFIX + protocol + FILTER_POSTFIX); + } catch (InvalidSyntaxException e) { + return null; + } + tracker = new ServiceTracker<>(ctx, filter, null); + tracker.open(); + // cache it in the registry + urlTrackers.put(protocol, tracker); + } + return tracker.getService(); + } + } + + public static Bundle[] getFragments(Bundle host) { + BundleContext ctx = bundleContext; + if (ctx == null) { + return new Bundle[0]; + } + synchronized (APISupport.class) { + if (adminTracker == null) { + adminTracker = new ServiceTracker<>(ctx, PackageAdmin.class, null); + adminTracker.open(); + } + } + PackageAdmin service = adminTracker.getService(); + if (service == null) { + return new Bundle[0]; + } + return service.getFragments(host); + } + + /** + * Returns the bundle id of the bundle that contains the provided object, or + * null if the bundle could not be determined. + */ + public static String getBundleId(Object object) { + if (object == null) + return null; + Bundle source = FrameworkUtil.getBundle(object.getClass()); + if (source != null && source.getSymbolicName() != null) + return source.getSymbolicName(); + return null; + } + +} diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/FindSupport.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/equinox/api/internal/FindSupport.java similarity index 87% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/FindSupport.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/equinox/api/internal/FindSupport.java index b8d4290ca33..0a1c81adaac 100644 --- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/FindSupport.java +++ b/bundles/org.eclipse.equinox.api/src/org/eclipse/equinox/api/internal/FindSupport.java @@ -12,14 +12,19 @@ * IBM Corporation - initial API and implementation * Sergey Prigogin (Google) - use parameterized types (bug 442021) *******************************************************************************/ -package org.eclipse.core.internal.runtime; +package org.eclipse.equinox.api.internal; import java.io.IOException; import java.io.InputStream; +import java.lang.reflect.Method; import java.net.URL; import java.util.ArrayList; import java.util.Map; -import org.eclipse.core.runtime.*; + +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; import org.osgi.framework.Bundle; // This class provides implements the find* methods exposed on Platform. @@ -32,8 +37,7 @@ public class FindSupport { public static final String PROP_WS = "osgi.ws"; //$NON-NLS-1$ public static final String PROP_ARCH = "osgi.arch"; //$NON-NLS-1$ - private static String[] NL_JAR_VARIANTS = buildNLVariants( - Activator.getContext() == null ? System.getProperty(PROP_NL) : Activator.getContext().getProperty(PROP_NL)); + private static final String[] NL_JAR_VARIANTS = buildNLVariants(APISupport.getProperty(PROP_NL)); private static String[] buildNLVariants(String nl) { ArrayList result = new ArrayList<>(); @@ -53,30 +57,30 @@ private static String[] buildNLVariants(String nl) { return result.toArray(new String[result.size()]); } - /** - * See doc on {@link FileLocator#find(Bundle, IPath, Map)} - */ +// /** +// * See doc on {@link FileLocator#find(Bundle, IPath, Map)} +// */ public static URL find(Bundle bundle, IPath path) { return find(bundle, path, null); } - /** - * See doc on {@link FileLocator#find(Bundle, IPath, Map)} - */ +// /** +// * See doc on {@link FileLocator#find(Bundle, IPath, Map)} +// */ public static URL find(Bundle b, IPath path, Map override) { return find(b, path, override, null); } - /** - * See doc on {@link FileLocator#findEntries(Bundle, IPath)} - */ +// /** +// * See doc on {@link FileLocator#findEntries(Bundle, IPath)} +// */ public static URL[] findEntries(Bundle bundle, IPath path) { return findEntries(bundle, path, null); } - /** - * See doc on {@link FileLocator#findEntries(Bundle, IPath, Map)} - */ +// /** +// * See doc on {@link FileLocator#findEntries(Bundle, IPath, Map)} +// */ public static URL[] findEntries(Bundle bundle, IPath path, Map override) { ArrayList results = new ArrayList<>(1); find(bundle, path, override, results); @@ -134,7 +138,7 @@ private static URL findOS(Bundle b, IPath path, Map override, Ar } if (os == null) // use default - os = Activator.getContext().getProperty(PROP_OS); + os = APISupport.getProperty(PROP_OS); if (os.length() == 0) return null; @@ -149,7 +153,7 @@ private static URL findOS(Bundle b, IPath path, Map override, Ar } if (osArch == null) // use default - osArch = Activator.getContext().getProperty(PROP_ARCH); + osArch = APISupport.getProperty(PROP_ARCH); if (osArch.length() == 0) return null; @@ -185,7 +189,7 @@ private static URL findWS(Bundle b, IPath path, Map override, Ar } if (ws == null) // use default - ws = Activator.getContext().getProperty(PROP_WS); + ws = APISupport.getProperty(PROP_WS); IPath filePath = IPath.fromOSString("ws").append(ws).append(path); //$NON-NLS-1$ // We know that there is only one segment to the ws path // e.g. ws/win32 @@ -243,10 +247,7 @@ private static URL findInPlugin(Bundle b, IPath filePath, ArrayList multipl } private static URL findInFragments(Bundle b, IPath filePath, ArrayList multiple) { - Activator activator = Activator.getDefault(); - if (activator == null) - return null; - Bundle[] fragments = activator.getFragments(b); + Bundle[] fragments = APISupport.getFragments(b); if (fragments == null) return null; @@ -264,9 +265,9 @@ private static URL findInFragments(Bundle b, IPath filePath, ArrayList mult return null; } - /** - * See doc on {@link FileLocator#openStream(Bundle, IPath, boolean)} - */ +// /** +// * See doc on {@link FileLocator#openStream(Bundle, IPath, boolean)} +// */ public static final InputStream openStream(Bundle bundle, IPath file, boolean substituteArgs) throws IOException { URL url = null; if (!substituteArgs) { @@ -293,9 +294,12 @@ public static URL find(URL url) { String spec = url.getFile().trim(); Object[] obj = null; try { - obj = PlatformURLPluginConnection.parse(spec, url); - } catch (IOException e) { - RuntimeLog.log(new Status(IStatus.ERROR, IRuntimeConstants.PI_RUNTIME, "Invalid input url:" + url, e)); //$NON-NLS-1$ + Class clz = APISupport.equinoxCommonBundle + .loadClass("org.eclipse.core.internal.runtime.PlatformURLPluginConnection"); + Method method = clz.getMethod("parse", String.class, URL.class); + obj = (Object[]) method.invoke(null, spec, url); + } catch (Exception e) { + APISupport.log(new Status(IStatus.ERROR, APISupport.PI_RUNTIME, "Can't parse input url:" + url, e)); //$NON-NLS-1$ return null; } Bundle bundle = (Bundle) obj[0]; diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/LocalizationUtils.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/equinox/api/internal/LocalizationUtils.java similarity index 72% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/LocalizationUtils.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/equinox/api/internal/LocalizationUtils.java index 85287fe63d0..9b9b83e151e 100644 --- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/LocalizationUtils.java +++ b/bundles/org.eclipse.equinox.api/src/org/eclipse/equinox/api/internal/LocalizationUtils.java @@ -12,10 +12,12 @@ * IBM Corporation - initial API and implementation * Sergey Prigogin (Google) - use parameterized types (bug 442021) *******************************************************************************/ -package org.eclipse.core.internal.runtime; +package org.eclipse.equinox.api.internal; import java.lang.reflect.Field; +import org.osgi.framework.Bundle; + /** * Helper methods related to string localization. * @@ -33,7 +35,7 @@ public class LocalizationUtils { */ static public String safeLocalize(String key) { try { - Class messageClass = Class.forName("org.eclipse.core.internal.runtime.CommonMessages"); //$NON-NLS-1$ + Class messageClass = getMessageClass(); // $NON-NLS-1$ if (messageClass == null) return key; Field field = messageClass.getDeclaredField(key); @@ -42,10 +44,18 @@ static public String safeLocalize(String key) { Object value = field.get(null); if (value instanceof String) return (String) value; - } catch (ClassNotFoundException | NoClassDefFoundError | SecurityException | NoSuchFieldException - | IllegalArgumentException | IllegalAccessException e) { + } catch (ClassNotFoundException | NoClassDefFoundError | NoSuchFieldException + | IllegalAccessException | RuntimeException e) { // eat exception and fall through } return key; } + + protected static Class getMessageClass() throws ClassNotFoundException { + Bundle bundle = APISupport.equinoxCommonBundle; + if (bundle != null) { + return bundle.loadClass("org.eclipse.core.internal.runtime.CommonMessages"); + } + return Class.forName("org.eclipse.core.internal.runtime.CommonMessages"); + } } diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PrintStackUtil.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/equinox/api/internal/PrintStackUtil.java similarity index 97% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PrintStackUtil.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/equinox/api/internal/PrintStackUtil.java index ce48f25a87a..299dd404232 100644 --- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/PrintStackUtil.java +++ b/bundles/org.eclipse.equinox.api/src/org/eclipse/equinox/api/internal/PrintStackUtil.java @@ -11,7 +11,7 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.core.internal.runtime; +package org.eclipse.equinox.api.internal; import java.io.PrintStream; import java.io.PrintWriter; diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/TracingOptions.java b/bundles/org.eclipse.equinox.api/src/org/eclipse/equinox/api/internal/TracingOptions.java similarity index 50% rename from bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/TracingOptions.java rename to bundles/org.eclipse.equinox.api/src/org/eclipse/equinox/api/internal/TracingOptions.java index 8603d120601..9568c6c81d7 100644 --- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/TracingOptions.java +++ b/bundles/org.eclipse.equinox.api/src/org/eclipse/equinox/api/internal/TracingOptions.java @@ -1,16 +1,16 @@ -package org.eclipse.core.internal.runtime; +package org.eclipse.equinox.api.internal; import org.eclipse.osgi.service.debug.DebugOptions; import org.eclipse.osgi.service.debug.DebugOptionsListener; public class TracingOptions { - public static DebugOptionsListener DEBUG_OPTIONS_LISTENER = new DebugOptionsListener() { + public static final DebugOptionsListener DEBUG_OPTIONS_LISTENER = new DebugOptionsListener() { @Override public void optionsChanged(DebugOptions options) { - debug = options.getBooleanOption(Activator.PLUGIN_ID + "/debug", false); //$NON-NLS-1$ + debug = options.getBooleanOption(APISupport.PI_COMMON + "/debug", false); //$NON-NLS-1$ debugProgressMonitors = debug - && options.getBooleanOption(Activator.PLUGIN_ID + "/progress_monitors", false); //$NON-NLS-1$ + && options.getBooleanOption(APISupport.PI_COMMON + "/progress_monitors", false); //$NON-NLS-1$ } }; diff --git a/bundles/org.eclipse.equinox.common/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.common/META-INF/MANIFEST.MF index 47c4a0c9639..4e7fa6f5b85 100644 --- a/bundles/org.eclipse.equinox.common/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.common/META-INF/MANIFEST.MF @@ -19,7 +19,8 @@ Export-Package: org.eclipse.core.internal.boot;x-friends:="org.eclipse.core.reso org.eclipse.equinox.events;version="1.0.0" Bundle-Vendor: %providerName Bundle-Activator: org.eclipse.core.internal.runtime.Activator -Require-Bundle: org.eclipse.osgi;bundle-version="[3.17.200,4.0.0)" +Require-Bundle: org.eclipse.osgi;bundle-version="[3.17.200,4.0.0)", + org.eclipse.equinox.api;bundle-version="1.0.0";visibility:=reexport Bundle-RequiredExecutionEnvironment: JavaSE-17 Bundle-ActivationPolicy: lazy Automatic-Module-Name: org.eclipse.equinox.common diff --git a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java index 45647f5175f..74d2904d37b 100644 --- a/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java +++ b/bundles/org.eclipse.equinox.common/src/org/eclipse/core/internal/runtime/Activator.java @@ -15,7 +15,6 @@ *******************************************************************************/ package org.eclipse.core.internal.runtime; -import java.net.URL; import java.util.*; import org.eclipse.core.internal.boot.PlatformURLBaseConnection; import org.eclipse.core.internal.boot.PlatformURLHandler; @@ -46,7 +45,6 @@ public class Activator implements BundleActivator { /** * Table to keep track of all the URL converter services. */ - private static final Map> urlTrackers = new HashMap<>(); private static BundleContext bundleContext; private static Activator singleton; private ServiceRegistration platformURLConverterService = null; @@ -89,10 +87,6 @@ public void start(BundleContext context) throws Exception { adapterManagerService = context.registerService(IAdapterManager.class, AdapterManager.getDefault(), null); installPlatformURLSupport(); installDataURLSupport(context); - Hashtable properties = new Hashtable<>(2); - properties.put(DebugOptions.LISTENER_SYMBOLICNAME, PLUGIN_ID); - debugRegistration = context.registerService(DebugOptionsListener.class, TracingOptions.DEBUG_OPTIONS_LISTENER, - properties); adapterFactoryTracker = new ServiceTracker<>(context, IAdapterFactory.class, new AdapterFactoryBridge(bundleContext)); adapterFactoryTracker.open(); @@ -235,7 +229,6 @@ public void stop(BundleContext context) throws Exception { if (adapterFactoryTracker != null) { adapterFactoryTracker.close(); } - closeURLTrackerServices(); if (platformURLConverterService != null) { platformURLConverterService.unregister(); platformURLConverterService = null; @@ -260,50 +253,6 @@ static BundleContext getContext() { return bundleContext; } - /* - * Let go of all the services that we acquired and kept track of. - */ - private static void closeURLTrackerServices() { - synchronized (urlTrackers) { - if (!urlTrackers.isEmpty()) { - for (ServiceTracker tracker : urlTrackers.values()) { - tracker.close(); - } - urlTrackers.clear(); - } - } - } - - /* - * Return the URL Converter for the given URL. Return null if we can't find one. - */ - public static URLConverter getURLConverter(URL url) { - BundleContext ctx = getContext(); - if (url == null || ctx == null) { - return null; - } - String protocol = url.getProtocol(); - synchronized (urlTrackers) { - ServiceTracker tracker = urlTrackers.get(protocol); - if (tracker == null) { - // get the right service based on the protocol - String FILTER_PREFIX = "(&(objectClass=" + URLConverter.class.getName() + ")(protocol="; //$NON-NLS-1$ //$NON-NLS-2$ - String FILTER_POSTFIX = "))"; //$NON-NLS-1$ - Filter filter = null; - try { - filter = ctx.createFilter(FILTER_PREFIX + protocol + FILTER_POSTFIX); - } catch (InvalidSyntaxException e) { - return null; - } - tracker = new ServiceTracker<>(getContext(), filter, null); - tracker.open(); - // cache it in the registry - urlTrackers.put(protocol, tracker); - } - return tracker.getService(); - } - } - /** * Register the platform URL support as a service to the URLHandler service */ diff --git a/bundles/org.eclipse.equinox.registry/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.registry/META-INF/MANIFEST.MF index e7ba987b09b..0a4f1207138 100644 --- a/bundles/org.eclipse.equinox.registry/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.equinox.registry/META-INF/MANIFEST.MF @@ -11,7 +11,7 @@ Export-Package: org.eclipse.core.internal.adapter;x-internal:=true, org.eclipse.core.runtime;registry=split;version="3.7.0";mandatory:=registry, org.eclipse.core.runtime.dynamichelpers;version="3.4.0", org.eclipse.core.runtime.spi;version="3.4.0" -Require-Bundle: org.eclipse.equinox.common;bundle-version="[3.15.100,4.0.0)" +Require-Bundle: org.eclipse.equinox.common;bundle-version="[3.15.100,4.0.0)", org.eclipse.equinox.api;bundle-version="1.0.0";visibility:=reexport Bundle-Vendor: %providerName Bundle-Activator: org.eclipse.core.internal.registry.osgi.Activator Import-Package: javax.xml.parsers, diff --git a/pom.xml b/pom.xml index 45163cb6bd7..e0703e11094 100644 --- a/pom.xml +++ b/pom.xml @@ -30,6 +30,7 @@ ../../../equinox.binaries require + true