How time flies when you’re having fun! Two years ago, we brought you the Annotated Java Monthly, now J.A.M. (homemade at JetBrains) and thanks to tasteful readers like yourself, we now have a number of flavors including the PHP Annotated, C++ Annotated and the Kotlin Digest for you to enjoy. Filled with the freshest ingredients, and following the finest recipes, we preserve all the ripest content, picked from the tallest branches of the most fruitful repositories around the web. Here’s a fresh batch right now, straight from our kitchen to yours. Bon appétit!
Java continues to evolve in the face of increasing pressure from large corporations and special interest groups, cause for concern among some in the Java community. While most will agree that Java’s widespread popularity and strong growth speaks for itself, it is no wonder that some should explore other alternatives. Yet Java’s competition is also the source of some of it’s greatest innovation. Were it not for Java, we might not have C#. Were it not for C#, we might not have Rx*. And now, RxJava may soon appear in JDK 9. For every action, there is a reaction.
Project Jigsaw: The module system – Following a series of trials and tribulations that started nearly a decade ago, the long-awaited Project Jigsaw now arrives in mainline builds of JDK 9, signaling a key milestone on the road to Feature Complete. Project Jigsaw originally sought to modularize the JDK, but since expanded to provide support for modular JARs through the JMS spec. Due for release next March, Java 9 also includes support for a brand new Java-based shell, convenience factory methods for collections, enhanced method handles, and much more.
Reactive Java EE – Developers have been using the word “reactive” a lot lately. An unfortunate (or perhaps deliberate) coincidence, is the similarity between reactive programming, Reactive Extensions, and React (perhaps they all liked the name). More recently, all three were co-opted by a broadly unrelated document called the Reactive Manifesto, a kind of high-level pattern for building software systems. Ola Petersson, Software Engineer at Squeed, demonstrates how to implement some key reactive concepts (of the latter sort) using Java EE.
Javaslang – Inspired by Scala, Javaslang is a dyed-in-the-wool functional programming library that provides a number of persistent data types and functional control structures to Java developers. While Java 8 was always intended as middle road between functional programming and familiar OOP, there are clearly some areas where Java’s Collection API could have used some refinements. Javaslang promises a more succinct API that has the benefit of things like pattern matching and reducing cyclomatic complexity. For details, see the documentation.
Android N spells an end to Apache Harmony, and the beginning a new era for Java on Android. While most users will be none the wiser, the switch to OpenJDK introduces some potential caveats, as well as subtle performance and behavior changes. Most notably however, Android developers can now avail themselves of new language features in Java 8, enjoyed by the Java SE community for well over two years. These include Java’s highly anticipated lambda expression syntax, and a completely retooled compiler toolchain. Give Android N Preview a try today!
Android Studio 2.0 – Built by the Android Tools team at Google in collaboration with JetBrains, Android Studio brings dozens of new features from IntelliJ IDEA 15, as well as Instant Run, GPU debugging, cloud test lab integration, and a brand new emulator that is dramatically faster and more user friendly. For Android N support, developers will need Android Studio 2.1 Preview. To learn more about the latest features in Android Studio, subscribe to Android Tool Time with Reto Meier, and follow recent updates from the Android Studio Project Site.
The Evolution of Android Architecture – Serge Zaitsev, longtime Android developer and creator of the Anvil library for building reactive views on Android, gives an account of Android development since the early days, from XML and nested inner classes, to lambdas and databinding, and shows us what building Android UIs with a fully reactive, MVVP design might look like. Considering how far Android has come since 2013, it is not difficult to imagine a project like Anvil becoming more mainstream. For examples on how to use Anvil, follow Serge’s blog.
The Shortcomings of Android Thread Annotations – First introduced with Android Support Annotations 22.2, thread annotations are part of a larger effort to help the compiler detect bugs and flag threading performance issues. These annotations let developers add metadata in specific locations to preemptively catch particular classes of bugs via static analysis. But as Android developer Michael Comella observes, in certain cases, these inspections may not be powerful enough, and can fail under method delegation. At least in theory, this issue should be fixable.
The Java community is home to many people – by some counts, there are between 6-10 million individual Java developers around the world. On most months of the year, less than a hundred of them write a technical blog post or share a programming lesson in Java, and less than ten have ever submitted to the Java Annotated. Here is a true fact: we have never turned down a user submission. We have thousands of readers. If you’re reading the Java Annotated, write to us! You have a story to tell, and we want to learn from you! Your next bright idea could be here.
Debugging an Annotation Processor – Java annotations are a common sight in any modern application framework. But unless you write Java middleware, you may have never had the pleasure of debugging an annotation processor. Annotations are processed during compilation, which introduces additional difficulty if you are using a build tool like Gradle. Although there is limited support in Android Studio or IntelliJ IDEA for debugging annotation processors, Santiago Castro may be able to help you in this area. Santiago Castro is a software engineer at xmartlabs.
Points of @Contention – False sharing is an well documented phenomenon in performance circles. The trouble occurs when multiple cores access data stored in a single, shared cache line, causing a measurable delay. For many years, the solution was to pad critical path variables using some sort of data structure to guarantee they would never be land in physically adjacent memory. Java 8 introduced the
@Contended annotation, to solve this problem. Chris Mowforth tells us the full story, with benchmarks to prove it. Chris is a senior engineer at Logentries.
SASI Empowering Secondary Indexes – A common data retrieval task, is given content, to find the document. The inverted index, or secondary index in Cassandra, lets users do just this, but comes with certain performance tradeoffs. Hanneli Tavante demonstrates how to use SASI, a more flexible alternative that offers configurable secondary indices based on the underlying data set. Cassandra is a distributed data store built on Java that offers linear scalability and eventual consistency. Hanneli is a software developer and Cassandra expert at Codeminer 42.