Home » Java » Core Java (page 4)

Core Java

Java: Benefit from Inline Class Properties Starting from Java 8

In some years, Java will hopefully have an “inline class” feature which solves many challenges with the current state of Java. Read this article and learn how to use Java 8 and upwards today, and still benefit from some of the advantages of the coming inline object arrays such as; no indirect pointers, eliminated object header overhead and improved data ...

Read More »

Why Declarative Coding Makes You a Better Programmer

Declarative solutions with functional composition provide superior code metrics over legacy imperative code in many cases. Read this article and understand how to become a better programmer using declarative code with functional composition. In this article, we will take a closer look at three problem examples and examine two different techniques (Imperative and Declarative) for solving each of these problems. ...

Read More »

java.lang.Record: Draft Specification

Work on proposed Java Records continues to proceed. Brian Goetz started three new threads on the OpenJDK amber-spec-experts mailing list yesterday and two of them are focused on Java Records. One of these two Record-oriented threads discusses whether Java records should support varargs. The other thread provides the initial draft specification for the proposed class java.lang.Record and that is the ...

Read More »

Draft JEP to Remove Deprecated CMS Garbage Collector

In the 10 April 2017 post “Java Garbage Collectors: When Will G1GC Force CMS Out?,” I discussed JEP 291 (“Deprecate the Concurrent Mark Sweep (CMS) Garbage Collector”) and provided a summary of some of the feedback for and against deprecating (and ultimately removing) the Concurrent Mark Sweep (CMS) Garbage Collector (GC). Earlier this month, a draft JEP called “Remove the ...

Read More »

Checking What’s Thrown in Java Tests

Someone came up with the idea of using try and catch blocks in unit tests in Java: 1 2 3 4 5 6 7 8 @Test public void test() {    try {       callSomeCode();    } catch (Exception e) {       assertEquals("foo", e.getMessage());    } } The above is tempting, but doesn’t work. If the code under test didn’t throw, then no assertion would ...

Read More »

The Chameleon Function

In Doctor Who the character Kamelion was a robot which could take any form. The physical prop they used was allegedly very troublesome and only understood by its creator, who wasn’t around to help put it right. So to the Chamelion function … Consider this code: 01 02 03 04 05 06 07 08 09 10 11 12 13 14 ...

Read More »

The Final Word on “final”

In Java, overuse of final feels like SHOUTING. It’s outdated and inappropriate much of the time. Java and JavaScript This is mainly about the final keyword in Java, but my opinion on its counterpart const in JavaScript has changed slightly. That I can think that const is a good thing and final is a bad thing needs some unpacking. I ...

Read More »

JVM with no garbage collection

JVM community keeps on adding new GC and recently new one was added and it is called  Epsilon and is very special one. Epsilon only allocates memory but will not reclaim any memory. It might look like what is use of GC that does not perform any garbage collection. This type of Garbage Collector has special use and we will look ...

Read More »

Need driven software development using Mocks

Excellent  paper on mocking framework by jmock author. This paper was written in 2004 that is 18 years ago but has many tips of building maintainable software system. In this post i will highlight key ideas from this paper but suggest you to read the paper to get big ideas behind mocking and programming practice.  Mock objects are extension of ...

Read More »