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.

1561 questions
989
votes
37 answers

How to resolve java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

I have some code that uses JAXB API classes which have been provided as a part of the JDK in Java 6/7/8. When I run the same code with Java 9, at runtime I get errors indicating that JAXB classes can not be found. The JAXB classes have been…
Andy Guibert
  • 34,857
  • 7
  • 32
  • 54
770
votes
1 answer

Why does array[idx++]+="a" increase idx once in Java 8 but twice in Java 9 and 10?

For a challenge, a fellow code golfer wrote the following code: import java.util.*; public class Main { public static void main(String[] args) { int size = 3; String[] array = new String[size]; Arrays.fill(array, ""); for(int i =…
Olivier Grégoire
  • 28,397
  • 21
  • 84
  • 121
260
votes
35 answers

Failed to install android-sdk: "java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema"

When installing the android sdk tools the following error is emitted: java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema Why is this happening and how can it be fixed? Debug output: $ java --version java 9 Java(TM) SE Runtime…
Novellizator
  • 9,169
  • 9
  • 38
  • 58
221
votes
10 answers

Replacements for deprecated JPMS modules with Java EE APIs

Java 9 deprecated six modules that contain Java EE APIs and they are going to be removed soon: java.activation with javax.activation package java.corba with javax.activity, javax.rmi, javax.rmi.CORBA, and org.omg.* packages java.transaction with…
Nicolai Parlog
  • 36,673
  • 16
  • 109
  • 236
175
votes
4 answers

what is an illegal reflective access

There are a lot of questions about illegal reflective access in Java 9. I have found plenty of discussion about working around the error messages, but I would love to know what an illegal reflective access actually is. So my question is: What…
Tschallacka
  • 24,188
  • 10
  • 79
  • 121
159
votes
4 answers

What is the difference between List.of and Arrays.asList?

Java 9 introduced new factory methods for lists, List.of: List strings = List.of("first", "second"); What's the difference between the previous and the new option? That is, what's the difference between this: Arrays.asList(1, 2, 3); and…
user5908494
152
votes
5 answers

Observer is deprecated in Java 9. What should we use instead of it?

Java 9 came out, and Observer has been deprecated. Why is that? Does it mean that we shouldn't implement observer pattern anymore? It would be good to know what is a better alternative?
curious95
  • 1,719
  • 3
  • 13
  • 16
144
votes
6 answers

Optional orElse Optional in Java

I've been working with the new Optional type in Java 8, and I've come across what seems like a common operation that isn't supported functionally: an "orElseOptional" Consider the following pattern: Optional resultFromServiceA =…
Yona Appletree
  • 7,618
  • 6
  • 31
  • 44
113
votes
3 answers

How is String concatenation implemented in Java 9?

As written in JEP 280: Indify String Concatenation: Change the static String-concatenation bytecode sequence generated by javac to use invokedynamic calls to JDK library functions. This will enable future optimizations of String concatenation…
Mohit Tyagi
  • 2,594
  • 3
  • 14
  • 29
106
votes
28 answers

Failed to run sdkmanager --list with Java 9

I downloaded and installed: JDK (jdk-9.0.1_osx-x64_bin.dmg) from Oracle here Android SDK (sdk-tools-darwin-3859397.zip) from Google here. After configuring the PATH variable, I tried running sdkmanager, which replaced the android command for…
103
votes
2 answers

What is the --release flag in the Java 9 compiler?

Java 9's javac has a new flag --release: > javac --help ... --release Compile for a specific VM version. Supported targets: 6, 7, 8, 9 How is it different from -source and -target flags? Is it just a shortcut for -source X -target X?
ZhekaKozlov
  • 29,055
  • 16
  • 100
  • 138
87
votes
8 answers

Why does Map.of not allow null keys and values?

With Java 9, new factory methods have been introduced for the List, Set and Map interfaces. These methods allow quickly instantiating a Map object with values in one line. Now, if we consider: Map map1 = new HashMap
hi.nitish
  • 2,154
  • 1
  • 11
  • 20
85
votes
2 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
  • 881
  • 1
  • 6
  • 8
82
votes
4 answers

How to solve InaccessibleObjectException ("Unable to make {member} accessible: module {A} does not 'opens {package}' to {B}") on Java 9?

This exception occurs in a wide variety of scenarios when running an application on Java 9. Certain libraries and frameworks (Spring, Hibernate, JAXB) are particularly prone to it. Here's an example from…
Nicolai Parlog
  • 36,673
  • 16
  • 109
  • 236
81
votes
1 answer

javax.xml.bind.JAXBException Implementation of JAXB-API has not been found on module path or classpath

I'm trying to run my Spring Boot application on Java 9, and I've faced with JAXB problem, which described in the guides, but didn't work for me. I've added dependency on JAXB api, and application started working. If you get the following exception,…
S34N
  • 5,119
  • 4
  • 29
  • 38
1
2 3
99 100