--illegal-access=warn not printing any warnings

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

--illegal-access=warn not printing any warnings

Paul Bakker
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
Reply | Threaded
Open this post in threaded view
|

Re: --illegal-access=warn not printing any warnings

Paul Bakker
Answering my own question, this is clear after reading the proposal once more.
Warnings are generated for reflective access only.

Paul

> On Jun 24, 2017, at 6:56 PM, Paul Bakker <[hidden email]> wrote:
>
> 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 <http://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