jsplitpkgscan icon indicating copy to clipboard operation
jsplitpkgscan copied to clipboard

JDK 9+ split package analysis tool

= OpenJDK split package scanner Patrick Reinhart https://github.com/reinhapa[@reinhapa] :project-name: jsplitpkgscan :group-name: org.adoptopenjdk :jsplitpkgscan-version: 1.1.0-SNAPSHOT :project-full-path: AdoptOpenJDK/{project-name} :github-branch: master :jdk-version: 11 :jdk-url: https://jdk.java.net/{jdk-version} :adoptopenjdk-url: https://adoptopenjdk.net

image:https://img.shields.io/badge/license-GPL2+CPE-blue.svg["GNU General Public License, version 2, with the Classpath Exception", link="https://github.com/{project-full-path}/blob/{github-branch}/LICENSE"] image:https://img.shields.io/badge/Java-{jdk-version}-blue.svg["Supported Versions", link="https://travis-ci.org/{project-full-path}"] image:https://github.com/{project-full-path}/actions/workflows/gradle.yml/badge.svg["Java CI with Gradle", link="https://github.com/{project-full-path}/actions/workflows/gradle.yml"] image:https://img.shields.io/maven-central/v/{group-name}/{project-name}.svg?label=Maven%20Central["Maven Central", link="https://search.maven.org/search?q=g:%22{group-name}%22%20AND%20a:%22{project-name}%22"]

This project contains a proposal for http://openjdk.java.net[OpenJDK] split package scanner addition.

The diving force starting this tool was the lack of tooling to prepare existing class path based modules for later migration to modules. For split packages with the current JDK, they will be shown by the jdeps tool as of today, but not class path based modules so far.

The jsplitpgkscan utility will search for split packages within all given .jar files and the modules known to the JDK itself and report them.

== Build and run To build the tool you need to have a actual JDK build that you can get from {jdk-url}[{jdk-url}], {adoptopenjdk-url}[{adoptopenjdk-url}] or other providers. Make sure that you have at least version jdk-{jdk-version} installed.

To build use:

[source, bash]

./gradlew clean build

After the build was successful you can now start it using:

[source, bash, subs="attributes"]

java -p build/libs/jsplitpkgscan-{jsplitpkgscan-version}.jar -m jdk.jsplitpkgscan

The usage is as follows [source]

Usage: jsplitpkgscan <path ...>] can be a pathname to a JAR/WAR/RAR file or exploded JAR/WAR/RAR file. Possible options include: -h -? --help Print this usage message -a Report all packages for each found JAR/RAR/WAR file or exploded directory -d Directory containing JAR/RAR/WAR files or exploded directories to scan (scans subdirectories as well) -f File containing a list of JAR/RAR/WAR files or exploded directories to scan -p Package prefix to report only split packages that matches this prefix --dot-output Destination directory for DOT file output

In order to create your own distribution using jlink you can enter the following command if you have JAVA_HOME set:

[source, bash]

$JAVA_HOME/bin/jlink --module-path $JAVA_HOME/jmods:build/libs --add-modules jsplitpkgscan
--launcher jsplitpkgscan=jsplitpkgscan --output /tmp/jsplitpkgscan

For using the tool from inside you're code, you can access it looking it up a an java.util.spi.ToolProvider implementation as follows:

[source, java]

int rc = ToolProvider.findFirst("jsplitpgkscan") .ifPresent(tool -> tool.run(System.out, System.err, "-h")

== Create DOT graphic To get a .png graphic for any .dot file output for directed graphs you could use:

[source, bash]

dot -Tpng summary.dot -O -Gratio=0.5

If your experience problems due undirected graphs you could also use this command:

[source, bash]

twopi -Tpng summary.dot -O -Gratio=0.5 -Goverlap=false

== Contribute Contributions are always welcome.

== License This project is licensed under the https://github.com/{project-full-path}/blob/{github-branch}/LICENSE[GNU General Public License, version 2 with the Classpath Exception]