Abstract
One of the main goals of JDK 9 is to encapsulate types and resources in modules and export only those packages whose public types are intended to be accessed by other modules. Sometimes, you may need to break the encapsulation specified by a module to enable white-box testing or use unsupported JDK-internal APIs or libraries. This is possible by using non-standard command-line options at compile-time and runtime. Another reason for having these options is backward compatibility. Not all existing applications will be fully migrated to JDK 9 and will be modularized. If those applications need to use the JDK APIs or APIs provided by libraries that used to be public, but have been encapsulated in JDK 9, those applications have a way to keep working. A few of these options have corresponding attributes that can be added to the MANIFEST.MF file of the executable JARs to avoid using the command-line options.
Author information
Authors and Affiliations
Rights and permissions
Copyright information
© 2017 Kishori Sharan 2017, corrected publication 2018
About this chapter
Cite this chapter
Sharan, K. (2017). Breaking Module Encapsulation. In: Java 9 Revealed. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-2592-9_9
Download citation
DOI: https://doi.org/10.1007/978-1-4842-2592-9_9
Published:
Publisher Name: Apress, Berkeley, CA
Print ISBN: 978-1-4842-2591-2
Online ISBN: 978-1-4842-2592-9
eBook Packages: Professional and Applied ComputingApress Access BooksProfessional and Applied Computing (R0)