Making jdeps aware of exported API

Mandy Chung mandy.chung at
Thu Mar 23 16:15:18 UTC 2017

I considered adding an option to specify the packages to be exported.  It may work fine for simple cases.  It may take a prefix to avoid listing the packages individually.  It’s an idea on the list to implement.  On the other hand, there will be cases that we would have to edit to include `uses` and remove `exports` or  qualify any export to a friend. 

One useful option, `jdeps —-check` option provides suggestion to `requires transitive` that may not be needed and any unused qualified exports.

After you edit, compile it and rerun jdeps —-check that will analyze the exported API packages and suggest `requires` and `requires transitive`.  It requires a compilation step which would be needed to run as a module anyway.  

About jdeps —-api-only, when running on a module, it looks at the module descriptor and analyzes only exported API packages.  If the classes are on classpath (-cp), module-info.class is skipped.


> On Mar 23, 2017, at 2:24 AM, Gunnar Morling <gunnar at> wrote:
> Hi,
> I would like to suggest to add an option to jdeps for describing the
> intended exported API of descriptors created by
> --generate-module-info. This would have two benefits:
> * Limiting the number of exported packages in the generated descriptor
> to the intended public API
> * Adding the "transitive" modifiers only to those "requires"
> statements whose types are used in the exported API
> While it's relatively simple to rework descriptors after generation
> and remove any unwanted exports, that's not the case for removing
> superfluous "transitive" modifiers. Identifying them would require to
> parse the input JAR once more to find out whether a given dependence
> is used in public/protected signatures of the exported API or not.
> If the intended exported API could be passed to jdeps - e.g. in form
> of regular expressions or some other kind of exclude/include patterns
> - no further post-processing would be needed for generating
> descriptors with a well-defined API.
> I had a look at the --api-only option, but this seems only to be about
> public/protected access and not the exported packages of a module.
> Thanks for your consideration,
> --Gunnar

More information about the jigsaw-dev mailing list