I'm not well known for my love of annotations. While I do recognise that they can serve a very limited purpose in some areas (e.g. hinting stuff to the compiler or extending the language where we don't want new keywords), I certainly don't think they were ever meant to be used for API design. "unfortunately" … Continue reading The Java Ecosystem’s Obsession with NonNull Annotations
Tag: annotations
JSR-308 and the Checker Framework Add Even More Typesafety to jOOQ 3.9
Java 8 introduced JSR-308, which added new annotation capabilities to the Java language. Most importantly: Type annotations. It is now possible to design monsters like the below: https://twitter.com/lukaseder/status/711612663202238464 The code displayed in that tweet really compiles. Every type can be annotated now, in order to enhance the type system in any custom way. Why, you … Continue reading JSR-308 and the Checker Framework Add Even More Typesafety to jOOQ 3.9
jOOQ 4.0’s New API Will Use Annotations Only for Truly Declarative Java/SQL Programming
SQL is the only really popular and mature 4GL (Fourth Generation Programming Language). I.e. it is the only popular declarative language. At the same time, SQL has proven that turing completeness is not reserved to lesser languages like C, C++, or Java. Since SQL:1999 and its hierarchical common table expressions, SQL can be safely considered … Continue reading jOOQ 4.0’s New API Will Use Annotations Only for Truly Declarative Java/SQL Programming
Improve Your JUnit Experience with this Annotation
JUnit is probably part of 90% of all Java projects. And the exciting thing is, we'll soon have JUnit 5 with Java 8 support. We've blogged about an improvement recently. Back in JUnit 4 land, there's this little trick that I can only recommend you put in all of your unit tests. Just add this … Continue reading Improve Your JUnit Experience with this Annotation
Use JUnit’s expected exceptions sparingly
Sometimes, when we get pull requests for jOOQ or our other libraries, people change the code in our unit tests to be more "idiomatic JUnit". In particular, this means that they tend to change this (admittedly not so pretty code): @Test public void testValueOfIntInvalid() { try { ubyte((UByte.MIN_VALUE) - 1); fail(); } catch (NumberFormatException e) … Continue reading Use JUnit’s expected exceptions sparingly
We’re Taking Bets: This Annotation Will Soon Show up in the JDK
This recent Stack Overflow question by Yahor has intrigued me: How to ensure at Java 8 compile time that a method signature “implements” a functional interface. It's a very good question. Let's assume the following nominal type: @FunctionalInterface interface LongHasher { int hash(long x); } The type imposes a crystal clear contract. Implementors must provide … Continue reading We’re Taking Bets: This Annotation Will Soon Show up in the JDK
How JPA 2.1 has become the new EJB 2.0
Beauty lies in the eye of the beholder. So does "ease": https://twitter.com/thjanssen123/status/588212182225039361 Thorben writes very good and useful articles about JPA, and he's recently started an excellent series about JPA 2.1's new features. Among which: Result set mapping. We can summarise this mapping procedure as follows: a) define the mapping @SqlResultSetMapping( name = "BookAuthorMapping", entities … Continue reading How JPA 2.1 has become the new EJB 2.0
Subtle Changes in Java 8: Repeatable Annotations
Apart from the "big stuff", related to extension methods, lambda, and the streams API, Java 8 also has a couple of minor, very subtle changes. One of them is the fact that you can now annotate an object several times with the same annotation! An example taken from the tutorial: @Alert(role="Manager") @Alert(role="Administrator") public class UnauthorizedAccessException … Continue reading Subtle Changes in Java 8: Repeatable Annotations