September is off to a busy start for many Java developers, and no busier than right here at JetBrains. Sweeping the chimney and stacking the wood, patching the roofs and packing the goods, we’re making our lists and checking them twice. Each month, we collect the best Java recipes, and each month we find new ingredients to use. Food for thought, from our kitchen to yours – compliments of developers like you.
For a language over twenty years old, the Java community has seen a flurry of recent activity and is still growing, with sweeping changes surrounding proposed rollout of Java 9. Thanks to an early emphasis on programming education, millions of young developers are graduating schools with Java language experience, and will continue to fuel the Java ecosystem with talent for many years to come.
The State of the Module System – Premiering in Java 9, the Java Module System sets the stage for a new kind of dependency system, one where modules are the primary unit of organization. True dependency resolution is a notoriously difficult task, but given the scope and timeline of the JSR, certain compromises are expected. Mark Reinhold outlines some of the technical and strategic decisions around the proposed solution.
A Post-Apocalyptic sun.misc.Unsafe World – Another major part of the Jigsaw puzzle is JDK modularization, an ambitious and longstanding goal of Project Jigsaw. One of the casualties of that restructuring process is the removal of
sun.misc.Unsafe. Despite stalwart opposition to this change, there are a number of options for those planning to adopt Java 9. Christoph Engelbert at HazelCast describes a number of those alternatives.
The real magic of Java happens behind the scenes. Some of the most innovative new language features are not found in conventional Java, but thanks to the JVM, new and coming-of-age developers seeking more powerful languages have a variety of excellent choices to express their ideas, and deploy them to billions of potential devices. JVM-based technologies will be around long after we forget what the “J” was ever for.
Kotlin M13 is here – Kotlin M13 brings dozens of new features to a rapidly maturing language. This includes a host of new language features, Java interop adjustments, a new reflection library and compiler tools, and IDE improvements across the board. M13 is one of the largest releases to date, and we’re extremely excited to introduce these features and hear your feedback.
JVM Language Summit 2015 – For language enthusiasts, the annual JVM Language Summit has a wealth of valuable information from language implementors to JVM engineers. You can learn about Flexible Types in Kotlin or LINQ-style Queries in Java, understand the history and fate of sun.misc.Unsafe, and preview upcoming changes to the bytecode architecture.
Android runs a forked version of the Java language, and represents Java’s only significant presence on consumer mobile devices. It is unclear how long that presence will last, and given the nature of the relationship between the two camps, the Java API stands on shifting ground. With Java 8 now live and pending further changes in 9 and 10, Java SE is quickly diverging from its Android counterpart with little sign of a happy reunion.
Supercharging Your Android Testing – Navigating the Android testing landscape can be a challenging prospect, with unit tests, instrumentation tests, functional UI tests, devices, IDEs and emulators. Ellen Shapiro, mobile engineer at Vokal gives a great introduction to Android testing with the new JUnit runner and Espresso, a framework for simulating user interactions and programmatically testing the results.
Offensive and Defensive Android Reverse Engineering – One topic that does not receive enough attention in Android development is reverse engineering. In order to properly secure Android applications, developers must be aware of the risks and methods used by malicious adversaries, and for many developers, that experience will only come from learning their vulnerabilities and collaborating with security professionals.
qark – For security conscious Android developers, qark is a static analysis tool for APKs that detects a wide variety of common vulnerabilities when developing Android applications, from private keys embedded in source code, to improper certificate validation, to unintentional data leaks and more. Built by LinkedIn, qark has tools for decompiling source code and providing automatic diagnoses for these issues.
Last month, we looked at the Spring framework, and how it can help you build enterprise class web applications. This month, we’ll take a closer look at Akka, a framework that uses actor-based concurrency to help build distributed applications on the JVM. With the rise of the Reactive Manifesto, actor frameworks are a common pattern today, but as one of the earliest to arrive on the JVM, Akka is also one of the most mature.
Designed for the Scala language, Akka can also be used in pure Java and Kotlin, albeit with a slightly different syntax. The premise is simple enough: in procedural programming the primary means of executing code is by calling a function. In Akka, actors (which are basically just POJOs with a callback) send and receive messages asynchronously. There is no synchronization or shared state, actors encapsulate data and reactions. For a good introduction, this article will help you get started.
If you are familiar with microservices this should start sounding very familiar. For a good example of how to build an HTTP microservice with Akka, have a look at this example. Akka also has a number of components for communicating over a network, persisting data, and clustering nodes over a P2P protocol. More recently, Akka has been working on a reactive streams implementation and improving type safety. For more examples and the latest features in Akka, head over to the Typesafe blog.
With Java’s enormous popularity, it is not surprising how much innovation happens in the Java community. It would be impossible to feature all the great content that Java developers create each month, but there is a common thread. Either thanks to Java’s conventions or in spite of them, these developers find some incredible ways to bend the rules. Some take it as a challenge. Others, a chore. But their creativity is indisputable.
Common SQL Clauses and Their Equivalents in Java 8 Streams – The use of fluent interfaces for modeling state-machinery seems to be an emerging pattern recently, made further possible with the help of Java’s new functional approach. There are a lot of parallels between functional programming and relational databases, and this is evident in the number of LINQ-related tools for Java, like DKO, Jinq, jOOQ and QueryDSL. Lukas Eder, creator of jOOQ and jOOλ, discusses the uncanny similarity between SQL operations and their Java Stream equivalents.
HTML in Java – A little-known compiler flag introduced in Java 8 now allows Java code to read parameter names through runtime reflection. This feature lets developers to use the additional metadata for things like writing inline HTML. Benji Weber implements a proof of concept for this idea to generate HTML, and by leveraging Java’s type system, gets compile-time HTML validation in the process. How cool is that?
Unrolling loops at runtime with Byte Buddy – When writing an unsafe version of ArrayList, Andrew Brampton had an interesting observation. He noticed that copying objects into off-heap memory from a loop was about two times slower than unrolling the same loop before compilation. In this article, he discusses how to use ByteBuddy, a runtime bytecode generator, and JMH to speed up an unsafe ArrayList and benchmark the results.