Skip to content

Reasons to drop to Java 8 support

Lee Surprenant edited this page Sep 16, 2022 · 2 revisions

InputStream.transferTo

Could obviate the need for having our own InputOutputBuffer class? https://github.com/LinuxForHealth/FHIR/pull/2088

Arrays#compare

We wouldn't need to do our own compare impl for our tests: https://github.com/LinuxForHealth/FHIR/pull/2088/files#diff-a672a3278cc153609a36fab54622ae08c4550b6f8a95580f90663af0bb12e7bcR53-R54

Caffeine 3.x requires Java 11

https://github.com/ben-manes/caffeine/releases/tag/v3.0.0

Derby 10.15.x requires Java 9 or higher

https://db.apache.org/derby/derby_downloads.html#For+Java+9+and+Higher

Predicate.not

This one is pretty minor, but sometimes the method predicate reference form seems to be preferred and this would let us use that when we actually need the inverse: https://stackoverflow.com/a/51439995/161022

TransformerFactory.newDefaultInstance()

Java 9 supports newDefaultInstance to create a TransformerFactory using the JVM default implementation. This is preferred to using the class name directly. See: https://github.com/LinuxForHealth/FHIR/issues/1226

XMLInputFactory.newDefaultFactory() / XMLOutputFactory.newDefaultFactory()

Java 9 supports newDefaultFactory to create an XMLInputFactory (or XMLOutputFactory) using the JVM default implementation. This is preferred to using the class name(s) directly.

See also https://github.com/LinuxForHealth/FHIR/issues/2266

Caffeine 3.x codebase

Java 9 is required when using Caffeine 3.x and above. We are currently using a back level 2.x version.

Set.of and Map.of

Java 9 introduces a nice way to statically initialize maps and sets:

Map.of("key1","value1", "key2", "value2") (up to 10 key-value pairs) or Map.ofEntries(List<Entry>) More info at baeldung.com/java-initialize-hashmap#2-mapofentries

Set.of("Apple", "Ball", "Cat", "Dog"); More info at https://stackoverflow.com/questions/2041778/how-to-initialize-hashset-values-by-construction/37406054#37406054

toUnmodifiableList collector

Starting with Java 10, we can use the toUnmodifiableList method from Java's Collectors class:

List<String> givenList = Arrays.asList("a", "b", "c");
List<String> result = givenList.stream()
  .collect(toUnmodifiableList());