Skip to content

[ji] continued cleanup of JavaClass and friends#7164

Closed
kares wants to merge 30 commits intojruby:jruby-9.3from
kares:ji-java-class-cleanup_9.3
Closed

[ji] continued cleanup of JavaClass and friends#7164
kares wants to merge 30 commits intojruby:jruby-9.3from
kares:ji-java-class-cleanup_9.3

Conversation

@kares
Copy link
Member

@kares kares commented Mar 31, 2022

WiP - proof of concept (testing against 9.3 due CI - expected to re-target against master - 9.4)


The motivation here is to cleanup Java Integration, avoid the duality of wrapping Java objects as to reduce user confusion when e.g. facing JavaObject vs a Java proxy, also shipping new features becomes easier ...

This is a follow-up on the work done in 9.3 to eliminate JavaClass: #6513
It takes things few steps further, namely:

  • eliminated JavaObject and JavaArray wrapper (they still exist and point to JavaProxy / ArrayJavaProxy)
    • these are now no longer used - and their Java proxies provide the same ruby API
    • the only concern is if a user (extension) does manual wrapping in Java using e.g. JavaObject.wrap but even that is going to function to some extent as a lot of the existing 'unwrapping' methods still hande the deprecated type
  • as JavaClass and friends was already deprecated in 9.3 we can now remove the Ruby impl methods
    • note JavaConstructor is smt still use internally (had 2 responsibilities) - thus stayed non-deprecated
  • synchronized { } was adjusted to yield the actual value we're synchronizing (previously yielded nil)
  • JavaSupport vs JavaSupportImpl methods are now split between the 2 -
    • JavaSupport is smt users could use runtime.getJavaSupport() in an ext so have clearly the methods user usable there
    • the internals (meant for JRuby use only) are moved JavaSupportImpl (the methods are deprecated in JavaSupport)
    • no API breaking changes except maybe for some very deep internals
  • some of JavaClass API is now moved elsewhere (the class is now deprecated), we still use some of it's API internally but the most crucial ones have been moved and can be used by the user e.g. JavaUtil.getJavaClass
  • some cleanup refactoring work that showed up along the way

@kares kares force-pushed the ji-java-class-cleanup_9.3 branch from c1c782c to b5eec49 Compare April 5, 2022 13:05
}

if (ctor == null) {
JavaObject jo = (JavaObject) initialize.call(context, self, clazz, "new", args);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@byteit101 not sure how well this branch or the whole method actually is covered with tests.
using JRuby's Java integration related suites I wasn't able to hit this ctor == null branch ...
and the many TODOs left around just confused me, the change should be backwards compatible but still could use your 👀

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is possible to hit, but only with nonstandard and untested configurations. See the java class configurator, ruby ctor boolean.

this class while being a ghost of Java::JavaConstructor
also had other responsibilities - used as a Java wrapper
kares added 6 commits April 6, 2022 14:39
while internal ones (some of which are public but deprecated) stay at
the Impl sub-class
JavaClass was revamped and deprecated (on Ruby side) in 9.3
the JavaClass constant still works as in 9.3 (= java.lang.Class)
@kares kares force-pushed the ji-java-class-cleanup_9.3 branch from c6b80b4 to a81003f Compare April 6, 2022 12:46
@kares kares force-pushed the ji-java-class-cleanup_9.3 branch from a81003f to cda2544 Compare April 6, 2022 13:03
@kares kares requested a review from headius April 14, 2022 12:39
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

Successfully merging this pull request may close these issues.

3 participants