OpenJDK 21 Compiler Warning on Constructor Calling Overridable Methods
Inspired by Actual Events
by @DustinMarx
1y ago
THe OpenJDK 21 beta 15 early access build (released 23 March 2023) adds an -Xlint warning to the Java compiler to notify Java developers when a class's constructor calls an overridable method. Specifically, changes for JDK-8015831 ("Add lint check for calling overridable methods from a constructor") and JDK-6557145 ("Warn about calling abstract methods in constructors") are avalable in OpenJDK 21 beta 15. CSR JDK-8299995 ("Add lint check for calling overridable methods from a constructor") provides background details and justificatiion for these new warnings. Two example classes are needed to ..read more
Visit website
More Frequent Java Long-Term Releases
Inspired by Actual Events
by @DustinMarx
2y ago
A little over four years ago, Mark Reinhold (Chief Architect of the Java Platform Group at Oracle) stated in his blog post "Moving Java Forward Faster": "For Java to remain competitive it must not just continue to move forward — it must move forward faster." In that post, Reinhold proposed "that after Java 9 we adopt a strict, time-based model with a new feature release every six months, update releases every quarter, and a long-term support release every three years." Reinhold stated that the motivation for this was that Java "must move forward faster ... for Java to remain competitive." Rece ..read more
Visit website
JDK 18: Code Snippets in Java API Documentation
Inspired by Actual Events
by @DustinMarx
2y ago
OpenJDK 18 Early-Access Build 16 (2021/9/23) is now available and includes the implementation for JEP 413 ("Code Snippets in Java API Documentation"), which is targeted for JDK 18. The objective of JEP 413 is to "introduce an @snippet tag for JavaDoc's Standard Doclet, to simplify the inclusion of example source code in API documentation" and the JEP itself covers the syntax of and features supported by the Javadoc {@snippet} tag. JEP 413 introduces the new {@snippet } Javadoc tag: We introduce a new inline tag, {@snippet ...}, to declare code fragments to appear in the generated documentation ..read more
Visit website
Java's Optional Does Not Supplant Traditional if-null-else or if-not-null-else Checks
Inspired by Actual Events
by @DustinMarx
2y ago
Java's addition of java.util.Optional has been welcome and had led to more fluent code for methods that cannot always return non-null values. Unfortunately, Optional has been abused and one type of abuse has been overuse. I occasionally have run across code that makes use of Optional when there is no clear advantage over using null directly. A red flag that can tip off when Optional is being used for no advantage over checking for null directly is when calling code employs Optional.ofNullable(T) against the returned value from the method it has just invoked. As with all "red flags," this doesn ..read more
Visit website
The Case of the Missing JEPs
Inspired by Actual Events
by @DustinMarx
2y ago
The JDK Enhancement-Proposal (JEP) process is "for collecting, reviewing, sorting, and recording the results of proposals for enhancements to the JDK and for related efforts, such as process and infrastructure improvements." JEP 0 is the "JEP Index" of "all JDK Enhancement Proposals, known as JEPs." This post provides a brief overview of the currently listed JEPs and discusses the surprisingly mysterious disappearance of two JEPs (JEP 187 and JEP 145). JDK Enhancement Proposal Overview The JEPs in the JEP Index with single-digit numbers are "Process" type JEPs and are currently: JEP 1: JDK En ..read more
Visit website
Surprisingly High Cost of Java Variables with Capitalized Names
Inspired by Actual Events
by @DustinMarx
2y ago
I've read hundreds of thousands or perhaps even millions of lines of Java code during my career as I've worked with my projects' baselines; read code from open source libraries I use; and read code examples in blogs, articles, and books. I've seen numerous different conventions and styles represented in the wide variety of Java code that I've read. However, in the vast majority of cases, the Java developers have used capitalized identifiers for classes, enums and other types and used camelcase identifiers beginning with a lowercase letter for local and other types of variables (fields used as ..read more
Visit website
Implementing equals(Object) with instanceof Pattern Matching
Inspired by Actual Events
by @DustinMarx
3y ago
Pattern matching for the instanceof operator was introduced as a preview feature with JDK 14 and was finalized with JDK 16. Because instanceof pattern matching is finalized for JDK 16, it is not surprising to now see changes being made to the JDK to take advantage of pattern matching for the instanceof operator. These changes to the JDK to leverage instanceof pattern matching can provide ideas and examples for where to begin applying this in our own code. In this post, I look at the use of instanceof pattern matching in implementation of the ubiquitous equals(Object) methods. In a message post ..read more
Visit website
Java NullPointerException Avoidance and Enhancement Tactics
Inspired by Actual Events
by @DustinMarx
3y ago
An encountered NullPointerException can be a useful mechanism for highlighting when a certain code flow or certain data has led to unexpected results (and the messages provided by NullPointerException are much improved with JDK 15). However, there are other times when the presence of null is not an exceptional condition and for those such cases there are several tactics that can be used to easily and cleanly avoid an unwanted NullPointerException. Even when the occurrence of a NullPointerException helps identify problems, there are other tactics we can use to make the most of these opportuniti ..read more
Visit website
JDK 17: Hexadecimal Formatting and Parsing
Inspired by Actual Events
by @DustinMarx
3y ago
Build 3 of JDK 17 Early Access Builds includes the implementation for JDK-8251989 ("Hex formatting and parsing utility"). This newly introduced functionality for parsing and formatting hexadecimal values is encapsulated in the new class java.util.HexFormat and is the subject of this post. Running javap against the new java.util.HexFormat class provides an easy way to see an overview of its API. The following output is generated from running javap java.util.HexFormat: Compiled from "HexFormat.java"public final class java.util.HexFormat { static final boolean $assertionsDisabled; public stati ..read more
Visit website
Java Predictions for 2021 on Foojay
Inspired by Actual Events
by @DustinMarx
3y ago
Geertjan Wielenga has posted "Java Predictions for 2021" on Foojay Today. It is a collection of predictions about Java in 2021 from eight members of the Java community (Almas Baimagambetov, Stephen Chin, Brice Dutheil, Marcus Hirt, Reza Rahman, Matt Raible, Simon Ritter, and me). The predictions are concisely written and it's interesting to see the overlap between them while at the same time seeing how different parts of "Java" are important to different people. In this post, I elaborate a bit more on my predictions that were included in "Java Predictions for 2021". I provided two somewhat rel ..read more
Visit website

Follow Inspired by Actual Events on FeedSpot

Continue with Google
Continue with Apple
OR