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

System.setProperty("org.jruby.embed.compat.version", "RUBY1_8") does not work #1365

Closed
pintubigfoot opened this issue Dec 27, 2013 · 6 comments
Closed

Comments

@pintubigfoot
Copy link

@pintubigfoot pintubigfoot commented Dec 27, 2013

Verified with jruby 1.7.9, the JSR223 does not set the compat version properly.

This is what I have tried:

// Setting the compat version to 1.8
System.setProperty("org.jruby.embed.compat.version", "RUBY1_8");  
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("jruby");
engine.eval("require \"irb\" ; IRB.start");

When I run it, it shows RUBY_VERSION is still 1.9

irb(main):009:0> puts RUBY_VERSION
1.9.3       # --------> compat version is still 1.9
=> nil
irb(main):010:0> puts JRUBY_VERSION
1.7.9
=> nil

org.jruby.embed.util.SystemPropertyCatcher (line 170):

    public static void setConfiguration(ScriptingContainer container) {
        LocalContextProvider provider = container.getProvider();
        RubyInstanceConfig config = provider.getRubyInstanceConfig();
        String s = SafePropertyAccessor.getProperty(PropertyName.COMPILEMODE.toString());
        if (s != null) {
            if ("jit".equalsIgnoreCase(s)) {
                config.setCompileMode(CompileMode.JIT);
            } else if ("force".equalsIgnoreCase(s)) {
                config.setCompileMode(CompileMode.FORCE);
            } else {
                config.setCompileMode(CompileMode.OFF);
            }
        }
        s = SafePropertyAccessor.getProperty(PropertyName.COMPATVERSION.toString());
        if (s != null) { 
            //================================================
            //  JSR223 is bypassing all version except 1.9 
            //================================================
            if (isRuby19(s)) { 
                config.setCompatVersion(CompatVersion.RUBY1_9);
            } 
        }
    }

Thank you.

@inger
Copy link

@inger inger commented Jul 9, 2015

I ran into this now too using 1.7.20.1. (2 years after the problem reported first).
This makes 1.8 mode practically unusable using JSR223.

The only workaround I found is:

  • use LocalContextScope.SINGLETON (the default for JSR223 api)
  • before creating the JSR223 ScriptEngine: do this:
      ScriptingContainer dummySingletonJruby = new ScriptingContainer(LocalContextScope.SINGLETON);
      dummySingletonJruby.setCompatVersion(CompatVersion.RUBY1_8);
      dummySingletonJruby.getProvider().getRuntime();
  • after this, the jsr one will pick up the already configured 1.8 engine..

I'd like this to be fixed for 1.7.x (as well as 9.x)

@kares
Copy link
Member

@kares kares commented Jul 14, 2015

this seems as a left-over from the time JRuby switched to 1.9 mode being the default (since 1.7.x) ... should be easy to fix. also please be aware that COMPAT_VERSION currently makes no sense in 9K (its 2_2 only)

kares added a commit to kares/jruby that referenced this issue Jul 14, 2015
with (JSR223) scripting-container (fixes jruby#1365)
@kares kares added this to the JRuby 1.7.22 milestone Jul 14, 2015
@kares
Copy link
Member

@kares kares commented Jul 14, 2015

should be ready for 1.7.22 ... you can try the jruby-1_7 branch

@kares kares closed this Jul 14, 2015
@inger
Copy link

@inger inger commented Jul 15, 2015

Great, thank you! Although in the meantime I migrated to using jruby.embed directly - I will try it soon.

@inger
Copy link

@inger inger commented Jul 15, 2015

BTW- I know this awfully off-topic - but is there any new mailing list up&running yet (codehaus replacement) Thanks

@kares
Copy link
Member

@kares kares commented Jul 15, 2015

http://jruby.org/community is updated with the new mailing list already (jruby@ruby-lang.org)

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

Successfully merging a pull request may close this issue.

None yet
3 participants