I have a project with a single source file, listed here in its entirety:
package com.acme.el;
public class ExpressionUtils {
public static Object evaluate() {
new org.apache.commons.el.ExpressionEvaluatorImpl();
return null;
}
}
The functionality is irrelevant to the question. When I build the project as an OSGi bundle using Gradle, the manifest contains the following instruction:
Export-Package: com.acme.el;uses:="org.apache.commons.el";version="1.0"
What baffles me is that uses
directive. As I've understood the directive, it is meant to define dependencies on other packages that need to be propagated to other bundles importing this exported package - if my class definitions or method signatures refer to classes in the org.apache.commons.el
package, for instance. But in this class, the dependency on org.apache.commons.el
is completely contained within the body of a method. It is not exposed in the API, and no other bundle importing com.acme.el
could ever get a hold of the ExpressionEvaluatorImpl
instance created in the method. So the dependency shouldn't need to be propagated, right?
Did I misunderstand the meaning of the uses
directive, or is its use here unnecessary?
I made a minimal example GitHub repo for reproduction which you can clone and import as a Gradle project in Eclipse.
uses
directive, the rest discusses how the framework should handle these directives: [...] For example, when they extend classes from another package, or these other classes appear in method signatures. It can therefore be said that a package uses other packages. These inter-package dependencies are modeled with the uses directive on the Export-Package header. – Ayo