Example example_hiddenmain

Part of the full Java 9 Jigsaw modules example suite.

Authors

Migrated for Java Modules support documentation of Apache MavenTM in the course of the Maven Support & Care program by Gerd Aschemann (and other team members) as forked repository. Please add discussions, requirements, bugfixes, etc. to the fork instead of the original.

What is this example about?

Modules in this example

  • modb, modmain

  • modmain has a Main class which is started in run.sh

Module Dependency Graph, created with DepVis

Example’s Module Dependency Graph

Example shows …​

  • Can a Java application start with a non-exported main method?

  • Run starts two examples: One starts the main methode in an exported package, second calls a main method in a non-exported package

Both calls are possible.

Output

This example uses golden master testing to ensure output consistency. The expected output is compared with actual output using verify.sh.

Expected Output

You called pkgmain.Main.main()
You called pkgmainhidden.HiddenMain.main()

Actual Output

You called pkgmain.Main.main()
You called pkgmainhidden.HiddenMain.main()

Maven 4 Output

You called pkgmain.Main.main()
You called pkgmainhidden.HiddenMain.main()

Maven 4 Migration

This example was migrated to Maven 4 using the standard approach documented in the central Maven 4 Migration guide. The migration required no special configuration beyond the standard Module Source Hierarchy setup.