New JVM Features in JDK 11 | TechWell

New JVM Features in JDK 11

Girl Coding

Java SE 11 is a recent LTS (Long Term Support) version of Java. Java 11 has introduced several other (non-language features), some of which we’ll discuss in this article. 

New Access Context for Private Members of Inner Classes

Java supports inner classes (classes enclosed or nested within a top-level class) and access among the private members of the different inner classes.

Problem
The inner classes within a top-level class compile to separate class files. To allow access among the private members of the different inner classes, the compiler generates and adds package-private accessibility broadening bridge methods. Invoking a private member of another inner class is translated into invoking the compiler generated package-private method. The compiler-generated bridge methods have the following disadvantages:

  • increase the size of the deployed application

  • is not aligned with the encapsulation principle

  • could confuse users and tools


Solution
JDK 11 introduces a new access control context called "nests" to allow direct access between the private members of inner classes within the same outer top-level class. The compiler does not have to add accessibility broadening bridge methods to compiled code to add a level of indirection. Access among the private members of the inner classes is permitted by the JVM access rules as defined by the access control context.

Single New Constant-Pool Form to Create Other New Constant-Pool Forms

A class file is associated with a constant_pool table that specifies symbolic information about the code (such as classes, interfaces, methods, and fields) referenced by the class. A constant_pool table is generated by the compiler and is needed to run a class. Each item in the constant_pool table begins with a 1-byte tag whose value is based on the constant-pool type or form. A fixed set of constant pool forms is defined. As an example, the constant tag value for a class (constant type CONSTANT_Class) is 7, and the constant tag value for a String (CONSTANT_String) is 8. Java 7 introduced support for adding new constant-pool forms.

Problem
Defining new constant-pool forms is rather complex.

Solution
JDK 11 introduces a single new constant-pool form called CONSTANT_Dynamic that may be parameterized as needed to create new constant-pool forms. Only a bootstrap method with static arguments is needed to be provided by a user to create a new constant-pool form using CONSTANT_Dynamic.

Support for Unicode 10

The Unicode standard is a character coding standard for exchange, processing, and display of written texts of diverse languages and technical disciplines. 

Problem
JDK 10 supports an archaic version of the Unicode Standard, version 8.0.0. The latest Unicode version is 11.0.0.

Solution
JDK 11 added support for Unicode 10.0.0. In upgrading from version 8.0.0 of Unicode, 7,500 characters were added in Unicode 9.0.0 and 8,518 characters were added in Unicode 10.0.0. The main packages affected are java.lang.Character, java.lang.String, java.awt.font.NumericShaper, java.text.Bidi, java.text.BreakIterator, and java.text.Normalizer.

Nashorn JavaScript Engine Deprecated

The Nashorn JavaScript Engine was introduced in JDK 8. The command-line tool jjs tool may be used to run JavaScript programs from the command-line. The Nashorn JavaScript engine is based on ECMAScript-262 5.1 standard.

Problem
The ECMAScript language constructs and APIs have evolved rapidly making it difficult to maintain the Nashorn JavaScript Engine.

Solution
JDK 11 has deprecated the Nashorn JavaScript Engine including the jjs tool. The javax.script package, which consists of the scripting API classes that define Java Scripting Engines, is not affected.

Up Next

About the Author

TechWell Insights To Go

(* Required fields)

Get the latest stories delivered to your inbox every week.