Skip to content

Latest commit

 

History

History
92 lines (65 loc) · 2.34 KB

OPEN_ACCESS_OPTIONAL.adoc

File metadata and controls

92 lines (65 loc) · 2.34 KB

Practice 6

If a module want to access to other module’s components, other module have to open or export required packages to caller module.

exports

Makes packages accessible to other modules at compile time or run time.

opens

Makes packages accessible to other modules only at run time including access to private members.

Note
Class<?> clazz = Class.forName("com.printer.impl.Printer"); (1)
Class<Printer> clazz = Printer.class; (2)
  1. Access to the class at run-time

  2. Access to the class at compile time

1) Reflective access with exports (public method)

cd module-reflection-exports

2) Reflective access with exports (private method)

cd module-reflection-exports-private

3) Reflective access with opens (private method)

cd module-reflection-opens-private

3) 2) Non-Reflective access with opens (public method)

cd module-reflection-opens-public