This month we are focusing on OpenJDK projects you should know about. This time we will be covering Project Panama (we have also looked at Valhalla, Loom, Skara and Amber).
My understanding of this project was greatly helped by Maurizio Cimadamore’s talk at Devoxx Belgium, you can watch the whole talk here.
What is Project Panama?
Project Panama is the OpenJDK project which is focused on improving Java’s support for accessing native code. Java currently provides us with Java Native Interface (JNI), however this implementation:
- Is complicated to learn
- Has multiple possible points of failure
- Has little room for JIT optimization
- Requires you to also be able to program in C.
Because of this, the Java community has worked to make native code interactions more accessible, with libraries such as Java Native Access (JNA) and Java Native Runtime (JNR).
With this in mind, Oracle set up Project Panama. The aims are to:
- Provide a foreign interface at the Java level similar to JNA and JNR
- Optimize these calls at the JVM level
- Expand the supported model to include C++ functionality
- Make it easier for Java developers to run native code
Why is Panama important?
Being able to use native code can provide different benefits but normally it can be cut down to 3 reaasons:
- To access functionality outside of the JDK (Libraries like OpenGL for example)
- To gain better performance
- To interact with legacy code/systems
It is worth noting that if you want better performance: even if there is a good performance boost by using native code, you should take the performance cost of the interface into consideration, as it could negate any gains.
With Panama, all of the above are possible and more accessible to all Java developers. In the right circumstances, you can develop a better application for your users. You may very well find it is something you want to experiment with.
How will it do it?
Although there is the potential for the direction to change, Panama will make a more accessible method native code interface by:
- Using annotated interfaces to model the primitive types/objects in Java
- Generating the implementations on the fly with binding
- Providing us with an automated tool (JExtract) to generate the interfaces
- Getting the compiler to produce the library directly, rather than a header file that you then have to code with
Panama has a Java 12 early-access build which you can experiment with (now available for Mac, Linux and Windows on the latest release). The JExtract tool shows a lot of potential, I would recommend giving it a test.
If you want to follow the development of the project, you can always subscribe to the mailing list.
Have you used native code for your projects before? Are you looking forward to what Panama might bring?
Are you a Developer working with PDF files?
Our developers guide contains a large number of technical posts to help you understand the PDF file Format.
Do you need to solve any of these problems?
|Display PDF documents in a Web app|
|Use PDF Forms in a web browser|
|Convert PDF Documents to an image|
|Work with PDF Documents in Java|
2 Replies to “OpenJDK projects you should know about – Panama”
“Panama has a Java 12 early-access build which you can experiment with (curently only working on Mac and Linux)”. Please note that the latest panama early access is available for Windows as well.
Good spot! Many thanks for the correction, I have updated the post. It’s nice to see the latest build is even more accessible
Comments are closed.