MethodHandle accessing private method of outer class
Jochen Theodorou
blackdrag at gmx.org
Sat Mar 31 16:47:18 UTC 2018
Hi all,
I just noticed something I would like to know if that is correct and as
specified (before I start using that in my application logic) using java
9.0.4
> public class Application {
> public Lookup foo() {
> Supplier<Lookup> s = new Supplier<Lookup>() {
> public Lookup get() { return MethodHandles.lookup); }
> }
> return s.get();
> }
> }
what I noticed is that the lookup object returned by the call to foo is
one with full access rights for the inner class of Application, but it
seems I am also having full access rights on Application itself. I can
for example call a private method in Application using a handle created
using this lookup object.
Is this really as intended? I am asking because Java would realize this
afaik with a helper method (at least in the past).
Was this always possible with MethodHandles, or did this change?
bye Jochen
More information about the mlvm-dev
mailing list