Questions tagged [java-9]

Use this tag for questions specific to Java 9, which is version 9 of the Java platform, released on the 21st of September 2017. In most cases you should also specify the java tag.

Oracle has released its updated list of proposed or targeted Java 9 enhancements. In addition to previously confirmed Java modularity updates, the most recent list includes a common logging system for all JVM components (JEP 158), more HotSpot JIT compiler controls (JEP 158), and refinements to improve the efficiency of garbage collection (JEP 214), and repair issues introduced by Project Coin language updates in JDK 7 (JEP 213). This is also the first release under the new version-string schema (JEP 223) and will hence be officially be numbered 9, not "1.9.0" as was the case for earlier versions.

Even with delays, Oracle has been steadily moving forward with its plans to modularize the JDK. But the scope of Java modularity took a step up in September, when Oracle announced four new JEPs, including JEP 220: Modular Run-Time Images. Ben Evans, writing for InfoQ, noted that swapping JARs for modules is the "point of no return for modularity," with serious implications for IDEs, toolmakers, and many Java application frameworks:

After this point, The Java Runtime Environment (JRE) will no longer be contained in jar files, and instead will be composed of modules (JSR 376). Files such as rt.jar and tools.jar no longer exist in the JRE. The platform will continue to accept and run applications and libraries packaged in conventional jar files, modular jar files, or in the new module file format. The intention is that over time, application developers wil migrate to the new modular formats as well.

See "Oracle Commit to Java Modularity" for more from Ben Evans on modularity updates in Java 9. Also see Takipi Blog: "Java 9 – The Ultimate Feature List" for a comprehensive (as of November 20, 2014) description of new features accepted or proposed for the next major release of Java, and "What's New in Java 9? (Besides Modules)" for another more recent compilation of features.

The API documentation of the release can be accessed at Oracle's technetwork.

1606 questions
107
votes
7 answers

What's the difference between requires and requires transitive statements in Java 9?

What's the difference between requires and requires transitive module statements in module declaration? For example: module foo { requires java.base; requires transitive java.compiler; }
Michał Szewczyk
  • 7,540
  • 8
  • 35
  • 47
106
votes
3 answers

How to quit the JShell and go back to the command-line?

When using the JShell, how do I exit it back to the CMD line? I have already tried ctrl + x and just writing quit, but to no joy.
Bryn
  • 1,091
  • 2
  • 7
  • 8
105
votes
10 answers

Maven compilation issue with Java 9

Trying to compile a Maven project using JDK 9.0.1 I'm facing this stacktrace without much of an explanation: Exception in thread "main" java.lang.AssertionError at jdk.compiler/com.sun.tools.javac.util.Assert.error(Assert.java:155) at…
Peter Major
  • 2,975
  • 4
  • 16
  • 17
103
votes
2 answers

Is there any need to switch to modules when migrating to Java 9 or later?

We're currently migrating from Java 8 to Java 11. However, upgrading our services was less painful, than we anticipated. We basically only had to change the version number in our build.gradle file and the services were happily up and running. We…
Younes El Ouarti
  • 2,200
  • 2
  • 20
  • 31
100
votes
1 answer

What's the difference between --add-exports and --add-opens in Java 9?

Java 9 (jdk-9+170) does not allow by default an application to see all classes from the JDK, unlike all previous versions of Java, due to the new module system. To workaround this, the java command line offers a new argument --add-exports which…
97
votes
9 answers

How to hide warning "Illegal reflective access" in java 9 without JVM argument?

I just tried to run my server with Java 9 and got next warning: WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by io.netty.util.internal.ReflectionUtil…
Dmitriy Dumanskiy
  • 11,657
  • 9
  • 37
  • 57
87
votes
2 answers

Why did Java 9 introduce the JMOD file format?

Java 9 has three ways to package compiled code in files: JAR JMOD JIMAGE JIMAGE is optimized for speed and space and used by the JVM at runtime so it makes sense why JIMAGE was introduced. JIMAGE files are not supposed to be published to maven…
ams
  • 60,316
  • 68
  • 200
  • 288
84
votes
6 answers

What is the replacement for javax.activation package in java 9?

Seems like javax.activation package is deprecated in Java 9. Oracle migration guide proposes to use --add-modules java.activation option during JVM start. However, I would like to avoid this and replace javax.activation package's classes, as it is…
Dmitriy Dumanskiy
  • 11,657
  • 9
  • 37
  • 57
82
votes
5 answers

Why project Jigsaw / JPMS?

Java's package management system always seemed simple and effective to me. It is heavily used by the JDK itself. We have been using it to mimic the concept of namespaces and modules. What is Project Jigsaw (aka Java Platform Module System) trying to…
John Eipe
  • 10,922
  • 24
  • 72
  • 114
78
votes
1 answer

Why does \R behave differently in regular expressions between Java 8 and Java 9?

The following code compiles in both Java 8 & 9, but behaves differently. class Simple { static String sample = "\nEn un lugar\r\nde la Mancha\nde cuyo nombre\r\nno quiero acordarme"; public static void main(String args[]){ String[]…
Germán Bouzas
  • 1,430
  • 1
  • 13
  • 18
75
votes
2 answers

Stream.peek() method in Java 8 vs Java 9

I am in the progress of learning through Java 8 lambda expressions and would like to ask about the following piece of Java code relating to the peek method in the function interface that I have come across. On execution of the program on IDE, it…
Patrick C.
  • 1,339
  • 3
  • 16
  • 31
75
votes
4 answers

takeWhile() working differently with flatmap

I am creating snippets with takeWhile to explore its possibilities. When used in conjunction with flatMap, the behaviour is not in line with the expectation. Please find the code snippet below. String[][] strArray = {{"Sample1", "Sample2"},…
Jeevan Varughese
  • 2,159
  • 2
  • 15
  • 20
72
votes
4 answers

Difference between RxJava API and the Java 9 Flow API

It seems on every iteration of Java for the last few major releases, there are consistently new ways to manage concurrent tasks. In Java 9, we have the Flow API which resembles the Flowable API of RxJava but with Java 9 has a much simpler set of…
Dovmo
  • 8,121
  • 3
  • 30
  • 44
72
votes
4 answers

List.of() or Collections.emptyList()

As an special case of List.of(...) or Collections.unmodifiableList() - what is the preferred Java 9 way of pointing to an empty and immutable list? Keep writing Collections.emptyList(); or switch to List.of();
Sormuras
  • 8,491
  • 1
  • 38
  • 64
70
votes
8 answers

Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1

My JDK 9+181 Spring Boot 2.0.0.BUILD-SNAPSHOT CLI application displays this warning on startup: WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1…
Jan Nielsen
  • 10,892
  • 14
  • 65
  • 119