[9] Review request: 8177566: FX user module gets IllegalAccessException from sun.reflect.misc.Trampoline

Kevin Rushforth kevin.rushforth at oracle.com
Tue May 2 21:22:49 UTC 2017


Mandy Chung wrote:
> Hi Kevin,
>> On May 1, 2017, at 5:21 PM, Kevin Rushforth <Kevin.Rushforth at oracle.COM> wrote:
>> This review is being cross-posted to both openjfx-dev and jigsaw-dev.
>> Please review the proposed fix for:
>> https://bugs.openjdk.java.net/browse/JDK-8177566
>> http://cr.openjdk.java.net/~kcr/8177566/webrev.00/complete-webrev/
> First pass of comment:
> javafx.base/src/main/java/com/sun/javafx/property/PropertyReference.java
>  196         try {
>  197             return (ReadOnlyProperty<T>)MethodHelper.invoke(propertyGetter, bean, (Object[])null);
>  198         } catch (Exception ex) {
>  199             throw new RuntimeException(ex);
>  200         }
> Do you have an example exception thrown if the package is not
> open to javafx.base?  IAE is thrown by MethodHelper.invoke.
> Are you detecting this and throw an exception with friendlier
> message?

Here is the message:

IllegalAccessException: class com.sun.javafx.property.MethodHelper 
cannot access class com.foo (in module foo.app) because module foo.app 
does not open com.foo to javafx.base

It is roughly the same message that any similar illegal access would 
generate (e.g., we get similar error messages when FXML tries to call 
setAccessible for a field annotated with @FXML if the module is not 
"open" to javafx.fxml).

> javafx.base/src/main/java/com/sun/javafx/property/MethodHelper.java
> javafx.fxml/src/main/java/com/sun/javafx/fxml/MethodHelper.java
> javafx.web/src/main/java/com/sun/webkit/MethodHelper.java
>   45     public static Object invoke(Method m, Object obj, Object[] params)
> To avoid 3 ModuleHelper classes, the invoke method can take
> the callerModule argument to replace this line: 
>   56         final Module thisModule = MethodHelper.class.getModule();

I'm fairly certain that won't work. Module::addOpens is caller sensitive 
and will only work when called from the module in question.

> javafx.base/src/main/java/com/sun/javafx/reflect/MethodUtil.java
>   There are a few other public methods which I think JavaFX doesn’t
>   need and can be removed.

Yes, I could do this to reduce the public footprint of the class. To 
minimize the diffs between the original and our copy, I might just 
comment out the "public". That would also make it easier to add them 
back in a future version (e.g., to eventually get rid of all dependency 
on sun.reflect.misc). Thoughts?

-- Kevin

> Mandy

More information about the jigsaw-dev mailing list