Error message when accessing non-public type
Alex Buckley
alex.buckley at oracle.com
Wed Jun 22 01:11:37 UTC 2016
Hi Gunnar,
A question for you about Hibernate accessing non-exported types, in
connection with your fascinating blog entry
http://in.relation.to/2016/06/17/bean-validation-and-the-jigsaw-liaison/
The user module com.example.acme 'provides' a secret implementation of
javax.validation.ConstraintValidator. The RI module
org.hibernate.validator.engine 'uses' ConstraintValidator. Great --
until code in the RI module tries to instantiate the secret
implementation class directly, and gets an IAE. Why isn't the RI module
letting ServiceLoader instantiate custom constraint validators on its
behalf?
(Earlier, the API module javax.validation was happy to have
ServiceLoader instantiate validation providers on its behalf.)
Alex
On 6/15/2016 3:24 AM, Gunnar Morling wrote:
> Hi,
>
> When referring to a not-exported type from another module, I'm getting this
> rather generic compilation error:
>
> package someprivate.pakkage does not exist
> import someprivate.pakkage.SomeType;
> ^
> error: cannot find symbol SomeType
>
> As if the type was not existing at all. As per this blog post [1], a more
> specific error used to be raised in previous EA builds:
>
> error: SomeType is not visible because
> package someprivate.pakkage is not visible
>
> I found that previous error more helpful, as it gives an indication of what
> to do in order to prevent it. Has this been changed intentionally? Or am I
> doing something wrong here?
>
> Thanks,
>
> --Gunnar
>
> [1]
> https://blog.codecentric.de/en/2015/11/first-steps-with-java9-jigsaw-part-1/
>
More information about the jigsaw-dev
mailing list