1. #encoding: utf-8
  2.  
  3. require 'singleton'
  4. require 'java'
  5.  
  6. java_import org.slf4j.Logger;
  7. java_import org.slf4j.LoggerFactory;
  8. java_import 'ch.qos.logback.classic.LoggerContext';
  9. java_import 'ch.qos.logback.core.Context';
  10. java_import 'ch.qos.logback.core.util.StatusPrinter';
  11.  
  12.   class Wisper
  13.     include Singleton
  14.     include Java::ChQosLogbackCore.Context
  15.     #include Java::ChQosLogbackClassic.LoggerContext
  16.  
  17.     def test0(name)
  18.       lc = LoggerFactory.getILoggerFactory
  19.       StatusPrinter.print(lc)
  20.       # ↑ this call return
  21.       # org.jruby.exceptions.RaiseException: (NameError) no method 'print' for arguments (org.slf4j.impl.Slf4jLoggerFactory) on Java::ChQosLogbackCoreUtil::StatusPrinter
  22.     end
  23.  
  24.     def test1(name)
  25.       lc = LoggerFactory.getILoggerFactory
  26.       stprint = StatusPrinter.java_method :print, [Context.java_class]
  27.       stprint.call(lc)
  28.       # ↑ this call return
  29.       # org.jruby.exceptions.RaiseException: (TypeError) failed to coerce org.slf4j.impl.Slf4jLoggerFactory to ch.qos.logback.core.Context
  30.     end
  31.  
  32.     def test2(name)
  33.       lc = LoggerFactory.getILoggerFactory.to_java(LoggerContext.java_class)
  34.       # ↑ this call return
  35.       # org.jruby.exceptions.RaiseException: (TypeError) unable to convert to type: ch.qos.logback.classic.LoggerContext
  36.       stprint = StatusPrinter.java_method :print, [Context.java_class]
  37.       stprint.call(lc)
  38.     end
  39.  
  40.     def test3(name)
  41.       lc = LoggerFactory.getILoggerFactory
  42.       stprint = StatusPrinter.java_method :print, [Context.java_class]
  43.       stprint.call(lc.java_object)
  44.       # ↑ this call return
  45.       # org.jruby.exceptions.RaiseException: (NoMethodError) undefined method `getStatusManager' for #<Java::JavaObject:0x7cfecfcb>`
  46.     end
  47.  
  48.   end
  49.  
  50.  
  51. Wisper.instance.test3('mylogger')