module WebConsole::JRuby

Public Class Methods

interpreted_mode?() click to toggle source

Returns whether JRuby is ran in interpreted mode.

# File lib/web_console/integration/jruby.rb, line 10
def interpreted_mode?
  compile_mode     = ::JRuby.runtime.instance_config.compile_mode
  interpreted_mode = RubyInstanceConfig::CompileMode::OFF

  compile_mode == interpreted_mode
end
set_exception_bindings_trace_func() click to toggle source

A proc to be used in Kernel#set_trace_func.

It sets Exception#bindings for an error with all the bindings the current ThreadContext contains.

# File lib/web_console/integration/jruby.rb, line 21
def set_exception_bindings_trace_func
  proc do |event, file, line, id, binding, classname|
    case event
    when 'raise'
      if $ERROR_INFO.bindings.empty?
        # binding_of_caller will generate an improperly built binding at
        # caller[1]. Every call to a non existent method, constant or a
        # local variable will result in a Java NullPointerException.
        #
        # The binding that Kernel#set_trace_func is giving us is properly
        # built, so we can use in place of the broken one.
        bindings = ::Kernel.binding.callers.drop(2).unshift(binding)
        $ERROR_INFO.instance_variable_set(:@bindings, bindings)
      end
    end
  end
end