InfoQ Homepage News JRuby Roundup: Java Integration and Debugging (JSR-45) Improvements
JRuby Roundup: Java Integration and Debugging (JSR-45) Improvements
This item in japanese
Aug 18, 2008 2 min read
Write for InfoQ
Feed your curiosity. Help 550k+ globalsenior developers
each month stay ahead.Get in touch
Charles Nutter shows some of the recent improvements in JRuby's Java Integration:
0. Obviously, there's been a lot of performance work.
1. Closures can be passed to any method with an interface as its last argument; the closure will be converted to the target interface type. thread = java.lang.Thread.new { puts 'here' }
2. Interfaces can be implemented using Ruby-cased (underscored) names for all methods now.class Foo
3. Interfaces with bean-like methods can be implemented using attr*. [..]
include java.awt.event.ActionListener
def action_performed(event)
...
end
end
4. Interfaces with boolean methods can be implemented using the question-marked version of the method name.
Another improvement is the use of JSR-45 features to improve debugging (Note: link seems to be broken at the time of publication). JSR-45 allows to map source files and source lines to class files. JSR-45 defines class attributes (SourceDebugExtension) that contain metadata in the SMAP format defined in the JSR to define which input source file a class file comes from. A look at the compiler code shows that line number information is already being added to the generated class files. ASM, used for generating the class files, allows to set line numbers via the
visitLineNumber
method. With the addition of SMAP files, regular Java debuggers, eg jdb, can step through Ruby code compiled to bytecode (sample pastie showing how to step through a Ruby file using jdb).
The new capabilities are another step towards a fast debugger for JRuby - however it's important to note that this method only works for code that gets compiled to bytecode. Code that is interpreted still needs to be handled by the existing trace or hook based debuggers. How much of an applications code is turned into bytecode depends on a couple of factors. For instance, there's the risk of running out of PermGen space, which usually ends in a JVM crash/termination. To solve that, the JRuby JIT limits the amount of compiled methods (the limit can be configured).
This content is in the Java topic
Related Topics:
-
Related Editorial
-
Related Sponsors
-
Popular across InfoQ
-
AWS Introduces ECS Managed Instances for Containerized Applications
-
Producing a Better Software Architecture with Residuality Theory
-
GitHub Introduces New Embedding Model to Improve Code Search and Context
-
Google DeepMind Introduces CodeMender, an AI Agent for Automated Code Repair
-
Building Distributed Event-Driven Architectures across Multi-Cloud Boundaries
-
Mental Models in Architecture and Societal Views of Technology: A Conversation with Nimisha Asthagiri
-
Related Content
The InfoQ Newsletter
A round-up of last week’s content on InfoQ sent out every Tuesday. Join a community of over 250,000 senior developers. View an example