what is an illegal reflective access

前端 未结 4 1616
南笙
南笙 2020-11-22 15:17

There are a lot of questions around about illegal reflective access in Java 9.

Now what I can\'t find because all Google spews up is people trying to work around the

4条回答
  •  难免孤独
    2020-11-22 16:03

    Just look at setAccessible() method used to access private fields and methods:

    https://docs.oracle.com/javase/8/docs/api/java/lang/reflect/AccessibleObject.html#setAccessible-boolean-

    https://docs.oracle.com/javase/9/docs/api/java/lang/reflect/AccessibleObject.html#setAccessible-boolean-

    Now there is a lot more conditions required for this method to work. The only reason it doesn't break almost all of older software is that modules autogenerated from plain JARs are very permissive (open and export everything for everyone).

提交回复
热议问题