Forum: JRuby Null pointer exception when printing profiled data

Posted by Lorenzo Jorquera (Guest)
on 2012-12-26 19:05
(Received via mailing list)
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.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.