Migrating Speedment to Java 9
Speaker: Dan Lawesson @dan_lawesson
See the list of all blog posts from the conference
Cute – Spire their mascot on github has two years experience in that role
Since a library, want to be running with Java 9 as soon as it is released.
- Streams API ORM – customer.stream().filter(field.equal(value)).count();
- uses JVM memory acceleration, ode generation and modular design
- Type safety
- Works like streams – you don’t get any values back until terminal operation runs
- Have non-SQL code like a collector to convert the result into JSON
- can use findAny() with Optional on result – generates SQL limit statement
- Have finderBy so can join tables
- Like SQL, Streams are declared. Describe the what, not the how. But with SQL, you have to describe the result set format.
- A package must only belong to one modules. Yet it is common for two jars to have same package. The first one in the classpath takes precedence. In Java 9 must have only place for package.
- Automatic modules are for smoth transition to Java 9. It moves the Java 8 jars from the classpath to the module path. The jar automatically becomes a module
- However, automatic modules create split pakcages and can’t have those in Java 9
- sun.misc.Unsafe – should not be used but a key for real world Java success
- OSGi bundling is different than Jigsaw
Jigsawing the Java 8 open source application
- Running Java 8 under Java 9 JDK is easy
- Created module info file
- Brute force is to move all jars into depdencies in your monolithic module. When works, actually modularize app. Didn’t take this approach because already had OSGi modules
- Moduler approach: create directory for each module and move relevant packages to that directory. Add empty module-info.java (no requires/exports). That won’t compile so now can incrementally add dependencies and re-compile. Since this is iterative, they wrote a script to do it.
- Patch abuse of non-exported JDK APIs. Can add exports of java packages as a temporary workaround. Would need this flag at runtime if the temporary workaround isn’t removed. The workaround is just so you can identify all the issues and TBDs.
- Remove the OSGI bundling. Comment it out so building a jar instead of a bundle in Maven
- Use code generation so no reflection
- Harder becuase use sun.misc.Unsafe, third party dependencies with package issues
The first 20 minutes was about the Speedment library. I felt like that was a lot for a non-product talk. I wasn’t surprised because Dan was at my lunch table. And it was interesting. It just wasn’t necessary to understand the Java 9 part. Dan made a lot of references to things earlier in the day, which was nice. Also, the path Speedment took to move to Java 9 was very useful. I would have wanted to hear more about the issues in enterprise. Are they just outstanding issues. What do they plan to do if the libraries don’t release.