Skip to content
This repository has been archived by the owner on Sep 6, 2023. It is now read-only.

convert java_class to ruby_class #482

Closed
jimtng opened this issue Jan 4, 2022 · 2 comments · Fixed by #490
Closed

convert java_class to ruby_class #482

jimtng opened this issue Jan 4, 2022 · 2 comments · Fixed by #490
Labels

Comments

@jimtng
Copy link
Collaborator

jimtng commented Jan 4, 2022

The jrubyscripting bundle that shipped with openhab 3.2 contains a bug where Openhab injected global scope which contains java classes. As a result, they are not usable in JRuby, unless the classes are re-imported. This in turns breaks rules that don't use openhab-jruby helper library.

The openhab-jruby helper library re-imports most of the relevant classes which masked the problem.

In December 2021, a new PR made it into the release of Openhab 3.2 which added ZonedDateTime, Duration and ChronoUnit. This caused problems in rules that use those java classes without re-importing them.

I made a patch to the jrubyscripting bundle to intercept the objects / classes and replace them with a jruby class. This jar file can be used for testing:
https://github.com/jimtng/openhab-addons/raw/jruby-scope/bundles/org.openhab.automation.jrubyscripting/org.openhab.automation.jrubyscripting-3.2.0-SNAPSHOT.jar

The source code can be found here:
https://github.com/jimtng/openhab-addons/blob/jruby-scope/bundles/org.openhab.automation.jrubyscripting/src/main/java/org/openhab/automation/jrubyscripting/internal/JRubyScriptEngineFactory.java

I'll clean it up before submitting a PR to openhab-addons.

Originally posted by @jimtng in #448 (comment)

@jimtng
Copy link
Collaborator Author

jimtng commented Jan 10, 2022

I found out why I was having problems with ZonedDateTime out of a sudden, as described in #438, although it isn't related to the original issue in #438.

ZonedDateTime and Duration were recently added to the global scope: openhab/openhab-core#2587

As a result, they too started having the java_class / ruby_class problem.

@github-actions
Copy link

🎉 This issue has been resolved in version 4.28.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

1 participant