Hello all,
I am trying to use the JRuby profiler in a OSGi environment. I enable
the
API mode of the profiler via the Ruby container
OSGiScriptingContainer.setProfile method, and I set it to
ProfileMode.API.
With that, I can run simple profile queries with code like this:
require ‘jruby/profiler’
profile_data = JRuby::Profiler.profile do
(1…10).count
end
my_output_stream = java.io.ByteArrayOutputStream.new
print_stream = java.io.PrintStream.new(my_output_stream)
profile_printer = JRuby::Profiler::GraphProfilePrinter.new(profile_data)
profile_printer.printProfile(print_stream)
However, when I try to print the profile data of real code (in my case,
stuff using Datamapper) I get a Null pointer exception in the
AbstractProfilePrinter class:
Ruby error: Native Exception: ‘class java.lang.NullPointerException’;
Message: null; StackTrace: java.lang.NullPointerException
at
org.jruby.runtime.profile.AbstractProfilePrinter.getMethodName(AbstractProfilePrinter.java:100)
at
org.jruby.runtime.profile.AbstractProfilePrinter.methodName(AbstractProfilePrinter.java:86)
at
org.jruby.runtime.profile.AbstractProfilePrinter.isThisProfilerInvocation(AbstractProfilePrinter.java:80)
at
org.jruby.runtime.profile.AbstractProfilePrinter.isProfilerInvocation(AbstractProfilePrinter.java:75)
at
org.jruby.runtime.profile.AbstractProfilePrinter.isProfilerInvocation(AbstractProfilePrinter.java:75)
at
org.jruby.runtime.profile.GraphProfilePrinter.printProfile(GraphProfilePrinter.java:59)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at
org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(JavaMethod.java:525)
I followed up the code with a debugger, and it seems that the failing
code
it’s trying to find a method’s name.
Any ideas?
Thanks, Lorenzo.