Skip to content

Commit

Permalink
Fix bndtools#662: R6 @ProviderType annotation does not produce provid…
Browse files Browse the repository at this point in the history
…er range

Signed-off-by: Neil Bartlett <njbartlett@gmail.com>
  • Loading branch information
njbartlett committed Oct 28, 2014
1 parent 50dcb25 commit f1661d3
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
22 changes: 22 additions & 0 deletions biz.aQute.bndlib.tests/src/test/VersionPolicyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package test.version.annotations.osgi;

import org.osgi.annotation.versioning.*;

@ProviderType
public interface AnnotatedProviderInterface {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package test.versionpolicy.implemented.osgi;

import test.version.annotations.osgi.*;

public class ImplementR5AnnotatedProviderInterface implements AnnotatedProviderInterface {

}
3 changes: 2 additions & 1 deletion biz.aQute.bndlib/src/aQute/bnd/osgi/Analyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit f1661d3

Please sign in to comment.