Paul Krill
Editor at Large

Jabel brings post-Java 8 features to Java 8 users

news
Sep 5, 20192 mins

Using the ‘annotation processor,’ developers can take advantage of the latest Java language features and still compile to Java 8 bytecode

java coffee cup with number 8 froth eight by undefined undefined getty
Credit: undefined undefined / Getty Images

Do you want to stay on Java 8 while taking advantage of the latest Java syntax and features? A tool called Jabel enables this because, as its GitHub page states, “life is too short to wait for your users to upgrade their Java.”

Jabel is an “annotation processor” that instruments Java compiler classes and treats some Java 9 and later language features as if they were supported in Java 8. The result is valid Java 8 bytecode for switch expressions, var declarations, and other features not supported in Java 8. Basically, Jabel tricks the compiler into thinking that certain features were developed for Java 8 by removing the checks that report them as invalid for the Java 8 target.

Jabel is in a proof of concept stage at this point, with developer Sergei Egorov even referring to it as a “hack.” The Jabel page stresses that the majority of open source libraries are still using Java 8 as their target. But since most new language features introduced after Java 8 did not require a change in bytecode, the javac compiler could emit Java 8 bytecode even when compiling sources from Java 12.

Jabel also allows developers to use Java 13 syntax in the GraalVM virtual machine. Java 13 is due for a production release on September 17. Jabel is similar to Project Lombok, a Java library intended to reduce boilerplate code, but does not contain any business logic, Egorov said. In explaining his motivation behind developing Jabel, Egorov said other languages have adopted source transformation pipelines, particularly JavaScript, and this inspired him to try the same for Java. Java 8 was introduced in March 2014. The current release of Java is version 12.

Instructions on using Jabel can be found on GitHub. A plug-in for Jabel is distributed with the JitPack package repo.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a “Best Technology News Coverage” award from IDG.

More from this author