Sharing experiences with the latest EA build // #ReflectiveAccessToNonExportedTypes #ResourceEncapsulation
Alan Bateman
Alan.Bateman at oracle.com
Wed Oct 5 11:59:23 UTC 2016
On 03/10/2016 16:15, Rafael Winterhalter wrote:
> :
>
> triggering in the following reflective invocation in the Java layer of
> the rule engine's module:
>
> Object foo = Foo.getInstance();
> foo.getClass().getMethod("qux").invoke(foo); // Causes IllegalAccessError
IllegalAccessException isn't new here of course, it's always been
possible that getClass() returns a type that is not accessible. In this
case, then Foo.class.getMethod("qux").invoke(foo) is what you want. I do
have sympathy of course of course, it almost feels like there a new
method is needed to here to walk the hierarchy to find the method on the
accessible type (I think Peter Levart had an example in a recent mail).
> :
>
> For this and many other reasons, as for this particular application, I
> do not believe it will ever make it past the "weak module" phase. A
> lot of code was built based on the assumption that reflection can just
> cut through.
Sure but I don't think there is any expectation that every library or
application will immediately migrate to strong modules. Getting to weak
modules will be a huge achievement in many cases. It means there will be
module names, it means that cycles and split package issues have been
addressed, and it means that dependences are declared. No failure in
getting that far.
-Alan.
More information about the jigsaw-dev
mailing list