Skip to content

Commit 06b607d

Browse files
committed
Merge pull request #663 from njbartlett/nb/issues/662
Fix #662: R6 @ProviderType annotation does not produce provider range.
2 parents 50dcb25 + f1661d3 commit 06b607d

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

Diff for: biz.aQute.bndlib.tests/src/test/VersionPolicyTest.java

+22
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,28 @@ public static void testProviderType() throws Exception {
126126
assertEquals("[1.2,1.3)", attrs.get("version"));
127127

128128
}
129+
130+
/**
131+
* Test if the implementation of "AnnotatedProviderInterface", which is annotated with OSGi R6
132+
* @ProviderType, causes import of the api package to use the provider version policy
133+
*/
134+
public static void testProviderTypeR6() throws Exception {
135+
Builder b = new Builder();
136+
b.addClasspath(new File("bin"));
137+
b.setPrivatePackage("test.versionpolicy.implemented.osgi");
138+
b.setProperty("build", "123");
139+
140+
Jar jar = b.build();
141+
assertTrue(b.check());
142+
Manifest m = jar.getManifest();
143+
m.write(System.err);
144+
145+
Domain d = Domain.domain(m);
146+
Parameters params = d.getImportPackage();
147+
Attrs attrs = params.get("test.version.annotations.osgi");
148+
assertNotNull(attrs);
149+
assertEquals("[1.2,1.3)", attrs.get("version"));
150+
}
129151

130152
/**
131153
* Tests if the implementation of the EventHandler (which is marked as a
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package test.version.annotations.osgi;
2+
3+
import org.osgi.annotation.versioning.*;
4+
5+
@ProviderType
6+
public interface AnnotatedProviderInterface {
7+
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package test.versionpolicy.implemented.osgi;
2+
3+
import test.version.annotations.osgi.*;
4+
5+
public class ImplementR5AnnotatedProviderInterface implements AnnotatedProviderInterface {
6+
7+
}

Diff for: biz.aQute.bndlib/src/aQute/bnd/osgi/Analyzer.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1675,7 +1675,8 @@ private boolean isProvider(TypeRef t) throws Exception {
16751675
return false;
16761676

16771677
TypeRef pt = getTypeRefFromFQN(ProviderType.class.getName());
1678-
boolean result = c.annotations.contains(pt);
1678+
TypeRef r6pt = getTypeRefFromFQN("org.osgi.annotation.versioning.ProviderType");
1679+
boolean result = c.annotations.contains(pt) || c.annotations.contains(r6pt);
16791680
return result;
16801681
}
16811682

0 commit comments

Comments
 (0)