The following code uses an encapsulated type:
import sun.security.x509.X500Name;
public class EncapsulatedTypes {
public static void main(String... args) throws Exception {
System.out.println(new X500Name("test.com", "test", "test", "US"));
}
}
When running this code with "java --illegal-access=deny" it fails like I
expected.
Exception in thread "main" java.lang.IllegalAccessError: class
EncapsulatedTypes (in unnamed module @0x6bc168e5) cannot access class
sun.security.x509.X500Name (in module java.base) because module java.base does
not export sun.security.x509 to unnamed module @0x6bc168e5
at EncapsulatedTypes.main(EncapsulatedTypes.java:8)
When running with the default behavior or even with --illegal-access=warn or
--illegal-access=debug, no warnings are generated.
I have other (larger) examples where the warnings are shown correctly. Why
doesn't this happen for this example?
I'm running build 9-ea+174-jigsaw-nightly-h6526-20170617.
Thanks,
Paul