Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does bnd add a uses directive for a package used only within a method body?
    primarykey
    data
    text
    <p>I have a project with a single source file, listed here in its entirety:</p> <pre><code>package com.acme.el; public class ExpressionUtils { public static Object evaluate() { new org.apache.commons.el.ExpressionEvaluatorImpl(); return null; } } </code></pre> <p>The functionality is irrelevant to the question. When I build the project as an OSGi bundle using Gradle, the manifest contains the following instruction:</p> <pre><code>Export-Package: com.acme.el;uses:="org.apache.commons.el";version="1.0" </code></pre> <p>What baffles me is that <code>uses</code> 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 <code>org.apache.commons.el</code> package, for instance. But in this class, the dependency on <code>org.apache.commons.el</code> is completely contained <em>within the body</em> of a method. It is not exposed in the API, and no other bundle importing <code>com.acme.el</code> could ever get a hold of the <code>ExpressionEvaluatorImpl</code> instance created in the method. So the dependency shouldn't need to be propagated, right? </p> <p>Did I misunderstand the meaning of the <code>uses</code> directive, or is its use here unnecessary?</p> <p>I made <a href="https://github.com/emlun/bnd-uses-strange">a minimal example GitHub repo for reproduction</a> which you can clone and import as a Gradle project in Eclipse.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload