Example example_annotations

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, mod.annotations, 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 modules with annotations

  • modmain looks up modules modb and mod.annotations and prints their annotations available at runtime

  • modb is deprecated via annotation in its module-info.java.

  • mod.annotations defines three annotations with ElementType module, one available at runtime, two only available at compile time

Output

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

Expected Output

Annotations of module modb:
- @java.lang.Deprecated(forRemoval=true, since="9")
- @pkgannotations.ReallyCoolModule(wowReason="modb is simply cool")
- @pkgannotations.RunTimeAnnotation()

Annotations of module mod.annotations:
- @pkgannotations.RunTimeAnnotation()

Actual Output

Annotations of module modb:
- @java.lang.Deprecated(forRemoval=true, since="9")
- @pkgannotations.ReallyCoolModule(wowReason="modb is simply cool")
- @pkgannotations.RunTimeAnnotation()

Annotations of module mod.annotations:
- @pkgannotations.RunTimeAnnotation()

Maven 4 Output

Annotations of module modb:
- @java.lang.Deprecated(forRemoval=true, since="9")
- @pkgannotations.ReallyCoolModule(wowReason="modb is simply cool")
- @pkgannotations.RunTimeAnnotation()

Annotations of module mod.annotations:
- @pkgannotations.RunTimeAnnotation()

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.