Here are my notes from the talks I attended on Day Four at CodeOne (the successor toJavaOne). We have a summary report on our 4 highlights from Oracle CodeOne and you can find Monday’s here, Tuesday’s here, and Wednesday’s here.
I have added my takeaways at the end of each. Any mistakes or omissions are mine. Please add comments if you would like any items expanded.
The Future of Java SE [DEV6323]
- Aim to be open, evolving, nimble, scalable
- Adding very easy, changing very hard (and removing)
- JDK9 first release to remove stuff.
- Recovered new release model for JDK and slippage in past
- All previous Oracle commercial features now in OpenJDK.
- java product management blog good source for minor differences between Oracle and OpenJDK
- jdk.java.net for openjdk binaries
- New release means late binding of features (old releases very ‘waterfall’ type releases). In new release late freeze date very close to GA date.
- 180 EA builds of j9, 45 EA builds in j10, 27 EA builds in j11
- Still same speed of dev but split across more releases.
- J12 has 4 JEPS so far
- New tools to manage change.
- jdeps in J8 to show class dependencies
- If you use libraries you inherit any mistakes, uses of unsafe, etc
- in j9, jpedrscan shows deprecated api elements -for-removal flag limits to ones which will be removed
- Incubator modules for non-final apis to get feedback from j9
- Features can be seen in OpenJDK projects and will appear when ready
- Portola – containers.
- Valhalla – performance/memory
- Panama – better JNI
- Loom – fibers for threading
- Amber – lang improvements 9dynamic class-file constants, raw string literals,switch statements
- Project Skara – move to git
My takeaways – If you want to see where Java is heading check out the projects. The new tools make updating much easier
Benefiting from Java 9 Improvements [DEV5372] 2005
- Full room for Venkat
- Not covering modules as covered elsewhere
- interface now have private methods (can already have default and static). Cannot have private default. Should b used sparingly
- final in try with resources (finalise now deprecated in Java9. can implement AutoCloseable – added in J7 – in your code)
- In life and programming we seem to solve one se too programming only to create a new set of problems
- _ is internal symbol for “I don’t care” – used in Scala and Kotlin
- In j8 _ a warning and now error so can be used in later release for something.
- Stream – Java8 has limit and skip on stream but based on stream not valid values if you filter.Added takeWhile (like a break) and dropWhile (like Haskell).
- IntStream iterate makes it easy to replace for loops with increments other than 1 IntStream.iterate(0, i ->i <=15, i -> i + 3)
- Optional. Allows you to avoid null. Do not use as parameter for method. Optional unfortunately has get method which will throw error if no value. So avoid. use result.orElse(default) – in java11 orElseThrow(). Java 9 adds ifPresentOrElse() .ifFirst can take stream
My takeaways – While jigsaw is exciting, there is lots of other cool stuff in Java9
JDK 9, 10, and 11: Pitfalls for the Unwary
- Show of hands – virtually all audience on j8
- If on 8 now, move to 11 not 9 or 10
- Compatibility very important
- minor issues 1.4 to 5 – assert became keyword and enum now reserved
- Deprecation added in 1.1
- In j8 492 deprecated API elements, none removed so far
- J9 start long overdue cleanup to remove stuff
- Clean code should work
- in j9 big change module system
- 75 modules in OpenjdK (27 javase and 48 jdk). 14 additional in Oracle (8 javaFX, 2 oracle specific)
- Most internal APIs now encapsulated (sun.misc.Unsafe) – used in common libraries so you may be using them.
- You can ignore modulesystem
- Module jar to module path – becomes automatic module
- upgrade code to proper module
- You can use –illegal-access permit|warn|debug\deny (big kill switch) to allow old style access and turn off encapsulation. Also –add-exports/–add-opens for more granular control. Add-exports can be added in jar manifest
- java.se.ee module not included by default in j9/10 (reactivation, corba, xml)
- accessed via –add-modules All have standalone on Maven central. Can deploy on module or classpath
- _ is now a keyword (but __ okay for var name)
- Deleted 6 methods in j9 (mainly as issue with these in modularisation)
- new version strings now semantic versioning ie 1.8.0_131
- JNLP now strict parsing on config file
- ext directory now removed
- lots of GC options removed
- Logging changed in JVM (previously each had own)
- Lots of JVM flags removed
- 50 command flags no longer work and will stop JVM from starting if used
My takeaways – Documented key changes and ways to ease transition
Migrating Java UI Client Applications to OpenJDK 11 [DEV5990]
- Most desktop apps using J8. Recommended migration to j11
- Plugin, webstart, javafX not part of OpenJDK
- J7 first simultaneous release of OpenJDK and Oracle JDK
- most users still downloaded commercial releases and little OpenJDK testing as result
- Now converging means changes needed.
- Font rasterisation T2K >freetype
- lucida fonts removed in j11
- Anti-alias Ductus -> marlin
- JPEG classes gone (com.sun.jpeg.codec). Still java.imageio
- image processing Kodak >little cms. losing profiles for common colourspaces and replaced with Open source. But will give different results
- hiDpi support in windows. now scaled up to match. May need apps tweaking (ie Icon images scaled up)
- no javafX in j11 – needs downloading and adding
- Deployment technologies removed – plugin, webstart, appletviewer. Now need to be an application
- Plan to have packager in j12 to create bundles to run
My takeaways – lots of changes under the hood. Will need some planning to ensure not issue.
JUnit 5: The Next Step in Automated Testing for Java [DEV5916]
- Why change? (JUnit 4 released 2006)
- Modernise (use J8)
- backwards compatible
- 3 major modules:-
- vintage (backward compatibility)
- Platform (test launch and tooling)
- Jupiter (new cool stuff)
- Demo to show backwards compatibility.
- JUnit5 replaces rules with extension model. @RuleMigrationSupport annotation needed in J5 if you still use
- assertAll make sit easy to run all tests
- @DisplayName and Emoji support
- Some language changes to clarify usage
- Extendwith Extension API
- Dependency Injection (ie for a mock)
- TestInfo object available
- @ValueSource allows easy definition
- Repeated tests
- Dynamic tests
- Test interfaces
- tests can be disables via OS, jdk version, custom logic
- parallel test execution
- Nested tests
My takeaways – Great backwards compatibility but worth updating the tests to use new features
The Seven Deadly Sins of Software Development [DEV6081] [DEV5916]
- 1. No tests. Legacy code is code with no tests. Avoid the copy/paste design pattern
- 2. god objects. One huge class
- 3. comments. Delete commented out code. Comments should be safe,legal and rare.
- 4. dead code. kill it.
- 5. Driving without a seat belt. Antiviruses, locking down windows (shutup10), sandbox your browser, vpn and browsers
- 6. Not knowing tool you use. Learn to type as keyboard main input device. and have a decent keyboard. Then use keyboard shortcuts
- 7. bad names. being lazy.
My takeaways – great fun session to finish the show!