Pointed already by existing answers, the way to adapt to this is modularising your code (adding a module declaration with module-info.java
for a start). Just detailing them out with reference to sotms#module-declaration
exports
clauses can be added to declare that the module makes all,
and only, the public
types in specific packages available for use by
other modules:
module com.foo.bar {
requires org.baz.qux;
exports com.foo.bar.alpha;
exports com.foo.bar.beta;
}
If a module’s declaration contains no exports clauses then it will not export any types at all to any other modules.
and from the JLS section Exported and Opened packages
The exports
directive specifies the name of a package to be exported
by the current module. For code in other modules, this grants access
at compile time and run time to the public
and protected
types in the
package, and the public
and protected
members of those types (§6.6).
It also grants reflective access to those types and members for code
in other modules.
and further related to qualified and unqualified exports...
For a qualified directive, the public and protected types in the
package, and their public and protected members, are accessible solely
to code in the modules specified in the to clause. The modules
specified in the to
clause are referred to as friends of the current
module. For an unqualified directive, these types and their members
are accessible to code in any module.