GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - isabiq/demo-java-x: Demonstrates Java 9-13's new features

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

98 Commits
98 Commits

Folders and files

NameName
Last commit message
Last commit date
resources
resources
 
 
src
src
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
app-cds.sh
app-cds.sh
 
 
build.gradle
build.gradle
 
 
compile-run.sh
compile-run.sh
 
 
compile.sh
compile.sh
 
 
echo
echo
 
 
echo-haiku.txt
echo-haiku.txt
 
 
executables.sh
executables.sh
 
 
multi-release.sh
multi-release.sh
 
 
platform-logging.sh
platform-logging.sh
 
 
pom.xml
pom.xml
 
 
run.sh
run.sh
 
 
switch-default.sh
switch-default.sh
 
 

Repository files navigation

Java X Feature Demo

Demonstrates most features that were introduced by Java 9 and later versions. The links below take you to the demos in this project, the JEPs responsible for introducing the feature, and to other sources if available.

For a more practical approach to many of these features, including some quick code metrics, check my Java After Eight repo.

These articles discuss the recent Java versions and list a lot of the new features:

Java 13:

  • Definitive Guide To Java 13
  • 81 New Features and APIs in JDK 13

Java 12:

  • Definitive Guide To Java 12
  • 39 New Features (and APIs) in JDK 12

Java 11:

  • All You Need To Know For Migrating To Java 11
  • Java 11 Tutorial
  • 90 New Features (and APIs) in JDK 11

Java 9:

  • Code-First Java 9 Tutorial
  • The Ultimate Guide to Java 9
  • Inside Java 9 – Version Schema, Multi-Release JARs, and More
  • Inside Java 9 – Performance, Compiler, and More

You can read more from me on codefx.org, watch me blab on my YouTube channel, or follow me on Twitter.

Setup

This project requires at least the most recent Java release, at times even early-access builds of upcoming versions. You can get OpenJDK builds for both from jdk.java.net, although I prefer using SDKMAN.

Most of the project can be built with Maven. It uses toolchains to configure which Java version Maven should use for compilation and packaging. Create/modify toolchains.xml in Maven's user folder (~/.m2/ on Linux) to contain a block like the following:

<!-- if the file already contains a <toolchains> tag,
     you only need the inner <toolchain> block -->
<toolchains>
	<toolchain>
		<type>jdk</type>
		<provides>
			<version>13</version>
			<vendor>OpenJDK</vendor>
		</provides>
		<configuration>
			<jdkHome>/opt/jdk/13</jdkHome>
		</configuration>
	</toolchain>
</toolchains>

If your IDE doesn't like new syntax or APIs, you can always compile and run by hand - see compile.sh, run.sh (which expects the fully qualified name of the main class as argument) and compile-run.sh (conveniently combines the two - also needs the main class). The scripts are written for Linux but should look similar on other operating systems. If the appropriate Java version is not on your path, configure it in executables.sh.

For some features, you have to run the .sh scripts in the root directory. If that's necessary, the feature list below mentions it.

Java Platform Module System

The module system is too big to demo here. Check out the jpms tag on my blog, this demo project, or my book on the module system.

Language Changes

  • ⓧ sealed classes (JEP 360)
  • ⑯ instanceof pattern matching (JEP 394)
  • ⑮ text blocks (article, JEP 378)
  • ⑭ switch expressions (article, video, JEP 361)
  • ⑩ local-variable type inference with var (article, video, JEP 286)
    • experiments with intersection types (article)
    • experiments with ad-hoc fields and methods (article)
    • experiments with traits (article)
  • ⑨ private interface methods (JEP 213)
  • ⑨ try-with-resources on effectively final variables (JEP 213)
  • ⑨ diamond operator for anonymous classes (JEP 213)
  • ⑨ @SaveVarargs on private non-final methods (JEP 213)
  • ⑨ no warnings for deprecated imports (JEP 211)

New APIs

  • ⑪ HTTP/2 client: simple, more formal (tutorial, reactive request/response bodies)
  • ⑩⑨ version API, introduced in Java 9, updated in Java 10
  • ⑨ collection factory methods (instead of collection literals; JEP 269)
  • ⑨ reactive streams (JEP 266)
  • ⑨ stack walking (JEP 259, post on SitePoint including benchmarks)
  • ⑨ multi-resolution images (JEP 251)
  • ⑨ platform-specific desktop features (not supported by my OS so my sample sucks; PRs welcome! JEP 272)
  • ⑨ deserialization filter (targeted for JDK 9 but wasn't implemented when I created this; JEP 290)

Updated APIs

  • ⑫⑪ String in Java 12 and in Java 11
  • ⑯⑫⑨ Stream in Java 16 (article 1, 2), in Java 12 (article), and in Java 9 (article)
  • ⑫ formating numbers
  • ⑫ Files::mismatch
  • ⑫ error recovery with CompletableFuture
  • ⑪ I/O
  • ⑪ Predicate / Pattern
  • ⑪ Collection
  • ⑪⑨ Optional in Java 11 and in Java 9 (article)
  • ⑨ OS processes (JEP 102)

Some of the small changes have their own articles (in which case they are linked), but many don't. Most are show-cased in these posts, though:

  • Definitive Guide To Java 12
  • Eleven Hidden Gems In Java 11

JVM & Tooling

  • ⑬⑫⑩ application class-dara sharing (article, JEP 310, JEP 341, JEP 350)
  • ⑪ single-source-file execution and scripting: run the script with cat echo-haiku.txt | ./echo (article, JEP 330)
  • ⑨ multi-release JARs: classes and the script (JEP 238)
  • ⑨ platform logging: classes and the script (JEP 264)

Internals

  • ⑨ new version string schema (JEP 223)
  • ⑨ UTF-8 property files (JEP 226)
  • ⑨ reserved stack areas (JEP 270)
  • ⑨ DRGB implementations for SecureRandom (JEP 273)
  • ⑨ string compaction (JEP 254)

About

Demonstrates Java 9-13's new features

codefx.org

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.