With ‘var’ it is possible to ad-hoc combine traits into an instance that matches your exact requirements. This allows for pretty cool experimentation, but unfortunately has some serious downsides.
Posts about concepts of the Java programming language. This does not include posts which merely employ Java to talk about something else.
Local-variable type inference with `var` makes it easier to work with anonymous classes, for example to create ad-hoc fields and methods. But does that mean you should use them more often? I think not.
With ‘var’ it is much easier to work with intersection types in Java 10 and later. You still need non-trivial tricks with generics to declare intersection types, but thanks to ‘var’ it is now easy to create local variables of such types.
On Java 10+, you can use application class-data sharing to reduce launch times, response time outliers, and memory footprint. By archiving class data with -Xshare:dump and loading it with -Xshare:on, the JVM’s class loading workload can be reduced considerably.
So, Java 9 came out last year… What now? Where to get started? If that’s what you’re asking yourself, then you’ve come to the right place! This Java 9 tutorial is a condensation of all you need to know to find your way around the new release, to get you ready to explore it in more depth.
Java 10 introduces ‘var’ which lets the compiler infer local variable types. Here’s how it works, why it exists, and how it impacts readability.
Using annotations from JSR-305 (@Nonnull, @Nullable, etc.) with others from the javax.annotation package (@Generated, @PostConstruct) on Java 9 causes a split package. Here’s the fix.
Learn all the module system basics in this tutorial: how to declare modules with module-info.java, compile, package, and launch them and what role the module path and readability graph play.
Java 9 introduces unified logging, a central mechanism configurable with -Xlog to observe class loading, threading, the garbage collector, the module system, etc.
Get your code running on the Java 9 Module System with the command line options –add-exports, –add-opens, –add-modules, –add-reads, and –patch-module.