From f1661d35355836508417c04a168231e71ae54621 Mon Sep 17 00:00:00 2001 From: Neil Bartlett Date: Tue, 28 Oct 2014 20:37:51 +0000 Subject: [PATCH] Fix #662: R6 @ProviderType annotation does not produce provider range Signed-off-by: Neil Bartlett --- .../src/test/VersionPolicyTest.java | 22 +++++++++++++++++++ .../osgi/AnnotatedProviderInterface.java | 8 +++++++ ...ImplementR5AnnotatedProviderInterface.java | 7 ++++++ .../src/aQute/bnd/osgi/Analyzer.java | 3 ++- 4 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 biz.aQute.bndlib.tests/src/test/version/annotations/osgi/AnnotatedProviderInterface.java create mode 100644 biz.aQute.bndlib.tests/src/test/versionpolicy/implemented/osgi/ImplementR5AnnotatedProviderInterface.java diff --git a/biz.aQute.bndlib.tests/src/test/VersionPolicyTest.java b/biz.aQute.bndlib.tests/src/test/VersionPolicyTest.java index c1379169df..77b773e4b6 100644 --- a/biz.aQute.bndlib.tests/src/test/VersionPolicyTest.java +++ b/biz.aQute.bndlib.tests/src/test/VersionPolicyTest.java @@ -126,6 +126,28 @@ public static void testProviderType() throws Exception { assertEquals("[1.2,1.3)", attrs.get("version")); } + + /** + * Test if the implementation of "AnnotatedProviderInterface", which is annotated with OSGi R6 + * @ProviderType, causes import of the api package to use the provider version policy + */ + public static void testProviderTypeR6() throws Exception { + Builder b = new Builder(); + b.addClasspath(new File("bin")); + b.setPrivatePackage("test.versionpolicy.implemented.osgi"); + b.setProperty("build", "123"); + + Jar jar = b.build(); + assertTrue(b.check()); + Manifest m = jar.getManifest(); + m.write(System.err); + + Domain d = Domain.domain(m); + Parameters params = d.getImportPackage(); + Attrs attrs = params.get("test.version.annotations.osgi"); + assertNotNull(attrs); + assertEquals("[1.2,1.3)", attrs.get("version")); + } /** * Tests if the implementation of the EventHandler (which is marked as a diff --git a/biz.aQute.bndlib.tests/src/test/version/annotations/osgi/AnnotatedProviderInterface.java b/biz.aQute.bndlib.tests/src/test/version/annotations/osgi/AnnotatedProviderInterface.java new file mode 100644 index 0000000000..667e9ed376 --- /dev/null +++ b/biz.aQute.bndlib.tests/src/test/version/annotations/osgi/AnnotatedProviderInterface.java @@ -0,0 +1,8 @@ +package test.version.annotations.osgi; + +import org.osgi.annotation.versioning.*; + +@ProviderType +public interface AnnotatedProviderInterface { + +} diff --git a/biz.aQute.bndlib.tests/src/test/versionpolicy/implemented/osgi/ImplementR5AnnotatedProviderInterface.java b/biz.aQute.bndlib.tests/src/test/versionpolicy/implemented/osgi/ImplementR5AnnotatedProviderInterface.java new file mode 100644 index 0000000000..06e695e30c --- /dev/null +++ b/biz.aQute.bndlib.tests/src/test/versionpolicy/implemented/osgi/ImplementR5AnnotatedProviderInterface.java @@ -0,0 +1,7 @@ +package test.versionpolicy.implemented.osgi; + +import test.version.annotations.osgi.*; + +public class ImplementR5AnnotatedProviderInterface implements AnnotatedProviderInterface { + +} diff --git a/biz.aQute.bndlib/src/aQute/bnd/osgi/Analyzer.java b/biz.aQute.bndlib/src/aQute/bnd/osgi/Analyzer.java index 03b8ba82aa..dbb984dffa 100755 --- a/biz.aQute.bndlib/src/aQute/bnd/osgi/Analyzer.java +++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/Analyzer.java @@ -1675,7 +1675,8 @@ private boolean isProvider(TypeRef t) throws Exception { return false; TypeRef pt = getTypeRefFromFQN(ProviderType.class.getName()); - boolean result = c.annotations.contains(pt); + TypeRef r6pt = getTypeRefFromFQN("org.osgi.annotation.versioning.ProviderType"); + boolean result = c.annotations.contains(pt) || c.annotations.contains(r6pt); return result; }