How Do Annotations Work in Java?

Annotations have been a very important part of Java, and it’s been there from the time of J2SE 5.0. All of us have seen annotations like  @Override and @Deprecated in our application code at some place or another. In this article, I will discuss what exactly annotations are, why they were introduced, how they work, how to write custom annotations (with example code), what could be valid scenarios for annotations, and lastly annotations and ADF. It’s going to be a long post, so grab some coffee and get ready to dive into the world of annotations.

What Are Annotations?

One word to explain annotation is metadata. Metadata is data about data. So annotations are metadata for code. For example, look at the following piece of code.

Corda – Extending and Overriding Flows From External CorDapps

Recently, Corda 4 was released, bringing with it a ton of new features to make Corda more enjoyable to work with. To be honest, I am kind of assuming there are a lot of new features. I had a quick browse through the changelog, mainly to see my contributions being referenced, but I remember seeing a lot of lines of text. That has to be a good thing, right?

Anyway, one of these features is the ability to extend and override Flows. It doesn’t really sound very fancy when you realize that Corda is written in Kotlin and has inheritance completely baked into it (true for Java as well). But, there is more to it than that. Corda needs to map an Initiating Flow to the counterparty Flow that is responding to it.