Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

com.sun.javafx.collections not exported in javafx.base #6287

Closed
GoldenWeiss opened this issue Jun 18, 2020 · 2 comments
Closed

com.sun.javafx.collections not exported in javafx.base #6287

GoldenWeiss opened this issue Jun 18, 2020 · 2 comments

Comments

@GoldenWeiss
Copy link

GoldenWeiss commented Jun 18, 2020

.: Environment :.
jruby 9.2.11.1

.: Overview :.
It prevents access to the inherited methods of ObservableMapWrapper in the jrubyfx DSL. Hence, the method add_change_listener throws an Exception :

TypeError: illegal access on 'addListener': class org.jruby.javasupport.JavaMethod cannot access class com.sun.javafx.collections.ObservableMapWrapper (in module javafx.base) because module javafx.base does not export com.sun.javafx.collections to unnamed module @abc0923
add_change_listener at uri:classloader:/jrubyfx/core_ext/observable_value.rb:121

.: Reproduction :.
x =Java::javafx.collections.FXCollections.observable_map({})
x.addListener Java::javafx.collections.MapChangeListener.impl{|a,b| puts "z"}

.: Small patch by Headius :.
In run configurations, add the line :
--add-exports javafx.base/com.sun.javafx.collections=ALL-UNNAMED

.: Note :.
observable_array_list.add_change_listener runs just fine, as it doesn't inherit from collections.

@headius
Copy link
Member

headius commented Jun 18, 2020

The problem here is that ObservableMapWrapper is a public class, but in a non-exported package. Because it's public we proceed to set up its methods, assuming they and the class itself will be accessible. However when a class is not exported, accessing it directly this way triggers the error reported above.

We will also need to check whether a given class has been exported to the module JRuby is running as before binding its methods. If it has not been exported, we may try to export it, but failing that we should treat it the same way we treat private classes.

@headius headius added this to the JRuby 9.2.12.0 milestone Jun 18, 2020
headius added a commit to headius/jruby that referenced this issue Jun 25, 2020
Similar to non-public classes, we don't want to bind the
reflected methods from no-exported classes, since dispatching to
those method objects will fail with an IllegalAccessException. We
avoid setting up methods on those proxies and allow public
supertypes to provide them.

Fixes jruby#6287
@headius
Copy link
Member

headius commented Jun 25, 2020

Merged to master and 9.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants