Skip to content

Instantly share code, notes, and snippets.

@pkafel
Last active July 21, 2017 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pkafel/c4932a073f7dfd95df64ef4b3d394aab to your computer and use it in GitHub Desktop.
Save pkafel/c4932a073f7dfd95df64ef4b3d394aab to your computer and use it in GitHub Desktop.
List of major features in Java 9

Java 9 features

Convenience Factory Methods for Collections (JEP 269)

Provide static factory methods on the List, Set and Map interfaces for creating unmodifiable instances of those collections.

List.of();
List.of(E e1);
List.of(E e1, E e2);
// more methods
List.of(E... elements);

Set.of();
Set.of(E e1);
Set.of(E e1, E e2);
// more methods
Set.of(E... elements);

Map.of();
Map.of(K k1, V v1);
Map.of(K k1, V v1, K k2, V v2);
// more methods
Map.ofEntries(Map.Entry<? extends K,? extends V>... entries);

New methods in Stream interface

  • dropWhile(Predicate<? super T> predicate) doc
  • takeWhile(Predicate<? super T> predicate) doc
  • iterate(T seed, Predicate<? super T> hasNext, UnaryOperator<T> next) doc
  • ofNullable(T t) doc

The Java Shell (Read-Eval-Print Loop) (JEP-222)

Provide an interactive tool to evaluate declarations, statements, and expressions of the Java programming language, together with an API so that other applications can leverage this functionality.

More Concurrency Updates (JEP-266)

An interoperable publish-subscribe framework, enhancements to the CompletableFuture API, and various other improvements.

  • Interfaces supporting the Reactive Streams publish-subscribe framework, nested within the new class Flow.
  • Time-based enhancements are added that enable a future to complete with a value or exceptionally after a certain duration, see methods orTimeout and completeTimeout.
  • Executor returned by the static methods named delayedExecutor allow a task to execute after a certain duration.
  • Subclass enhancements are added making it easier to extend from CompletableFuture, such as to provide a subclass that supports an alternative default executor.

Multi-Release JAR Files (JEP 238)

Extend the JAR file format to allow multiple, Java-release-specific versions of class files to coexist in a single archive.

Enhanced Deprecation (JEP 277)

Revamp the @Deprecated annotation, and provide tools to strengthen the API life cycle.

Milling Project Coin (JEP 213)

The small language changes included in Project Coin / JSR 334 as part of JDK 7 / Java SE 7 have been easy to use and have worked well in practice. However, a few amendments could address the rough edges of those changes. In addition, using underscore ("_") as an identifier, which generates a warning as of Java SE 8, should be turned into an error in Java SE 9. It is also proposed that interfaces be allowed to have private methods.

HTML5 Javadoc (JEP 224)

Enhance the javadoc tool to generate HTML5 markup.

Make G1 the Default Garbage Collector (JEP 248)

Make G1 the default garbage collector on 32- and 64-bit server configurations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment