Skip to content

Commit

Permalink
Remove access to deprecated PackageAdmin Access in activator
Browse files Browse the repository at this point in the history
Adjusting the tests to used the bundleContext to access
org.eclipse.jdt.annotation, hence the initialization of the package
admin
can also be removed from the activator and therefore also the activator.

Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
Co-authored-by: Hannes Wellmann <wellmann.hannes1@gmx.net>
  • Loading branch information
2 people authored and akurtakov committed Dec 13, 2024
1 parent 4e12c19 commit 04d3a2d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 56 deletions.
1 change: 0 additions & 1 deletion org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -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

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -81,16 +83,22 @@ protected void setUp() throws Exception {
setUpAnnotationLib();
}

/**
* @deprecated indirectly uses deprecated class PackageAdmin
*/
protected void setUpAnnotationLib() throws IOException {
if (this.LIBS == null) {
String[] defaultLibs = getDefaultClassPaths();
int len = defaultLibs.length;
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();
}
}

Expand Down

0 comments on commit 04d3a2d

Please sign in to comment.