JEP 347: Enable C++14 Language Features

OwnerKim Barrett
StatusProposed to Target
Discussionhotspot dash dev at openjdk dot java dot net
Reviewed byDavid Holmes, Mikael Vidstedt
Endorsed byMikael Vidstedt
Created2018/07/23 14:30
Updated2020/07/10 01:06


Allow the use of C++14 language features in the JDK C++ source code, and update HotSpot language usage guidance.


Through JDK 15, the language features utilized by C++ code in the JDK have been limited to the C++98/03 language standards. With JDK 11, the code has been updated to support building with newer versions of the C++ standard, although it is not yet using any new features. This includes being able to build with recent versions of various compilers that support C++11/14 language features.

The purpose of this JEP is to formally allow C++ source code changes within the JDK to take advantage of C++14 language features, and to give specific guidance about which of those features may be used in HotSpot.


This JEP does not propose any usage or style changes for C++ code in the JDK that is outside of HotSpot. The rules are already different for HotSpot and non-HotSpot code. For example, C++ exceptions are used in some non-HotSpot code, but are disallowed in HotSpot by build-time options. However, build consistency requirements will make the newer language features available for use in all C++ code in the JDK.


Changes to the Build System

To take advantage of C++14 language features some build-time changes are required, with specifics depending on the platform compiler. Minimum acceptable versions of the various platform compilers also need to be specified. The desired language standard should be specified explicitly; later compiler versions might default to a later, and possibly incompatible, language standard.

For Windows: Visual Studio 2017 is required for JDK 11. (Earlier versions will generate a configure-time warning and may or may not work.) For Visual Studio 2017 the default C++ standard is C++14. The /std:c++14 option should be added. Support for older versions will be dropped entirely.

For Linux: Replace the -std=gnu++98 compiler option with -std=c++14. The minimum supported version of gcc is 5.0.

For macOS: Replace the -std=gnu++98 compiler option with -std=c++14. The minimum supported version of clang is 3.5.

For AIX/PowerPC: Replace the -std=gnu++98 compiler option with -std=c++14 and require the use of xlclang++ as the compiler. The minimum supported version of xlclang++ is 16.1.

Changes to C++ Usage

The existing restrictions and best-practice recommendations for C++ usage in HotSpot code are based on the C++98/03 language standard, and described in the HotSpot Style Guide.

Similar restrictions and guidelines for features of more recent language standards will be added to that document. They will be described by a table of permitted features and another of excluded features. Use of permitted features may be unconditional or may have some restrictions or additional guidance. Use of excluded features is forbidden in HotSpot code.

There is a third category, undecided features, about which HotSpot developers have not reached a consensus, or possibly discussed at all. Use of these features is also forbidden.

Note, however, that the use of some language features may not be immediately obvious and may accidentally slip in anyway, since the compiler will accept them. As always, the code review process is the main defense against this.

Proposed changes to a feature's categorization are approved by rough consensus of the HotSpot Group members, as determined by the Group Lead. Such changes must be documented in updates to the Style Guide.

Lists of new features for C++11 and C++14, along with links to their descriptions, can be found in the online documentation for some of the compilers and libraries:

As a rule of thumb, permitting features which simplify writing code and, especially, reading code, are encouraged.

HotSpot has largely avoided using the C++ Standard Library. Some of the reasons for that may be obsolete (in particular, bugs encountered in early versions), while others may still be applicable (minimizing dependencies). Categorizing pieces of the Standard Library should go through the same process as language features.

An initial set of feature categorizations for HotSpot follows.



Similar lists for some other projects:

Risk and Assumptions

There may be other platforms with toolchains that do not yet support the C++14 language standard.

There may be bugs in the support for some new features by some compilers.