How to Build Java Applications Today: May 3, 2021
Tags: java, bpf
Published: 2021-05-03 21:25:07

---
canonical_url: https://bpfnl.substack.com/p/how-to-build-java-applications-today-8b9
---

## TLDR
javac “—release” flag, Java 8 security updates until 2030, SOLID principles, Jira for all, Micronaut 2.5, and Spring Data 2021.0.

***

## README
This is **issue 34** of my weekly newsletter, “How To Build Java Applications Today”. I read all the Java newsletters, so **you** don’t have to! And I try to entertain you a bit while presenting Java news.

If you like my newsletter, then [subscribe to it on Substack](https://bpfnl.substack.com)!

***

## Quote of the Week
*‌The universe is a cruel, uncaring void. The key to being happy isn't a search for meaning. It's to just keep yourself busy with unimportant nonsense, and eventually, you'll be dead.*
[Mr. Peanutbutter](https://www.goodreads.com/quotes/9096421-the-universe-is-a-cruel-uncaring-void-the-key-to), a character in the animated TV show “[Bojack Horseman](https://en.wikipedia.org/wiki/BoJack_Horseman)”, misses out on writing yet another life-affirming self-help book.

***

## Stand-Up
It’s been a quiet week for me: No talks, no conferences, no articles, just working on [my web & mobile apps](https://yourhomeingoodhands.co.uk). 

***

## Code Review
### Issue 33 from April 26, 2021
I wrote about the GraalVM 21.1 release in the last issue and said this about its multi-tier compilation:
> Because some optimizations now run later, we also get “later peak performance”. 

Oleg Šelajev ([@shelajev](https://twitter.com/shelajev)) [replied on Twitter](https://twitter.com/shelajev/status/1386937564418953216):
> Multi-tier in GraalVM helps reach peak performance *faster*, not later.

He also pointed to [this Twitch video](https://www.twitch.tv/videos/996724689) for detailed explanations. 

Oleg is partially correct: In some scenarios, GraalVM 21.1 **does** reach peak performance **faster**. The [multi-tier explanation article I linked to](https://medium.com/graalvm/multi-tier-compilation-in-graalvm-5fbc65f92402#afbe) has an [example](https://medium.com/graalvm/multi-tier-compilation-in-graalvm-5fbc65f92402#cae7):
> Nevertheless, we can see that multi-tier approaches peak faster, especially early on.

But the article also shows scenarios where peak performance is achieved **later**, as I claimed last week was always the case. Here’s [the first one](https://medium.com/graalvm/multi-tier-compilation-in-graalvm-5fbc65f92402#afbe) (highlights are mine):
> In many practical scenarios, we are interested in **short-running programs** such as command-line tools or single unit-test executions. In **other scenarios**, we expect that the program achieves decent execution performance as soon as possible, even if it achieves the **best possible peak performance much later**.

So some long-running programs achieve peak performance **later**. The same is true for a program called [TruffleSqueak that the article cited](https://medium.com/graalvm/multi-tier-compilation-in-graalvm-5fbc65f92402#d9a6):
> As an expected tradeoff, it takes a bit longer to reach peak performance.

So my categorical statement about “later peak performance” in the last issues was wrong. Instead, it’s a mixed bag: Some programs reach peak performance earlier, some later. I should have read the article more carefully. 

Thank you, Oleg, for pointing this out!
 
***

## Bookmarks
### Java
#### javac “—release” Flag
Java compilers can produce byte code that runs in earlier Java versions. But what happens if our code uses a Java API that’s not available in that earlier Java version?

We’ll get a runtime error, as it turns out. You can try yourself:
- Write code that calls `List.of()` (which is only available in Java 9).
- Compile this with Java 9 or later and use `—source 1.8` and `—target 1.8`. to create bytecode for Java 8.
- Then run the compiled code in Java 8. Boom - `java.lang.NoSuchMethodError`!

The way to fix this is by using the compiler flag `—release 8` instead. That will now give a compile-time error on `List.of()`. Yeah, I didn’t know this flag either!

How does Java 9 know about the `List` methods of Java 8? Read this excellent article to find out! I stole my example there.

BTW: In my current project, I work the other way around: I compile with Java 14 and run with Java 15. I would love to compile & run with Java 16. But that’s as far as I got without compilation or runtime error that I just didn’t  want to deal with.

[Article](https://www.morling.dev/blog/the-anatomy-of-ct-sym-how-javac-ensures-backwards-compatibility)

***

#### Oracle Provides Java 8 Security Updates Until 2030
Here’s an article you want to hide from your boss. Bad: Java 8 is still the most used Java version (69% market share, according to JRebel - see [issue 27](https://bpfnl.substack.com/p/how-to-build-java-applications-today-4b3), “JRebel 2021 Java Technology Report”). Worse: We can run Java 8 until 2030 if we pay Oracle for “Extended Support”!

Truth be told, Oracle [announced this last year](https://www.infoworld.com/article/3532358/oracle-extends-extended-support-for-java-8.html). But hey, I started this newsletter only [last September](https://bpfnl.substack.com/p/how-to-build-a-java-application-today), so it’s news to me. 😀

So, why am I showing you this? Because it’s better you learn the bad news **before** your boss tells you: “No need to upgrade to Java 17 because we can stay on Java 8 for ten more years!”
  
[Oracle Java SE Support Roadmap](https://www.oracle.com/java/technologies/java-se-support-roadmap.html)

***

### Software Engineering
#### SOLID Principles in Java 
SOLID is an abbreviation to die for:
- **S**ingle Responsibility Principle
- **O**pen-Closed Principle
- **L**iskov Substitution Principle
- **I**nterface Segregation Principle
- **D**ependency Inversion Principle

If you’ve never heard of SOLID or need a refresher, then this article is for you. 

As with many of these laws & principles, I find myself sometimes breaking them. For instance, my classes sometimes have more than one responsibility, violating the “S” in “SOLID”. I’d like to think that I’ve gotten better there over the years (Jonathan, if you read this, I’m terribly sorry for `BusinessMethods`). But then again, maybe I’m just fooling myself, and nobody tells me because I code alone these days…

[Article](https://www.jrebel.com/blog/solid-principles-in-java)

***

### Tools
#### Jira For All?
Jira is hands-down the best issue tracker I’ve ever used. And I’m not just saying that because I was as Jira/Confluence admin for many years. At least I think I don’t.

Well, Jira doesn’t want to be an issue tracker just for **developers** anymore. Instead, it now wants to organize the work of “*all* teams within an organization”. So [Atlassian](https://www.atlassian.com), the makers of Jira, released “Jira Work Management for business teams like marketing, HR, finance, operations, design, legal, sales, and more”. They also [updated the issue view](https://support.atlassian.com/jira-core-cloud/docs/what-is-the-new-jira-issue-view). That’s great because the issue view was already confusing to unsuspecting developers, let alone mere mortals.

Why is Atlassian doing this? Here’s my answer, and it’s pure speculation on my part.

First of all, it’s always good if you can dramatically expand the market for your product/service, as Atlassian just did.

Secondly, Jira faces more competition in their biggest market - developers. As I reported in January about [Spring Data’s migration from Jira to GitHub issues](https://betterprojectsfaster.com/blog/weekly-links-2021-01-25#spring-datas-migration-from-jira-to-github-issueshttpsspringioblog20210107spring-data-s-migration-from-jira-to-github-issues), when your code is in GitHub, then GitHub issues offer several advantages over Jira: 
- One login
- No additional issues for pull requests anymore
- Auto-linking references to issues, pull requests, source code, and commits across all GitHub projects
- Mention & notify any GitHub user

This probably also applies to [Gitlab](https://about.gitlab.com), but they have less market share than GitHub.

For Atlassian, the beauty of “Jira Work Management” is that GitHub probably won’t copy this: GitHub [belongs to Microsoft](https://techcrunch.com/2018/06/04/microsoft-has-acquired-github-for-7-5b-in-microsoft-stock/), and Microsoft sells [Microsoft 365](https://www.microsoft.com/en-us/microsoft-365) for enterprise collaboration.

[Atlassian announcement](https://www.atlassian.com/blog/announcements/introducing-jira-work-management)

***

### Releases
#### Micronaut 2.5
That was quick: Only seven weeks after Micronaut 2.4 (see [issue 27](https://bpfnl.substack.com/p/how-to-build-java-applications-today-4b3), section “Micronaut 2.4 Released”) we already get version 2.5. But I guess that’s one way of differentiating from Spring Boot - they only release every six months.

So, how much can you do in seven weeks?

Not a lot of features, as it turns out: Micronaut Data now supports Java 16 records, Kotlin immutable data classes, reactive data sources with R2DBC, and optimistic locking. The “dependency bump department” contributes Java 16, Gradle 7, and GraalVM 21.1. And those are the big-ticket items.

 Not bad for seven weeks, but a bit “micro” in scope for a major release. I know, a bit of a cheap shot, but I didn’t call the framework “Micronaut”, they did!

[Announcement](https://micronaut.io/2021/04/30/micronaut-framework-2-5-released/)

***

#### Spring Data 2021.0
Talking about six-month release cycles: Spring Data just had its second one. Well, they must have gotten much more done than the Micronaut guys, right?

Nope: Query by example now works with [reactive JDBC datasources](https://r2dbc.io), Cassandra prepared statements are supported, and we can use the [Domain-Driven Design](https://en.wikipedia.org/wiki/Domain-driven_design) (DDD) annotations from [jMolecules](https://github.com/xmolecules/jmolecules).

But then again - it’s a Spring project, it’s the incumbent (JRebel pegs Spring Boot’s market share at 62% - see [issue 27](https://bpfnl.substack.com/p/how-to-build-java-applications-today-4b3), “JRebel 2021 Java Technology Report”). So it doesn’t need to be the best or the fastest. It just needs to be not much worse than, say, Micronaut Data.

[Announcement](https://spring.io/blog/2021/04/20/what-s-new-in-spring-data-2021-0)

***

## About
Karsten Silz is the author of this newsletter. He is a full-stack web & mobile developer with 22 years of Java experience, author, speaker, and entrepreneur. Karsten got a Master's degree in Computer Science at the Dresden University of Technology (Germany) in 1996.

Karsten has developed software in five European countries and the US. In 2004, he co-founded a software product start-up in the US. During power outages, the software protected TV, Internet, and phone services for 50 million North American cable TV households. Karsten led product development for 13 years and left after the company was sold successfully.  

Karsten has worked as a contractor since 2017. He co-founded the UK SaaS start-up "[Your Home in Good Hands](https://yourhomeingoodhands.co.uk/)" as CTO in 2020.

Karsten has [this newsletter](https://bpfnl.substack.com/), a [developer website](https://betterprojectsfaster.com/), and a [contractor site](https://ksilz.com/). He's on [LinkedIn](https://www.linkedin.com/in/ksilz/), [Twitter](https://twitter.com/karsilz), and [GitHub](https://github.com/ksilz).