Skip to content

Commit

Permalink
Merge pull request #663 from njbartlett/nb/issues/662
Browse files Browse the repository at this point in the history
Fix #662: R6 @ProviderType annotation does not produce provider range.
  • Loading branch information
njbartlett committed Oct 29, 2014
2 parents 50dcb25 + f1661d3 commit 06b607d
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 06b607d

Please sign in to comment.