When it comes to Java 9, the lion’s share of coverage has gone to Project Jigsaw, the overarching (and incredibly tricky) effort to modularise the platform. So let’s turn our attention to some another big Java 9 initiative: Project Panama, which aims to open up a channel for Java developers to easily build native interconnections between code managed by the JVM and APIs for external libraries (similar to JNA (Java Native Access) or JNR (Java Native Runtime).
Once Panama is finished, Java developers will find it a whole lot easier to interface with libraries outside the traditional JVM space, for example C++, and the like. Or, as Oracle JVM Architect John Rose puts it, “If non-Java programmers find some library useful and easy to access, it should be similarly accessible to Java programmers.”
Though still a work in progress, the final implementation of Panama should include many of the following components:
- native function calling from JVM (C, C++), specifically per JEP 191
- native data access from JVM or inside JVM heap
- new data layouts in JVM heap
- native metadata definition for JVM
- header file API extraction tools (see below)
- native library management APIs
- native-oriented interpreter and runtime “hooks”
- class and method resolution “hooks”
- native-oriented JIT optimizations
- tooling or wrapper interposition for safety
- exploratory work with difficult-to-integrate native libraries
As Rose wrote way back in March 2014, the motivation behind Project Panama is fundamentally simple: the execution however, is considerably more complicated. In a report published last month, Mikael Vidstedt outlined just where the project is at.
Currently, Panama is still in the exploratory/research phase, so there’s a lot that could still change. Key areas still under evaluation include ways to enhance type safety and security, how to manage native resources, as well as support and bindings for languages such as C++, and many others.
The latest Panama prototype was release on Xmas Eve, constituting a prototype implementation of the binder. With this experimental code, the development team can run canonical test cases such as getpid, printf (varargs) and qsort (callbacks), as well other complex function types. Bear in mind it’s very much a rudimentary work, and could cause your VM to rebel in protest at this stage.
In other Java 9 (and beyond) news, towards the close of 2015, the Javadoc team have very helpfully implemented a Javadoc search box for version 9 (defined by JEP 225: Javadoc Search). As the name would suggest, this addition allows you to plug a search box into API documentation to hunt for program elements and tagged words and phrases within your documentation. The search box operates local searches, and requires no server-side input. If you want to join the testing effort, you’ll find it located in the upper right corner of the main panel.