JavaSE 18

Wikipedia

Java (programming language)
Java (Programmiersprache)

OpenJDK

JDK 17

Tutorials

baeldung

Differences Between Oracle JDK and OpenJDK
Deep Dive Into the New Java JIT Compiler – Graal

YouTube

Java

Java 8 to 18: Most important changes in the Java Platform
Java 19 – The Best Java Release? – Inside Java Newscast #27

Removed

  • Access to JDK internals
  • JAXB / JAXWS / CORBA
  • Nashorn JS Engine
  • CMS Garbage Collector
  • ParallelScavenge+ Serial Old GC
  • Launch-Time JRE version selection
  • JVM TI hprof Agent
  • jhat tool
  • Native-Header Generation tool (javah)
  • Pack200
  • Solaris and SPARC Ports
  • RMI Activation
  • Demos and Samples

Deprecated

  • Biased Locking

Deprecated-for-removal

  • Applet API
  • SecurityManager
  • Value Based Classes constructors
  • Finalization

No Longer in Oracle JDK

  • JavaFX
  • Java Web Start
  • JRE (and Auto update)
  • 32-bit

Failed experiments

  • AOT Compiler (9 to 17)
  • JIT Compiler (10 to 17)

Improving the Java Programming Language

  • Local-Variable Type Inference – var
  • Local Variable Syntax for Lambda Parameters
  • Switch Expressions
  • Text Blocks
  • Records / Record Classes/li>
  • Pattern Matching for instanceof
  • Sealed Classes
  • Pattern Matching for switch

Local-Variable Type Inference – var

var url = new URL("http://www.openjdk.com/");
var con = urk.openConnection();
var is = new InputStreamReader(con.getInputStream());
var reader = new BufferedReader(is);

Switch Expressions

return switch(day) {
  case MONDAY, FRIDAY, SUNDAY -> 6;
  case TUESDAY                -> 7;
  case THURSDAY, SATURDAY     -> 8
  case WEDNESDAY              -> 9;
};

Text Blocks

var html += """
  <tr>
    <td>Retweets: %s</td>
    <td>Likes: %s</td>
  </tr>
""".formatted(t.getRetweetCount(),
              t.getLikeCount());

Records / Record Classes

record Point (int x, int y) {}

Pattern Matching for instanceof

if (obj instance of String s) {
    // String s = (String) obj not necessary anymore
}
[/code]

<h4>Sealed Classes</h4>

public abstract sealed class Shape permits Circle, Rectangle, Square {...}

public final class Circle extends Shape {...}

public sealed class Rectangle extends Shape permits TransparentRectangle,
                                                    FilledRectangle {...}
public final class TransparentRectangle extends Rectangle {...}
public final class FilledRectangle extends Rectangle {...}

public non-sealed class Square extends Shape {...}

Pattern Matching for switch

static String formatterPatternSwitch(Object o) {
  return switch(o) {
    case Integer i -> String.format("int %d", i);
    case Long l    -> String.format("long %d", l);
    case Double d  -> String.format("double %f", d);
    case String s  -> String.format("String %s", s);
    default        -> o.toString();
  };
}

Pattern Matching for switch – Matching null

static String formatterPatternSwitch(Object o) {
  return switch(o) {
    case null      -> "null";
    case Integer i -> String.format("int %d", i);
    case Long l    -> String.format("long %d", l);
    case Double d  -> String.format("double %f", d);
    case String s  -> String.format("String %s", s);
    default        -> o.toString();
  };
}

Keso Rupert

All Java 18 Features In Under 5 Minutes!

  • 400: UTF-8 by Default
  • 408: Simple Web Server
  • 413: Code Snippets in Java API Documentation
  • 416: Reimplement Core Reflection with Method Handles
  • 417: Vector API (Third Incubator)
  • 418: Internet-Address Resolution SPI
  • 419: Foreign Function & Memory API (Second Incubator)
  • 420: Pattern Matching for switch (Second Preview)
  • 421: Deprecate Finalization for Removal

History

Version Date
JDK Beta 1995
JDK 1.0 January 23, 1996
JDK 1.1 February 19, 1997
J2SE 1.2 December 8, 1998
J2SE 1.3 May 8, 2000
J2SE 1.4 February 6, 2002
J2SE 5.0 September 30, 2004
Java SE 6 December 11, 2006
Java SE 7 July 28, 2011
Java SE 8 (LTS) March 18, 2014
Java SE 9 September 21, 2017
Java SE 10 March 20, 2018
Java SE 11 (LTS) September 25, 2018
Java SE 12 March 19, 2019
Java SE 13 September 17, 2019
Java SE 14 March 17, 2020
Java SE 15 September 15, 2020
Java SE 16 March 16, 2021
Java SE 17 (LTS) September 14, 2021
Java SE 18 March 22, 2022

Leave a Reply

Your email address will not be published. Required fields are marked *