JRI: don't System.exit on native load failure; fix double assign truncation - #2
Open
pvitt72 wants to merge 2 commits into
Open
JRI: don't System.exit on native load failure; fix double assign truncation#2pvitt72 wants to merge 2 commits into
pvitt72 wants to merge 2 commits into
Conversation
…cation The Rengine static initializer called System.exit(1) when the JRI native library failed to load. This kills the whole JVM, which is fatal when JRI is embedded in a container (application server, plugin host, ...). Leave jriLoaded == false instead and have both Rengine constructors throw an UnsatisfiedLinkError so callers can handle the failure. Also fix assign(String, REXP) for double scalars: it called Double.intValue() instead of doubleValue(), truncating the value to an integer before assigning it to R. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Modern JDKs (9+) reject -source/-target 1.4, so a plain 'make' failed with 'Source option 1.4 is no longer supported'. Default JDKVER to 8, the oldest level still accepted, and document that 14+ must not be used for JRI.jar because 'yield' becomes a reserved identifier there. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
When the JRI native library cannot be loaded,
org.rosuda.JRI.Rengine's static initializer callsSystem.exit(1). This terminates the entire JVM, which is fatal when JRI is embedded in a container (application server, plugin host, another long-lived app). The caller has no chance to recover or report the error.Changes
rosuda/JRI/Rengine.java:System.exit(1)from the static initializer. OnUnsatisfiedLinkErrorit still logs the diagnostic and leavesjriLoaded == false(the existing, documented flag). Thejri.ignore.uleproperty path is unchanged.Rengineconstructors: if!jriLoadedthey throw anUnsatisfiedLinkErrorinstead of proceeding (which previously failed later, on the R thread).UnsatisfiedLinkErrorkeeps source/binary compatibility with callers already catching it from native calls. The high-levelREngine/JRI/JRIEnginealready checksRengine.jriLoadedand throwsREngineException, so the canonical path is fully recoverable.assign(String, REXP)for double scalars: theXT_DOUBLEbranch calledDouble.intValue()instead ofdoubleValue(), truncating the value to an integer before assigning it to R (e.g.assign("x", new REXP(3.7))assigned3.0). The adjacent int branch already usesintValue()correctly.Stand-alone applications that relied on the previous exit-on-failure behavior can check
Rengine.jriLoaded(or catch the constructor'sUnsatisfiedLinkError).🤖 Generated with Claude Code