Stephen Colebourne's blog

http://blog.joda.org/ (RSS)
visit blog
Pattern match Optional in Java 21
26 Feb 2024 | original ↗

I'm going to describe a trick to get pattern patching on Optional in Java 21, but one you'll probably never actually use. Using Optional As of Java 21, Pattern matching in Java allows us to check a value against a type like an instanceof with a new variable being declared of the correct type. Pattern matching can handle simple types and the...

Java on-ramp - Fully defined Entrypoints
11 Oct 2022 | original ↗

How do you start a Java program? With a main method of course. But the ceremony around writing such a method is perhaps not the nicest for newcomers to Java. There has been a bit of dicussion recently about how the "on-ramp" for Java could be made easier. This is the original proposal. Here are follow ups - OpenJDK, Reddit, Hacker news....

From Java 8 to Java 11
4 Nov 2021 | original ↗

Moving from Java 8 to Java 11 is trickier than most upgrades. Here are a few of my notes on the process. (And here are a couple of other blogs - Benjamin Winterberg and Leonardo Zanivan.) Modules Java 9 introduced one of the largest changes in the history of Java - modules. Much has been said on the topic, by me and others. A key point is...

Oracle's Java 11 trap - Use OpenJDK instead!
4 Nov 2021 | original ↗

TL:DR; Java is still available at zero-cost, you just need to stop using Oracle JDK and start using an OpenJDK build, such as this one or this one. The trap Java 11 has been released. It is a major release because it has long-term support (LTS). But Oracle have also set it up to be a trap (either deliberately or accidentally). For 23 years,...

Java is still available at zero-cost
4 Nov 2021 | original ↗

The Java ecosystem has always been built on a high quality $free (zero-cost) JDK available from Oracle, and previously Sun. This is as true today as it always has been - but the new six-monthly release cycle does mean some big changes are happening. Six-monthly releases Java now has a release every six months, something which greatly impacts how...

Time to look beyond Oracle's JDK
4 Nov 2021 | original ↗

From Java 11 its time to think beyond Oracle's JDK. Time to appreciate the depth of the ecosystem built on OpenJDK. Here is a list of some key OpenJDK builds. This is a quick follow up to my recent zero-cost Java post OpenJDK builds In practical terms, there is only one set of source code for the JDK. The source code is hosted in Mercurial at...

Big problems at the timezone database
25 Sept 2021 | original ↗

The last time I wrote about the timezone database on this blog, the database was under threat from a lawsuit. Fortunately that lawsuit went away relatively quickly as the company involved got the message that their action was a big mistake. Unfortunately this time the mess is internal. Paul Eggert is the project lead of the timezone...

Java switch - 4 wrongs don't make a right
4 Nov 2019 | original ↗

The switch statement in Java is being changed. But is it an upgrade or a mess? Classic switch The classic switch statement in Java isn't great. Unlike many other parts of Java, it wasn't properly rethought when pulling features across from C all those years ago. The key flaw is "fall-through-by-default". This means that if you forget to put a...

User-defined literals in Java?
22 Mar 2019 | original ↗

Java has a number of literals for creating values, but wouldn't it be nice if we had more? Current literals These are some of the literals we can write in Java today: integer - 123, 12s, 1234L, 0xB8E817, 077, 0b1011_1010 floating point - 45.6f, 56.7d, 7.656e6 string - "Hello world" char - 'a' boolean - true, false null - null Project Amber is...

Commercial support for Joda and ThreeTen projects
9 Jan 2019 | original ↗

The Java ecosystem is made up of many individuals, organisations and companies producing many different libraries. Some of the largest projects have long had support options where users of the project, typically corporates, can pay for an enhanced warranty, guaranteed approach to bug fixes and more. Small projects, run by a single individual or a...

Should you adopt Java 12 or stick on Java 11?
14 Nov 2018 | original ↗

Should you adopt Java 12 or stick on Java 11 for the next 3 years? Seems like an innocuous question, but it is one of the most important decisions out there for those running on the JVM. I'll try to cover the key aspects of the decision, with the assumption that you care about running with the latest set of security patches in production. TL;DR,...

Java release chains - Splitting features from security
31 Oct 2018 | original ↗

There is now a Java release every 6 months - March and September. It started with Java 9 and we're about to get Java 11. But should you jump on the release train? To answer that, we need to look at how Java's release chains are being split. Looking back at Java 8 In the olden days life was simple. There was a "major" Java release every few years...

Java SE 9 - JPMS module naming
30 Aug 2018 | original ↗

The Java Platform Module System (JPMS) is soon to arrive, developed as Project Jigsaw. This article follows the introduction and looks at how modules should be named. As with all "best practices", they are ultimately the opinion of the person writing them. I hope however to convince you that my opinion is right ;-). And as a community, we will...

Upgrading to Eclipse Photon
9 Jul 2018 | original ↗

I use Eclipse as my Java IDE. And the new release, Photon is now out. Photon is a large release, with lots of new features. The most important is the separation of the test and main classpaths, which has always been a point of pain in the IDE. Now it just works as you would expect, and the Maven plugin M2E correctly sets it up: Note the darker...

JPMS modules for library developers - negative benefits
22 Mar 2018 | original ↗

Java 9 introduced a major new feature - JPMS, the Java Platform Module System. After six months I've come to the conclusion that JPMS currently offers "negative benefits" to open source library developers. Read on to understand why. Modules for library developers Java 8 is probably the most successful Java release ever. It is widely used and...

Java 9 has six weeks to live
20 Mar 2018 | original ↗

Java 9 is obsolete in just six weeks (20th March 2018). What? You haven't upgraded yet? Well, Java 10 is only going to last six months before it is obsolete too. Update 2018-03-20: Java 10 is released. Java 9 is obsolete. Release train impact The new Java release train means that there will be a new release of Java every six months. And when the...

Java 9 modules - JPMS basics
14 Jun 2017 | original ↗

The Java Platform Module System (JPMS) is the major new feature of Java SE 9. In this article, I will introduce it, leaving most of my opinions to a follow up article. This is based on these slides. Java Platform Module System (JPMS) The new module system, developed as Project Jigsaw, is intended to raise the abstraction level of coding in Java...

Java SE 9 - JPMS automatic modules
9 May 2017 | original ↗

This article in my series on the Java Platform Module System (JPMS) is focussed on automatic modules. JPMS was previously known as Project Jigsaw and is the module system in Java SE 9. See also Module basics, Module naming and Modules & Artifacts. Automatic modules Lets say you are in charge of Java, and after 20 years you want to add a module...

Java SE 9 - JPMS modules are not artifacts
24 Apr 2017 | original ↗

This is the next article in a series I'm writing to help make sense of the Java Platform Module System (JPMS) in Java SE 9. JPMS was developed as Project Jigsaw. Other articles in the series are Module basics and Module naming. Module != Artifact If you want to grasp what JPMS modules are all about, it turns out that it is critical to understand...

Java Time (JSR-310) enhancements in Java SE 9
8 Feb 2017 | original ↗

The java.time.* API (JSR-310) was added to Java SE 8, but what has been going on since then? Java Time in Java SE 9 There are currently 117 java time issues targetted into Java SE 9. Most of these are not especially interesting, with a lot of mistakes in the Javadoc that needed fixing. What follows are some of the interesting ones: Main...

Code generating beans - mutable and immutable
26 Sept 2016 | original ↗

Java has long suffered from the pain of beans. To declare a simple data class takes far too much code. At JavaOne 2016, I talked about code generation options - see the slides. Code generation of mutable and immutable beans The Java ecosystem is massive. So many libraries releasd as open source and beyond, which naturally leads to the question as...

Private methods in interfaces in Java 9
20 Sept 2016 | original ↗

Java SE 9 is slowly moving towards the finishing line. One new feature is private methods on interfaces. Private methods on interfaces in Java 9 In Java 7 and all earlier versions, interfaces were simple. They could only contain public abstract methods. Java 8 changed this. From Java 8, you can have public static methods and public default...

Var and val in Java?
26 Mar 2016 | original ↗

Should local variable type inference be added to Java? This is the question being pondered right now by the Java language team. Local Variable Type Inference JEP-286 proposes to add inference to local variables using a new psuedo-keyword (treated as a "reserved type name"). We seek to improve the developer experience by reducing the ceremony...

Explicit receiver parameters
22 Dec 2015 | original ↗

I discovered that Java 8 has a language feature I'd never heard of before today! Explicit receiver parameters Consider a simple method in Java 7: public class Currency { public String getCode() { ... } } In Java 8, it turns out there is a second way to write the method: public class Currency { public String getCode(Currency this) { ......

Naming Optional query methods
15 Oct 2015 | original ↗

In the last article I outlined a pragmatic approach to Java 8's Optional class. In this one I'm looking at how we should name query methods that might return Optional. Convenience method naming Consider a requirement to produce a tree data structure, perhaps something like XML DOM. The basic data structure might look something like this: public...

↑ these items are from RSS. Visit the blog itself at http://blog.joda.org/ to find other articles and to appreciate the author's digital home.