Strong Encapsulation
Since jdk9 there has been a move toward strong encapsulation in java, however in order not to break existing code this has been somewhat relaxed. The exceptions are some internal and proprietary classes that were never intended to be generally available (includes some apple code which messes with original processing code on MacOS). This is detailed in jep-261 and jep-260 and explained here and somewhat lucidly by Mark Rheinhold.
What this means in practice for JRubyArt is that since jdk9, running sketches has become a lot more noisy (illegal reflective access warnings). With the latest development version of JRubyArt-2.0 (JRuby-9.2.8.0 and jdk12) I have started to explore these warnings, and it is easy as creating a ‘java_args.txt’ file in data folder (as sub-folder of the running sketches). I have published my results here:-
- A simple java 2d sketch
- A simple processing P2D sketch (jogl)
- A simple processing P3D sketch (jogl)
- A swing control panel sketch
Possible way around includes --add-exports
, --add-opens
, --add-modules
, --add-reads
for the specific modules at runtime (you could try this in java_args.txt
).
However I’ve not had much luck yet. Interestingly if instead of --illegal-access=warn
you use --illegal-access=deny
and run simple sketch you get following:-
2019-08-15T08:42:52.686+01:00 [main] WARN FilenoUtil : Native subprocess control requires open access to sun.nio.ch
Pass '--add-opens java.base/sun.nio.ch=org.jruby.dist' or '=org.jruby.core' to enable.
It is possible there is a more stable solution using jdeps
to create module-info for the legacy jars and to inject the module-info into them.