Skip to main content

More Adventurous

Posted by editor on October 5, 2007 at 8:23 AM PDT

From the lowest-level language to one of the highest

Understand and believe that when articles are proposed, I do make the author justify "why it matters" to readers, so that you don't see 2,000-word treatises on concepts of purely academic interest with little or no practical application. I bring this up because the premise of today's new article -- calling Java from assembly language -- might well bring hackles of impracticality.

Biswajit Sarkar has already covered invoking assembly code from Java, which has a straightforward usefulness to those seeking performance in critical sections of code. But when he proposed going in the opposite direction, from assembly to Java, I had to ask "why would anyone ever need to do that". He replied in his second draft with an anecdote to say that he'd already been in a position where this was the right approach:

Some time ago, I was associated with an application to collect real-time data from a number of sources and save them in circular buffers so that new data would overwrite old data once the buffer got filled up. If a designated trigger event was sensed through a digital input, a fixed number of data samples would be saved in the buffers so that a snapshot of pre- and post-trigger data would be available. The original application was written in assembly language. After the application was used for a few months, it was felt that it would be very useful to have the application mail the snapshots to authorized supervisors whenever the trigger event occurred. Of course, it would have been possible to write this extension in assembly, but the team felt that in that particular instance it was easier to write that extension in Java and hook it up with the ASM program. As I had earlier worked with ASM-oriented JNI, I knew this could be done and, indeed, the project was implemented quickly and successfully.

Even if you're not an assembly language programmer with an occasional need to call out to Java's many capable libraries, taking another tour into the specifics of how JNI manages interfaces to native code may be useful for understanding just how your Java code interacts with the system.

So I hope you'll enjoy this Feature Article,
Launch Java Applications from Assembly Language Programs. Actually, with a lot of legacy assembly code out there, it's entirely possible that there could be some novel uses for the idea. Perhaps an assembly language program on an old mainframe could be exposed as an SOA by writing a small amount of new assembly to call out to Java-based SOA libraries? Who knows... we'll see if this is an idea that gains traction.

Unknown and undocumented properties are the focus of two of today's Weblogs, starting with