diff --git a/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF b/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF index b0be23b6be1..d29180e65b5 100644 --- a/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF +++ b/org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF @@ -27,6 +27,5 @@ Import-Package: jakarta.annotation;version="[2.1.0,3.0.0)", org.eclipse.jdt.internal.compiler.apt.dispatch Bundle-RequiredExecutionEnvironment: JavaSE-17 Eclipse-BundleShape: dir -Bundle-Activator: org.eclipse.jdt.core.tests.compiler.Activator Bundle-ActivationPolicy: lazy Automatic-Module-Name: org.eclipse.jdt.core.tests.compiler diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/Activator.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/Activator.java deleted file mode 100644 index 45729f46ea7..00000000000 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/Activator.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2013 Stephan Herrmann 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: - * Stephan Herrmann - initial API and implementation - *******************************************************************************/ -package org.eclipse.jdt.core.tests.compiler; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Plugin; -import org.eclipse.core.runtime.Status; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; - -/** - * Make the PackageAdmin service accessible to tests. - * - * @deprecated uses deprecated class PackageAdmin. - */ -@SuppressWarnings({ "unchecked", "rawtypes" }) -public class Activator extends Plugin { - - private static final String PLUGIN_ID = "org.eclipse.jdt.core.tests.compiler"; - - static org.osgi.service.packageadmin.PackageAdmin packageAdmin = null; - - - public void start(BundleContext context) throws Exception { - - ServiceReference ref= context.getServiceReference(org.osgi.service.packageadmin.PackageAdmin.class.getName()); - if (ref!=null) - packageAdmin = (org.osgi.service.packageadmin.PackageAdmin)context.getService(ref); - else - getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, "Failed to load PackageAdmin service. Will not be able to access bundles org.eclipse.jdt.annotation.")); - } - - public void stop(BundleContext context) throws Exception { - // nothing - } - - public static org.osgi.service.packageadmin.PackageAdmin getPackageAdmin() { - return packageAdmin; - } - -} diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractNullAnnotationTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractNullAnnotationTest.java index a66a72c4f1a..f569ec24e79 100644 --- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractNullAnnotationTest.java +++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/AbstractNullAnnotationTest.java @@ -16,12 +16,14 @@ import java.io.File; import java.io.IOException; import java.net.URL; +import java.util.Arrays; import java.util.Map; import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.Platform; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; @SuppressWarnings({ "unchecked", "rawtypes" }) public abstract class AbstractNullAnnotationTest extends AbstractComparableTest { @@ -81,9 +83,6 @@ protected void setUp() throws Exception { setUpAnnotationLib(); } - /** - * @deprecated indirectly uses deprecated class PackageAdmin - */ protected void setUpAnnotationLib() throws IOException { if (this.LIBS == null) { String[] defaultLibs = getDefaultClassPaths(); @@ -91,6 +90,15 @@ protected void setUpAnnotationLib() throws IOException { this.LIBS = new String[len+1]; System.arraycopy(defaultLibs, 0, this.LIBS, 0, len); this.LIBS[len] = getAnnotationLibPath(); + + Bundle[] bundles = FrameworkUtil.getBundle(this.getClass()).getBundleContext().getBundles(); + File bundleFile = Arrays.stream(bundles) + .filter(b -> "org.eclipse.jdt.annotation".equals(b.getSymbolicName())) // + .findFirst().flatMap(FileLocator::getBundleFileLocation).orElseThrow(); + if (bundleFile.isDirectory()) + this.LIBS[len] = bundleFile.getPath()+"/bin"; + else + this.LIBS[len] = bundleFile.getPath(); } }