New candidate JEP: 403: Strongly Encapsulate JDK Internals

Alan Bateman Alan.Bateman at oracle.com
Thu Mar 25 11:26:14 UTC 2021


On 25/03/2021 10:54, Andrew Haley wrote:
> :
> Looking at the JEP, I don't immediately see anything about long-term
> use of illegal accesses in test code. There are a good many cases where
> we need to test private and protected classes and fields, for example.
> Is there a proposal to allow this?
I don't think tests should be impacted by this JEP.

For the JDK tests, jtreg has the @modules tag to do what we want. It can 
be used to export and/or open any of the packages for the test, the 
value of the tags get translated to the equivalent of --add-exports or 
--add-opens.

More generally, tests for modules, say white box tests that exercise 
package private methods, can continue to be compiled and run "as if" 
they are part of the module. The Maven/other plugins for testing will 
use --patch-module, and maybe other options, to the setup for the tests.

-Alan.


More information about the jigsaw-dev mailing list