On 12/12/2016 06:34, David Holmes wrote:
Does addExports only affect reflective access to the module, or does
it change all access? I'm trying to determine what the set of actions
X will be such that:
try {
<X>;
}
catch (<some exception indicating X failed due to lack of export>) {
execute( () -> mod.addExports(...)); // address the problem
<X>; // now it succeeds
}
It updates the module to export the package so that public types in that
package are accessible to bytecode, code reflection, also method handles.
As to what <X> is then it might be an access from bytecode (maybe
generated code or just a mismatch between the compile time and run time
environments that leads to IllegalAccessError).
More likely then <X> is using core reflection and an access check with
Constructor::newInstance, Method::invoke or Field::set fails with
IllegalAccessException. The retry in your example will succeed (assuming
the package is now exported to at least the caller and access is
otherwise allowed by the class/member modifiers). <X> could be something
using method handles too, say where a Lookup::findXXXX fails
IllegalAccessException.
-Alan