Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Move all JI setAccessible to trySetAccessible. #5843
The logic previously was depending on the ji.setAccessible
That default is removed here, along with a the CAN_SET_ACCESSIBLE
The direct calls to setAccessible have been replaced by the
Most of the changes here were masked by the property, but I have
This fixes #5841 by allowing
This relates to #5821, which fixed in 9.2.8 a similar issue where
The logic previously was depending on the ji.setAccessible property, which by default would simply refuse to set accessible *at all* when the Java version was >= "1.9" (also showing this logic was introduced very early in the Java 9 development cycle.) That default is removed here, along with a the CAN_SET_ACCESSIBLE static field in RubyInstanceConfig deprecated and replaced with the original meaning of this property, simply whether to attempt setAccessible. The direct calls to setAccessible have been replaced by the trySetAccessible in backport9 library that checks if the target member's module is open to JRuby, allowing users to opt-in to that reflective access if their application needs it. Previously these cases still skipped setAccessible just due to being on Java 9+. Most of the changes here were masked by the property, but I have also fixed several others that were not guarded by the property or that were otherwise used in booting JRuby or extending Java integration. This fixes #5841 by allowing `java_method` Method objects to go ahead and trySetAccessible when the module is open. This relates to #5821, which fixed in 9.2.8 a similar issue where even an open module would not set fields and methods accessible.
Yeah that might be a good idea. I hate to add something more to Ruby.java, but maybe to our Java class? It's already pretty fat and not really public API.