JRuby (please use github issues at http://bugs.jruby.org)
  1. JRuby (please use github issues at http://bugs.jruby.org)
  2. JRUBY-6608

error when catching errors in proc sent to secondary ScriptingContainer

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Not A Bug
    • Affects Version/s: JRuby 1.6.6
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      OS X, Windows 2008, Oracle Java, IBM Java, 1.8 mode, 1.9 mode
    • Number of attachments :
      0

      Activity

      Hide
      Mike Luu added a comment - - edited

      My application uses ScriptingContainer from within jruby as a way to sandbox a work routine. During this work, I need to execute code back in the main jruby instance.

      require 'java'
      sc = org.jruby.embed.ScriptingContainer.new(org.jruby.embed.LocalContextScope::THREADSAFE)
      sc.runScriptlet 'def foo(a); a.call end'
      a = proc { begin; raise StandardError; rescue; end }
      sc.callMethod(sc.runScriptlet("Kernel"), "foo", a)
      

      This generates a
      TypeError: assigning non-exception to $!

      Is there another way to accomplish this and workaround this issue?

      Show
      Mike Luu added a comment - - edited My application uses ScriptingContainer from within jruby as a way to sandbox a work routine. During this work, I need to execute code back in the main jruby instance. require 'java' sc = org.jruby.embed.ScriptingContainer. new (org.jruby.embed.LocalContextScope::THREADSAFE) sc.runScriptlet 'def foo(a); a.call end' a = proc { begin; raise StandardError; rescue; end } sc.callMethod(sc.runScriptlet( "Kernel" ), "foo" , a) This generates a TypeError: assigning non-exception to $! Is there another way to accomplish this and workaround this issue?
      Hide
      Mike Luu added a comment -

      I ended up using a monitor to control serial execution between jruby and the sub-ScriptingContainer

      Show
      Mike Luu added a comment - I ended up using a monitor to control serial execution between jruby and the sub-ScriptingContainer
      Hide
      Charles Oliver Nutter added a comment -

      Yes, unfortunately Ruby objects passing between runtimes generally just doesn't work. They are most definitely tied to their home runtime.

      Your solution sounds like a good one!

      Show
      Charles Oliver Nutter added a comment - Yes, unfortunately Ruby objects passing between runtimes generally just doesn't work. They are most definitely tied to their home runtime. Your solution sounds like a good one!
      Charles Oliver Nutter made changes -
      Field Original Value New Value
      Status Open [ 1 ] Resolved [ 5 ]
      Assignee Thomas E Enebo [ enebo ] Charles Oliver Nutter [ headius ]
      Resolution Not A Bug [ 6 ]
      Charles Oliver Nutter made changes -
      Status Resolved [ 5 ] Closed [ 6 ]

        People

        • Assignee:
          Charles Oliver Nutter
          Reporter:
          Mike Luu
        • Votes:
          0 Vote for this issue
          Watchers:
          2 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: